Code quality | Translation status | OpenAPI validation | |
---|---|---|---|
main branch | development branch | ||
An API written in PHP that will generate the liturgical calendar for any given year, based on the General Roman Calendar, calculating the mobile festivities and the precedence of solemnities, feasts, memorials... Can also produce calendar data for nations, dioceses, or groups of dioceses. This calendar data can be served in various formats such as JSON, YAML, XML, or ICS. More information on the website https://litcal.johnromanodorazio.com/.
OpenAPI documentation can be found here (kudos to @MichaelRShelton for generating the docs from the Swagger docker image).
The API is packaged as a composer library: run composer install
to setup the autoload functionality.
Some characteristics of this API:
- The data is based on official sources, not copied from random internet sources. Sources used are the various editions of the Roman Missal in Latin, English, and Italian, Magisterial documents, and the Decrees of the Congregation for Divine Worship
- Missale Romanum, Editio typica, 1970
- Missale Romanum, Reimpressio emendata, 1971
- Missale Romanum, Editio typica secunda, 1975
- Missale Romanum, Editio typica tertia, 2002
- Missale Romanum, Editio typica tertia emendata, 2008
- Mysterii Paschalis, PAULUS PP. VI, 1969
- Decrees of the Congregation of Divine Worship
- The data is historically accurate, i.e. the liturgical calendar produced for the year 1979 will reflect the calendar as it was in that year, and not as it would be today (obviously future years will reflect the calendar as it is generated in the current year; as new decrees are issued by the Congregation for Divine Worship or new editions of the Roman Missal are published, the script will need to be updated to account for any new criteria)
There are a few proof of concept example applications for usage of the API at https://litcal.johnromanodorazio.com/usage.php, which demonstrate generating an HTML representation of the Liturgical Calendar.
- The first example uses cURL in PHP to make a request to the endpoint and handle the results.
- The second example uses AJAX in Javascript to make the request to the endpoint and handle the results.
- The third example makes use of the FullCalendar javascript framework to display the results from the AJAX request in a nicely formatted calendar view.
- The fourth example is the same as the third except that it outputs the Messages first and the FullCalendar calendar view after.
All of these examples request JSON
as the data exchange format generated by the endpoint. Any application could use the endpoint in a similar manner: an Android App, a plugin for a Desktop Publishing App...
(See usage.php#calSubscription.)
- GOOGLE CALENDAR ON A DESKTOP COMPUTER: you can only add a calendar by URL using Google Calendar on a computer, I don't believe it is possible from smartphone / Android devices. At the bottom left corner of the screen, next to
Other calendars
, click on the+
to add a new calendar and chooseFrom URL
. Paste in the URL of the endpoint with the desired parameters, (make sure you useICS
as value of thereturn_type
parameter). And remember, if you omit theyear
parameter, it will use the current year. This should mean that as Google Calendar continues to poll the calendar URL (supposedly every 8 hours), on the turn of a new year new events should be created automatically for the new year. Once the calendar has been added from a computer, it should become available for the same gmail account on the Google Calendar app on a smartphone. - CALENDAR APPS ON AN ANDROID DEVICE: after you have added a calendar by URL in your Google Calendar on a Desktop Computer, you should then find that calendar synchronized with your Google account, so the calendar should become available to any Android Calendar apps that have access to your Google account to synchronize calendars.
- IPHONE: go to
Phone Settings
->Accounts
->Add account
->Other
->Add Calendar
, and paste in the endpoint URL with the desired parameters, (make sure you useICS
as value of thereturn_type
parameter). And remember, if you omit theyear
parameter, it will use the current year. This should mean that as the iPhone Calendar continues to poll the calendar URL, on the turn of a new year new events should be created automatically for the new year. - MICROSOFT OUTLOOK (tested with Outlook 2013): at the bottom of the screen, switch from
Email
view toCalendar
view. On the ribbon of theHome
menu item, click onOpen calendar
->From the internet
. Paste the endpoint URL with the desired parameters, (make sure you useICS
as value of thereturn_type
parameter). And remember, if you omit theyear
parameter, it will use the current year. On the following screen, check the checkbox along the lines of "Poll this calendar in the interval suggested by the creator", which would mean that Outlook Calendar should poll the calendar URL once a day. This means that without theyear
parameter, on the turn of a new year new events should be created automatically for the new year. Make sure the Calendar is created in theOther calendars
folder; if you find it under thePersonal calendars
folder, drag it and drop it onto theOther calendars
folder, this should ensure that it is treated as a subscription internet calendar. You can manually trigger an update against the calendar URL by clicking onSend/receive all
(from theSEND/RECEIVE
menu item). One highlight of the calendar in Outlook is that it supports a minimal amount of HTML in the event description, so the event descriptions in the Liturgical Calendar are a little bit more "beautified" for Outlook.
To test the API locally, you can use PHP's builtin server. However, you will need to spawn at least a couple of workers, since some routes will make a request internally to another route. For example, a request to the /calendar
route will make a request internally to the /calendars
route.
Spawn at least two workers:
PHP_CLI_SERVER_WORKERS=2 php -S localhost:8000
For convenience when using VSCode, a tasks.json
has been defined so that you can simply type CTRL+SHIFT+B (CMD+SHIFT+B on MacOS) to start the PHP builtin server and open the browser.
v4.0 (January 3rd 2025)
- package the API source as a composer library for autoload functionality
- move the endpoints from PHP scripts to resource paths, and create a router
- add
YAML
as a response media type - use JSON resource files for the Tests server in place of PHP Unit defs (remove dependency on PHP Unit)
- fix bug where liturgical commons were not getting localized correctly
- fix XML response, implement XML and ICS validation
- update the OpenAPI schema
- add timing to response output and to response headers
- refactor responses to use snake_case properties and collections (this also fixes
SaintAndrewAp
bug foryear_type=LITURGICAL
inyear=2023
, see issue #249) - add Calendars for Netherlands and for Canada, kudos to Steven van Roode and to Fr. @chrissherren for the contributions
- add a Dockerfile to easily spin up a Docker container with a local instance of the API
- fix for cases in which Immaculate Heart of Mary is suppressed, see commit 6f16f130fb2df88488f8ad9ddcc5c8961380f387
- fix calculation of weekdays between Epiphany and Baptism of the Lord, see issue #237
- fix Chritmas weekdays should not be created when there is an obligatory memorial, see commit a8ca47744582d89aaed195658a40a22145659eee
- fix moving of celebrations by a National Calendar that were suppressed in the General Roman Calendar, see issue #271
- add abbreviated form of the liturgical rank / grade to the
Festivity
output, see issue #251 - use ISO 3166-1 Alpha-2 codes to identify nations, see issue #231
- created an interface that allows to create Unit Tests, see issue #205
- added an index of all dioceses of Latin rite, kudos to Gabriel Chow of gcatholic.org for the contribution
- add Decree of the Congregation for Divine Worship for Italy: Immaculate Heart suppresses 2nd Sunday of Advent, see commit 191d3247838a4da18ce1ab7c0ca2f16a1b2d516e
- add Decree of the Congregation for Divine Worship for Italy: Saint Nicholas obligatory memorial since 2020, see issue #248
- feature: discoverability of supported locales, see issue #240
- feature: all national and diocesan calendars are now multilingual by default, see issue #150
- and a number of other bugfixes, features, and improvements
v3.9 (April 9th 2024)
- update PHP dependencies (
swaggest/json-schema
,phpunit/phpunit
) - add swagger validation badge to README
- remove deprecated LitLocale enums
- better locale handling (implement Locale::getPrimaryLanguage, simplify locale validity check, fix Locale class letter case )
- fix: wrong liturgical color for feast of Our Lord Jesus Christ King of the Universe
- add
liturgicalSeason
toFestivity
output, andDateTime
andTimestamp
to theMetadata
output - remove unneeded request headers from
Metadata
output - avoid defining year cycle for holy week and octave easter
- make sure sat mem BVM only Ordinary Time
- add isVigilFor key to vigil Masses
- implement YearType with types LITURGICAL and CIVIL
- output Liturgical Calendar as default (from first Sunday of Advent until Saturday of the 34th Week of Ordinary Time)
- track timing of calculations or read operations for pre-calculated / cached calendars, and add headers to Response: add X-LitCal-ExecutionTime header, add X-LitCal-Startime and -Endtime headers, add X-LitCal-Generated header
- fix rank Dedication Lateran Basilica
- allow national calendars to adhere to Feast of Jesus Christ Eternal Hight Priest fix issue #96 enable Feast Eternal High Priest, update EternalHighPriest setting based on national calendar
- update schemas to account for new settings and new properties in response output
v3.8 (February 1st 2023)
- fix language for iCal / ICS format
- fix bug in LitColor enum (static class variable)
- add empty
displayGrade
property for higher solemnities - add localized info to Festivity output for liturgical color, common, grade...
- define Divine Mercy Sunday starting from the year 2000
- update OpenAPI schema to v3.1
v3.7 (December 14th 2022)
- fix support for correct ordinal number spelling for any language
- fix "Year I", "Year II" references which should only concern weekdays of Ordinary Time
- fix: in cases where the diocesancalendar parameter was set, but the nationalcalendar parameter was not, the national calendar settings were not being picked up correctly
- fix for Netherlands national calendar data (Ascension on Thursday)
v3.6 (December 13th 2022)
- allow Diocesan calendars to define mobile festivities
- allow Diocesan calendars to define
untilYear
properties for festivities that may have changes after a given year - remove hardcoding of English, Latin and the 5 main European languages and allow for any possible language
- allow for geographic locales, in order to better identify source data for a given national or diocesan calendar
- remove hardcoding of supported national calendars, and automate the scan for existing calendars
v3.5 (December 4th 2022)
- Fix days before / after Epiphany (handled differently in different national calendars!)
- Add Dutch translation for Netherlands, thanks to Steven van Roode
v3.4 (June 6th 2022)
- Fix issue with Saint Vincent deacon in national calendar for USA • c27289f
- simplify calculation of Vigil Masses • 0afa39b
- add cache-control headers to the Metadata enpoint • 3d77f60
- complete move from MySQL tables to JSON source files • d9c7344
- add DiocesanGroups info to the Metadata endpoint • a378f16
- move National Calendar data and Wider Region calendar data to JSON source files: • 1716486 • 4e29877 • 15f16c3 • 5b27417 • 1247b98 • cdf8bdb • 62ad946 • 7395ef4 • e5d010f • 9ada5aa • c9646a6 • 25aa01a • ea5beac • b81b868 • a837f7b • 7e9e894 • 4d1eca2 • e86ccda • 445d22c • a0e693f
- add cache-control headers to the Main endpoint • d2ae04d • df7e17d
- add WiderRegions info to the Metadata endpoint • b3f567f
- add methods to FestivityCollection • a9e1760
- add year limits to Roman Missals • 0f939ba
- fix enum validations • 4c595c1 • c3d2492
- various fixes • 8330fa0 • 6cf80da • a7e85de • 4e0a597 • 8ee7065 • 44df76f • 5638ec6 • 4f7c11f • 4decc12 • 5450010 • e2c1f6c • fcb1108 • ec772a0 • d804c7e • a52019e • 8eadab7
- add Roman Missal info to the Metadata endpoint • 715c28a
- output 404 error for unavailable resources • 0bcbd3b
- define JSON schemas • b66f4d2 • 0db16a7 • 1574c01 • a70f383 • a9ac10e • bd2ba8b • fabf7b6 • 8b8ae2a • 85066b8 • 8a66bf4 • 3f79b05 • 5e82f30 • 552eaa3 • f682300 • b48bb72 • 289f4c2 • 1245cfc • a4d8bc4 • 1257b9b • baef32b • 09edca1 • 228af9c
- create JSON schema validation • 3938a27 • 85702b0 • a296cc5 • 21f2540 • 765bac9 • 10d7619 • 4828724 • 9cbb8e6 • 16809cb • a1de05c
- add more data for National Calendars to the Metadata endpoint • 34ef54f
- update translations
v3.3 (January 27th 2022)
- move festivity data from the 2008 Editio Typica Tertia emendata out from the
LitCalAPI.php
, to a JSON file - move data for festivities from Decrees of the Congregation of Divine Worship out from the
LitCalAPI.php
, to a JSON file
v3.2 (January 23rd 2022)
- allow full CORS requests from enabled domains
- allow Diocesan overrides for Epiphany, Ascension and Corpus Christi
v3.1 (December 26th 2021)
- bugfix which was missed in the v3.0 release: 86ee62ad68d58736880da2b5b39117dec7386dfc
v3.0 (December 26th 2021)
- all calendar data moved from a MySQL database to JSON files, that can be tracked in the repository
- the Calendar data for the Universal Calendar, as contained in the JSON files, is now translatable to other languages through a Weblate project
- the frontend and any implementations of the API have been moved to their own separate repositories, only the API code remains in this repository
- the PHP source code for the API has been pretty much completely rewritten, using classes and enum type classes
- all translatable strings in the PHP source code have been ported to
gettext
, and are now managed in a Weblate project - parameters
diocesanpreset
andnationalpreset
have been renamed todiocesancalendar
andnationalcalendar
- API now supports POST requests that send JSON in the body instead of Form Data
- Data type can be set through the
Accept
header rather than thereturntype
parameter - Language can be set through the
Accept-Language
header rather than thelocale
parameter
v2.9 (November 12th 2020)
- adds Vigil Masses for Sundays and Solemnities, including occasional notes by the Congregation for Divine Worship
- add Patron Saints of Europe, applicable for Italian Calendar (and eventually any other national calendar in Europe that may be added in the future)
- add Saturday Memorial of the Blessed Virgin Mary
v2.8 (August 11th 2020)
- adds
diocesanpreset
andnationalpreset
parameters with relative calendar data - adds all of the data from the recent Decrees of the Congregation for Divine Worship and verifies integrity with past Decrees
- ensures
Messages
returned are as specific as possible, while trying to keep the code as clean as possible - adds FullCalendar example
v2.7 (July 28th 2020)
- adds
Messages
array to the data that is generated by the endpoint, justifying the calculations made for the generation of the requested calendar - fixes an issue with the memorial Saint Jane Frances de Chantal after 1999, when it was decided to move the memorial from Dec. 12 to Aug. 12 in order to allow Our Lady of Guadalupe on Dec. 12 (if another more important celebration took place on Dec. 12, Saint Jane Frances was being removed before it could be moved, this is now handled correctly) add translations for the Messages array in Italian, English and Latin (please forgive my macaronic latin, it's not at all perfect, it's mostly conjecture, I hope to have it proofread at some point)
- update PHP example to display
Messages
array in a table below the generated calendar - update PHP example to fix parsing of Liturgical colors for memorials with more than one possible Common and more than one possible liturgical color
- fix a few errors in the database as regards liturgical colors for some memorials with more than one possible Common
v2.6 (July 26th 2020)
- integrate the calculation of the liturgical cycle (YEAR A,B,C for festivities and YEAR I,II for weekdays) directly into the engine, so that applications that take care of elaborating the data for display don't have to worry about it
- update both examples, PHP and Javascript, to use the new
liturgicalyear
property returned in the JSON data, and bring Javascript example up to par with the PHP example (add month cell that spans all events for that month)
v2.5 (July 25th 2020)
- make sure all endpoint parameters can have values with either uppercase or lowercase characters
- fix a few small issues with the ICS data generation
v2.4 (July 24th 2020)
- move as many festivities as possible to the MySQL tables to allow for localization (mobile feasts will be calculated in the script, but still need to be localized)
- add ICS data generation (requires more localization strings, because it is already a form of final display of the data)
v2.0 (January 8th 2018)
- separate the display logic from the engine, so that the engine can act as an endpoint
- make the engine return JSON or XML data that the display logic can use to generate a user-friendly representation of the data
v1.0 (July 26th 2017)
- proof of concept for the correct generation of a liturgical calendar
- create MySQL table for the Proper of the Saints