Give AlbumentationsX a star on GitHub — it powers this leaderboard

Star on GitHub

holidays

Open World Holidays Framework

Downloads: 0 (30 days)

Description

Holidays

A fast, efficient Python library for generating country- and subdivision- (e.g. state or province) specific sets of government-designated holidays on the fly. It aims to make determining whether a specific date is a holiday as fast and flexible as possible.

<!-- markdownlint-disable MD033 --> <table> <tr> <td>PyPI</td> <td> <a href="https://pypi.org/project/holidays"><img src="https://img.shields.io/badge/dynamic/yaml?url=https%3A%2F%2Fraw.githubusercontent.com%2Fvacanza%2Faux%2Frefs%2Fheads%2Fmain%2Fbadges%2Fdownloads%2Fpepy.tech.yaml&query=%24.previous_month_downloads_human&suffix=%2Fmonth&style=flat&label=downloads&color=41B5BE&cacheSeconds=86400" alt="PyPI monthly downloads"></a>&nbsp;<a href="https://pypi.org/project/holidays"><img src="https://img.shields.io/pypi/v/holidays?color=41B5BE&label=version&style=flat" alt="PyPI version"></a>&nbsp;<a href="https://github.com/vacanza/holidays/releases"><img src="https://img.shields.io/github/release-date/vacanza/holidays?color=41B5BE&style=flat" alt="Latest release date"></a> </td> </tr> <tr> <td>CI/CD</td> <td> <a href="https://github.com/vacanza/holidays/actions/workflows/ci-cd.yml?query=branch%3Adev"><img src="https://img.shields.io/github/actions/workflow/status/vacanza/holidays/ci-cd.yml?branch=dev&color=41B5BE&style=flat" alt="CI/CD status"></a>&nbsp;<a href="https://holidays.readthedocs.io/en/latest/?badge=latest"><img src="https://img.shields.io/readthedocs/holidays?color=41B5BE&style=flat" alt="Documentation status"></a>&nbsp;<a href="https://security.snyk.io/package/pip/holidays/"><img alt="Open World Holidays Package Health Score" src="https://img.shields.io/badge/dynamic/regex?url=https%3A%2F%2Fsecurity.snyk.io%2Fpackage%2Fpip%2Fholidays%2F&search=(class%3D%22score-number%22.*%3F%3E)(%5Cd%7B1%2C3%7D%2F%5Cd%7B1%2C3%7D)&replace=%242&style=flat&label=snyk&color=41B5BE"></a> </td> </tr> <tr> <td>Code</td> <td> <a href="https://github.com/vacanza/holidays/blob/dev/LICENSE"><img src="https://img.shields.io/github/license/vacanza/holidays?color=41B5BE&style=flat" alt="License"></a>&nbsp;<a href="https://pypi.org/project/holidays"><img src="https://img.shields.io/pypi/pyversions/holidays?label=python&color=41B5BE&style=flat" alt="Python supported versions"></a>&nbsp;<a href="https://github.com/astral-sh/ruff"><img src="https://img.shields.io/badge/style-ruff-41B5BE?style=flat" alt="Code style"></a>&nbsp;<a href="https://app.codecov.io/gh/vacanza/holidays"><img src="https://img.shields.io/codecov/c/github/vacanza/holidays/dev?color=41B5BE&style=flat" alt="Code coverage"></a> </td> </tr> <tr> <td>GitHub</td> <td> <a href="https://github.com/vacanza/holidays/stargazers"><img src="https://img.shields.io/github/stars/vacanza/holidays?color=41B5BE&style=flat" alt="GitHub stars"></a>&nbsp;<a href="https://github.com/vacanza/holidays/forks"><img src="https://img.shields.io/github/forks/vacanza/holidays?color=41B5BE&style=flat" alt="GitHub forks"></a>&nbsp;<a href="https://github.com/vacanza/holidays/graphs/contributors"><img src="https://img.shields.io/github/contributors/vacanza/holidays?color=41B5BE&style=flat" alt="GitHub contributors"></a>&nbsp;<a href="https://github.com/vacanza/holidays/commits/dev"><img src="https://img.shields.io/github/last-commit/vacanza/holidays/dev?color=41B5BE&style=flat" alt="GitHub last commit"></a> </td> </tr> <tr> <td>Citation</td> <td> <a href="https://doi.org/10.5281/zenodo.14884702"><img src="https://img.shields.io/badge/DOI-10.5281/zenodo.14884702-41B5BE?style=flat" alt="Open World Holidays Framework DOI"></a> </td> </tr> </table>

Install

The latest stable version can always be installed or updated via pip:

pip install --upgrade holidays

The latest development (dev) version can be installed directly from GitHub:

pip install --upgrade https://github.com/vacanza/holidays/tarball/dev

All new features are always first pushed to dev branch, then released on main branch upon official version upgrades.

Documentation

The documentation is hosted on Read the Docs.

Quick Start

from datetime import date
import holidays

us_holidays = holidays.US()  # this is a dict-like object
# the below is the same, but takes a string:
us_holidays = holidays.country_holidays('US')  # this is a dict-like object

nyse_holidays = holidays.NYSE()  # this is a dict-like object
# the below is the same, but takes a string:
nyse_holidays = holidays.financial_holidays('NYSE')  # this is a dict-like object

date(2015, 1, 1) in us_holidays  # True
date(2015, 1, 2) in us_holidays  # False
us_holidays.get('2014-01-01')  # "New Year's Day"

The HolidayBase dict-like class will also recognize date strings and Unix timestamps:

