Search code examples
python-3.xpython-holidays

Python Holidays Module: Custom holiday not included in "observed"


I'm trying to figure out why a custom holiday is not showing the "observed" date if the holiday itself lands on a weekend. For example, I added Cesar Chavez Day, which is on 03/31/xxxx. While I was testing out different years, I noticed that Cesar Chavez Day lands on a Sunday in 2019, but it is not showing an observed day like it does for the other holidays. The same issue applies to Lincoln's Birthday (falls on Saturday in 2022) since I added that day as well. Here is the modified holiday list:

class county_holidays(holidays.US):
    def _populate(self, year):
        holidays.US._populate(self, year)
        self[date(year, 2, 12)] = 'Lincoln\'s Birthday'
        self[date(year, 3, 31)] = 'Cesar E. Chavez'
        self.append({datetime.date(datetime(year, 11, 1) + relativedelta(weekday = TH(+4)) + timedelta(days = 1)): 'Day after Thanksgiving'})

Isn't the default setting for "observed" set to True, so why doesn't it apply to the custom holidays? How can I fix this?


Solution

  • Not all holidays are Observed on weekdays if they occur on a weekend, so right now the Holidays package does not support adding an Observed day for custom holidays. If you want this function added, you can add a feature request to https://github.com/dr-prodigy/python-holidays/issues