Liturgical-Calendar / LiturgicalCalendarAPI

A PHP script / API endpoint that will generate the Roman Catholic liturgical calendar for any given year, calculating the mobile festivities and the precedence of solemnities, feasts, memorials...
Apache License 2.0
44 stars 11 forks source link

Handle conditional dates for liturgical events in national calendars #206

Open JohnRDOrazio opened 6 months ago

JohnRDOrazio commented 6 months ago

Certain events loaded from national liturgical calendars require some logic to create the event conditionally based on whether it falls on a Sunday or Solemnity. This logic is currently hardcoded into the main LitCalAPI class. An example is the National Day of Prayer for the Unborn in the USA:

https://github.com/Liturgical-Calendar/LiturgicalCalendarAPI/blob/436ebf79c93c65835c97e91232b0775bef60e8aa/includes/LitCalAPI.php#L2323-L2330

We should extend the national calendar schemas to allow for language constructs that will allow to define rules for how such situations should be handled. This will likely require a bit of thought and planning, based on various concrete examples.

JohnRDOrazio commented 6 months ago

something like this:

"rules": [
    {
        "condition": {
            "coincidesWith": {
                "LitGrade": "SOLEMNITY"
            }
        },
        "then": {
            "move": "P1D"
        }
    }
]

The "coincidesWith" object could possibly accept a few different properties other than "LitGrade", for example it could be the eventkey of a specific liturgical event...

The "then" instruction could possibly accept a few different properties... whether a period of time to move it such as adding one day, or moving it one day before or after a specific other liturgical event (therefore specifying the eventkey of the other liturgical event)...

There will probably ever be only one rule, however this construct would allow for having more than rule. Rules would have to be applied in sequence...