does not seem to return true for holidays that coincide with a weekend (well, banks, of course…). Easter Sunday is an example. How can I emulate something like
Ephemeris.**isHoliday()**
so I can check for a holiday even when it’s on a weekend? Plus, how can I get something like:
With a custom XML config that lists the weekend holidays. As you surmise, the default XML file from JollyDay does not include holidays that always occur on a weekend. But if you create your own XML you can list any day you want regardless of which day of the week it falls. See https://www.openhab.org/docs/configuration/actions.html#custom-bank-holidays for details.
Note that certain holidays like Easter are not easy to define without doing some calculations so those get defined differently. In the case of Easter I think you would use <tns:ChristianHoliday type="EASTER"/>.
There are some unpleasant inconsistencies, indeed. I’ve put Easter Sunday and Pentecost Sunday into my local copy of Holidays_de.xml:, to test @rlkoshak 's suggestion:
If I define secondChristmasDay2021 = Ephemeris.getNextBankHoliday(622, "/etc/openhab2/services/Holidays_de.xml"), which happens to be a Sunday, where banks never work in Germany,
Ephemeris.isBankHoliday(622, "/etc/openhab2/services/Holidays_de.xml") returns 1, and Ephemeris.getHolidayDescription(secondChristmasDay2021) returns “2. Weihnachtsfeiertag”.
If I define pentecostSunday2021 = Ephemeris.getNextBankHoliday(405, "/etc/openhab2/services/Holidays_de.xml"), which is on a Sunday, too,
Ephemeris.isBankHoliday(405, "/etc/openhab2/services/Holidays_de.xml") returns 0, and Ephemeris.getHolidayDescription(pentecostSunday2021) returns “Pfingsten”.
Strange inconsistencies:
The Second Christmas Day of 2021 is considered to be a “bank holiday” although it’s on a Sunday (where banks would never be open in Germany, anyway).
After having been added to the config file, Pentecost Sunday of 2021 is considered a bank holiday by getNextBankHoliday() (since it is returned as the next one), but not by isBankHoliday().
Listing a holiday in Holidays_de.xml obviously only influences getNextBankHoliday(), but not isBankHoliday() - the information whether a holiday “is” a bank holiday seems to depend on other places in the code, too.
BTW: In Germany, we never speak of “bank holidays” but of “legal holidays” (which may differ a bit among our federal states). “Bank holiday” as a concept is not defined, over here. When Germans speak of “holidays” in general, they may have “legal holidays” in mind, but also holidays as defined by religious communities, which might not be “legal holidays” at all.
isn’t that much of an inconsistency. The XML file that defines the holidays that comes with JollyDay only omits those holidays that always occur on a weekend. The second day of Christmas often can occur on a weekday so it’s included. They don’t update the XML file every year.
That is the inconsistency identified by Thomas and which we need one of the feature devs to reply on. This could be expected behavior and they coded it that way (unlikely), expected behavior that the developer of JollyDay coded, or a bug that needs to be fixed.
See 2.
We don’t in the US either. We have “Government holidays” which are days the government gives its employees off. But ultimately it is up to each employer to decide which (if any) holidays to give it’s employees. Many companies, especially those in the service sector, do not get any holidays at all. Even the schools often do not strictly follow the government holidays so the list that comes with JollyDay (and therefore is used by default by Ephemeris) is not all that useful for most of us in the US.
I think the term “Bank Holiday” mainly comes from the UK.
Copy a locale-specific holiday list from the Jollyday repository, e.g. Holidays_de.xml
Add missing holidays, e.g. <tns:ChristianHoliday type="EASTER"/>
Store it in a suitable dir, e.g. the services config dir: /etc/openhab2/services/Holidays_de.xml
To cope with a documented bug, use it with day offset to a ZonedDateTime, e.g. for tomorrow: Ephemeris.isBankHoliday(ZonedDateTime.now().plusDays(1), "/etc/openhab2/services/Holidays_de.xml")