Add Halloween to US Holiday Schedule
Please add Halloween (Oct 31st) to US Holiday schedule. I use this code to automate my outdoor lights based on holiday. Halloween is a fun holiday to change lights.
Hi @schmittyice-hyp! Thanks for the idea!
I love this holiday! And it's quite unfortunate that at this moment python-holidays provides official holiday list (both federal and regional ones) only.
I don't know what your automation looks like but it sounds like you might benefit from forking the repo and adding that holiday by yourself for using the fork further in your automation. Another way would be extending the python-holidays to optionally include non-official holidays based on some parameter value. This may or may not be ready before this year's Halloween.
-- Ark
You can easily add this on your own. Here is a simple example:
class HalloweenHolidays(holidays.HolidayBase):
def _populate(self, year):
self[date(year, 10, 31)] = "Halloween"
german_holidays = holidays.country_holidays('DE', subdiv='NW', years=2022)
german_holidays += HalloweenHolidays()
for date, name in sorted(german_holidays.items()):
print(date, name)
This is all documented quite well. You can create new custom holiday classes and merge different holiday classes. This way I add halloween to the german holidays and debug print the result afterwards.
At the current time, I agree with @NicoHood : the right way to go is using a custom class to implement your required additional days. Anyway, thanks everyone for your interest and support!