$ show vacanza/holidays
This is the `holidays` Python library, a fast, efficient tool for generating country-, province-, state-, and financial-market-specific holiday calendars on the fly. It supports over 250 ISO 3166-1 countries (with subdivisions) and 25+ financial exchanges (NYSE, NASDAQ, LSE, etc.), using a mixin-based composition pattern to combine calendar systems (Gregorian, Islamic, Hebrew, Chinese, Hindu, Buddhist, etc.) with localization in dozens of languages. The library is designed for integration into applications that need to check whether a date is a holiday, retrieve holiday names, or export calendars to iCal format. It is not a data research project; it is a well-engineered Python library with a clean public API (`holidays.US()`, `holidays.country_holidays('US')`), extensive test coverage (100% code coverage enforced), and a robust observed-holiday rule system. The codebase demonstrates high craftsmanship through its reusable mixin pattern, configurable observed rules, and a generic iCal exporter. It is actively maintained with frequent commits, CI/CD pipelines, and dependabot integration.
The LLM identified 4 files worth highlighting for reuse:
Provides `ObservedHolidayBase` with a rich set of configurable observed/moved holiday rules (e.g., `SUN_TO_NEXT_MON`, `SAT_SUN_TO_NEXT_MON_TUE`, `ALL_TO_NEAREST_MON_LATAM`). These rules are defined as tuples and can be combined via `+`. The base class handles the logic of shifting holidays when they fall on weekends or other non-observance days. This is a highly reusable pattern: any project needing to handle observed holidays (e.g., payroll, scheduling) can extract this module and apply the same rule system with minimal adaptation.
A collection of mixin classes (e.g., `ChristianHolidays`, `IslamicHolidays`, `ChineseCalendarHolidays`, `HinduCalendarHolidays`, `InternationalHolidays`) that provide reusable `_add_<holiday_name>` methods. Each country class inherits from `HolidayBase` and one or more of these mixins, composing holiday logic without code duplication. This pattern is cleanly isolated and could be extracted to build holiday support for any new calendar system or domain (e.g., academic calendars, religious observances).
Implements `ICalExporter`, a generic class that converts any `HolidayBase` instance into iCalendar (.ics) format. It handles line folding, UUID generation, and optional LANGUAGE property. The exporter is completely decoupled from the holiday data and can be reused with any holiday-like dictionary (date -> name mapping). This is a clean, self-contained utility that could be extracted into a separate library or used in other calendar export projects.
Provides the `ChildEntity` mixin for creating alias country codes that map to a parent country's subdivision (e.g., `Guam(ChildEntity, UnitedStates)`, `Mayotte(ChildEntity, France)`). This avoids duplicating holiday logic for territories that are subdivisions of another country. The pattern is clean, self-contained, and could be reused in any domain where entities are aliases of a parent entity's sub-entities (e.g., regional branches, subsidiary companies).