Holiday Calendars, File Formats, et al

The classic holiday.py module (part of an old dateutil package -- old enough to rely on module time rather than the relatively recent datetime!) does a good job of calendric calculations (including Jewish <-> Gregorian calendar translations) but does not deal with persistence (reading or writing).

As @Brian's response suggests, ics is the dominant format for "calendars" in a file (and there are holiday files, among others, in such format). To read and write ics file in Python you can for example use the iCalendar package, which does precisely that task, or vobject, which is a much broader package supporting the range of vCard and vCalendar formats (including iCalendar).


Mozilla has a set of user-contributed holiday files in .ics format. That may get you started. Unfortunately they go out to different date ranges. iCalShare also has holiday calendars in .ics format.

Note:

Some holidays are state or region-related, rather than country-related.

I've found in the past that a hierarchical approach works. e.g. check for a city holiday calendar, then a state calendar, then a country calender.

There's a Python module for reading .ics files called icalendar(also on pypi). I can't vouch for its quality, unfortunately.