'2014-01-01' in us_holidays  # True
'1/1/2014' in us_holidays    # True
1388597445 in us_holidays    # True

Some holidays may be only present in parts of a country:

us_pr_holidays = holidays.country_holidays('US', subdiv='PR')
'2018-01-06' in us_holidays     # False
'2018-01-06' in us_pr_holidays  # True

Please see the holidays documentation for additional examples and detailed information.

Available Countries

We currently support 249 country codes and are fully compatible with ISO 3166-1. The standard way to refer to a country is by using its ISO 3166-1 alpha-2 code, the same used for domain names, and for a subdivision its ISO 3166-2 code. Some countries have common or foreign names or abbreviations as aliases for their subdivisions. These are defined in the (optional) subdivisions_aliases attribute. Some of the countries support more than one language for holiday names output. A default language is defined by default_language (optional) attribute for each entity and is used as a fallback when neither user specified language nor user locale language available. The default language code is a ISO 639-1 code. A list of all languages supported by country is defined by supported_languages (optional) attribute. If there is no designated ISO 639-1 code then ISO 639-2 code can be used.

Many countries have other categories of holidays in addition to common (national-wide) holidays: bank holidays, school holidays, additional (paid or non-paid) holidays, holidays of state or public employees, religious holidays (valid only for these religions followers). A list of all categories supported by country is defined by supported_categories (optional) attribute.

The following is a list of supported countries, their subdivisions followed by their aliases (if any) in brackets, available languages and additional holiday categories. All countries support PUBLIC holidays category by default. All other default values are highlighted with bold:

<table style="width: 100%"> <colgroup> <col style="width: 20.0%" /> <col style="width: 4.0%" /> <col style="width: 46.0%" /> <col style="width: 20.0%" /> <col style="width: 10.0%" /> </colgroup> <thead> <tr> <th>Country</th> <th>Code</th> <th>Subdivisions</th> <th>Supported Languages</th> <th>Supported Categories</th> </tr> </thead> <tbody> <tr> <td>Afghanistan</td> <td>AF</td> <td></td> <td>en_US, <strong>fa_AF</strong>, ps_AF</td> <td></td> </tr> <tr> <td>Åland Islands</td> <td>AX</td> <td>Can also be loaded as country FI, subdivision 01</td> <td>en_US, <strong>fi</strong>, sv_FI, th, uk</td> <td>UNOFFICIAL, WORKDAY</td> </tr> <tr> <td>Albania</td> <td>AL</td> <td></td> <td>en_US, <strong>sq</strong>, uk</td> <td></td> </tr> <tr> <td>Algeria</td> <td>DZ</td> <td></td> <td><strong>ar</strong>, en_US, fr</td> <td>CHRISTIAN, HEBREW</td> </tr> <tr> <td>American Samoa</td> <td>AS</td> <td>Can also be loaded as country US, subdivision AS</td> <td><strong>en_US</strong>, th</td> <td>UNOFFICIAL</td> </tr> <tr> <td>Andorra</td> <td>AD</td> <td>Parishes: 02 (Canillo), 03 (Encamp), 04 (La Massana), 05 (Ordino), 06 (Sant Julià de Lòria), 07 (Andorra la Vella), 08 (Escaldes-Engordany)</td> <td><strong>ca</strong>, en_US, uk</td> <td>GOVERNMENT</td> </tr> <tr> <td>Angola</td> <td>AO</td> <td></td> <td>en_US, <strong>pt_AO</strong>, uk</td> <td></td> </tr> <tr> <td>Anguilla</td> <td>AI</td> <td></td> <td><strong>en_AI</strong>, en_US</td> <td></td> </tr> <tr> <td>Antarctica</td> <td>AQ</td> <td></td> <td></td> <td></td> </tr> <tr> <td>Antigua and Barbuda</td> <td>AG</td> <td></td> <td></td> <td></td> </tr> <tr> <td>Argentina</td> <td>AR</td> <td>Provinces: A (Salta), B (Buenos Aires), C (Ciudad Autónoma de Buenos Aires), D (San Luis), E (Entre Ríos), F (La Rioja), G (Santiago del Estero), H (Chaco), J (San Juan), K (Catamarca), L (La Pampa), M (Mendoza), N (Misiones), P (Formosa), Q (Neuquén), R (Río Negro), S (Santa Fe), T (Tucumán), U (Chubut), V (Tierra del Fuego), W (Corrientes), X (Córdoba), Y (Jujuy), Z (Santa Cruz)</td> <td>en_US, <strong>es</strong>, uk</td> <td>ARMENIAN, BANK, GOVERNMENT, HEBREW, ISLAMIC</td> </tr> <tr> <td>Armenia</td> <td>AM</td> <td>Regions: AG (Aragac̣otn), AR (Ararat), AV (Armavir), ER (Erevan), GR (Geġark'unik'), KT (Kotayk'), LO (Loṙi), SH (Širak), SU (Syunik'), TV (Tavuš), VD (Vayoć Jor)</td> <td>en_US, <strong>hy</strong></td> <td>WORKDAY</td> </tr> <tr> <td>Aruba</td> <td>AW</td> <td></td> <td>en_US, nl, <strong>pap_AW</strong>, uk</td> <td></td> </tr> <tr> <td>Australia</td> <td>AU</td> <td>States and territories: ACT (Australian Capital Territory), NSW (New South Wales), NT (Northern Territory), QLD (Queensland), SA (South Australia), TAS (Tasmania), VIC (Victoria), WA (Western