Skip to content

Repository files navigation

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.

PyPIPyPI downloadsPyPI versionPyPI release date
CI/CDCI/CD statusDocumentation status
CodeLicensePython supported versionsCode styleCode coverage
GitHubGitHub starsGitHub forksGitHub contributorsGitHub last commit

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/python-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

fromdatetimeimportdateimportholidaysus_holidays=holidays.US() # this is a dict# the below is the same, but takes a string:us_holidays=holidays.country_holidays('US') # this is a dictnyse_holidays=holidays.NYSE() # this is a dict# the below is the same, but takes a string:nyse_holidays=holidays.financial_holidays('NYSE') # this is a dictdate(2015, 1, 1) inus_holidays# Truedate(2015, 1, 2) inus_holidays# Falseus_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'inus_holidays# True'1/1/2014'inus_holidays# True1388597445inus_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'inus_holidays# False'2018-01-06'inus_pr_holidays# True

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

Available Countries

We currently support 146 country codes. 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:

CountryCodeSubdivisionsSupported LanguagesSupported Categories
AlbaniaAL
AlgeriaDZar, en_US, fr
American SamoaASCan also be loaded as country US, subdivision ASUNOFFICIAL
AndorraADParishes: 02, 03, 04, 05, 06, 07, 08
AngolaAOen_US, pt_AO, uk
ArgentinaARen_US, es, uk
ArmeniaAMen_US, hy
ArubaAWen_US, nl, pap, uk
AustraliaAUStates and territories: ACT (Australian Capital Territory), NSW (New South Wales), NT (Northern Territory), QLD (Queensland), SA (South Australia), TAS (Tasmania), VIC (Victoria), WA (Western Australia)BANK, HALF_DAY
AustriaATStates: 1 (Burgenland, Bgld, B), 2 (Kärnten, Ktn, K), 3 (Niederösterreich, NÖ, N), 4 (Oberösterreich, OÖ, O), 5 (Salzburg, Sbg, S), 6 (Steiermark, Stmk, St), 7 (Tirol, T), 8 (Vorarlberg, Vbg, V), 9 (Wien, W)de, en_US, ukBANK
AzerbaijanAZaz, en_US, ukWORKDAY
BahamasBS
BahrainBHar, en_US
BangladeshBD
BarbadosBB
BelarusBYbe, en_US
BelgiumBEde, en_US, fr, nl, ukBANK
BelizeBZ
BoliviaBODepartments: B, C, H, L, N, O, P, S, Ten_US, es, uk
Bosnia and HerzegovinaBAEntities and district: BIH, BRC, SRPbs, en_US, sr, uk
BotswanaBW
BrazilBRStates: AC, AL, AM, AP, BA, CE, DF, ES, GO, MA, MG, MS, MT, PA, PB, PE, PI, PR, RJ, RN, RO, RR, RS, SC, SE, SP, TOOPTIONAL
BruneiBNen_US, ms, th
BulgariaBGbg, en_US, ukSCHOOL
Burkina FasoBF
BurundiBI
CambodiaKHen_US, km, th
CameroonCM
CanadaCAProvinces and territories: AB, BC, MB, NB, NL, NS, NT, NU, ON, PE, QC, SK, YTar, en_CA, en_US, fr, thGOVERNMENT, OPTIONAL
ChadTD
ChileCLRegions: AI, AN, AP, AR, AT, BI, CO, LI, LL, LR, MA, ML, NB, RM, TA, VSen_US, es, uk
ChinaCNen_US, th, zh_CN, zh_TWHALF_DAY
ColombiaCOen_US, es, uk
Costa RicaCRen_US, es, ukOPTIONAL
CroatiaHRen_US, hr, uk
CubaCUen_US, es, uk
CuracaoCWen_US, nl, pap, uk
CyprusCYel, en_CY, en_US, ukBANK, OPTIONAL
CzechiaCZcs, en_US, sk, uk
DenmarkDKda, en_US, ukOPTIONAL
DjiboutiDJar, en_US, fr
Dominican RepublicDOen_US, es, uk
EcuadorECen_US, es, uk
EgyptEGar, en_US
El SalvadorSVDepartments: AH, CA, CH, CU, LI, MO, PA, SA, SM, SO, SS, SV, UN, US
EstoniaEEen_US, et, uk
EswatiniSZ
EthiopiaETam, ar, en_US
FinlandFIen_US, fi, sv, uk
FranceFRDépartements: BL, GES, GP, GY, MF, MQ, NC, PF, RE, WF, YTen_US, fr, uk
GabonGA
GeorgiaGEen_US, ka, uk
GermanyDEStates: BB, BE, BW, BY, BYP, HB, HE, HH, MV, NI, NW, RP, SH, SL, SN, ST, THde, en_US, uk
GhanaGH
GreeceGRel, en_US, ukHALF_DAY
GuamGUCan also be loaded as country US, subdivision GUUNOFFICIAL
GuatemalaGTen_US, es
HondurasHNen_US, es, uk
Hong KongHK
HungaryHUen_US, hu, uk
IcelandISen_US, is, uk
IndiaINStates: AN, AP, AR, AS, BR, CG, CH, DD, DH, DL, GA, GJ, HP, HR, JH, JK, KA, KL, LA, LD, MH, ML, MN, MP, MZ, NL, OR, PB, PY, RJ, SK, TN, TR, TS, UK, UP, WB
IndonesiaIDen_US, id, ukGOVERNMENT
IranIRen_US, fa
IrelandIE
Isle of ManIM
IsraelILen_US, he, ukOPTIONAL, SCHOOL
ItalyITProvinces: AG, AL, AN, AO, AP, AQ, AR, AT, AV, BA, BG, BI, BL, BN, BO, BR, BS, BT, BZ, CA, CB, CE, CH, CL, CN, CO, CR, CS, CT, CZ, EN, FC, FE, FG, FI, FM, FR, GE, GO, GR, IM, IS, KR, LC, LE, LI, LO, LT, LU, MB, MC, ME, MI, MN, MO, MS, MT, NA, NO, NU, OR, PA, PC, PD, PE, PG, PI, PN, PO, PR, PT, PU, PV, PZ, RA, RC, RE, RG, RI, RM, RN, RO, SA, SI, SO, SP, SR, SS, SU, SV, TA, TE, TN, TO, TP, TR, TS, TV, UD, VA, VB, VC, VE, VI, VR, VT, VV. Cities: Andria, Barletta, Cesena, Forli, Pesaro, Trani, Urbino
JamaicaJM
JapanJPen_US, ja, thBANK
JerseyJE
JordanJOar, en_US
KazakhstanKZ
KenyaKE
KuwaitKWar, en_US
KyrgyzstanKG
LaosLAen_US, lo, thBANK, SCHOOL, WORKDAY
LatviaLVen_US, lv, uk
LesothoLS
LiechtensteinLIde, en_US, ukBANK
LithuaniaLTen_US, lt, uk
LuxembourgLUde, en_US, fr, lb, uk
MadagascarMGen_US, mg, uk
MalawiMW
MalaysiaMYStates: JHR, KDH, KTN, KUL, LBN, MLK, NSN, PHG, PJY, PLS, PNG, PRK, SBH, SGR, SWK, TRG
MaldivesMV
MaltaMTen_US, mt
Marshall Islands (the)MH
MexicoMXen_US, es, uk
MoldovaMDen_US, ro, uk
MonacoMCen_US, fr, uk
MontenegroME
MoroccoMAar, en_US, fr
MozambiqueMZen_US, pt_MZ, uk
NamibiaNA
NetherlandsNLen_US, nl, ukOPTIONAL
New ZealandNZRegions: AUK, BOP, CAN, CIT, GIS, HKB, MBH, MWT, NSN, NTL, OTA, STL, TAS, TKI, WGN, WKO, WTC
NicaraguaNIDepartments: AN, AS, BO, CA, CI, CO, ES, GR, JI, LE, MD, MN, MS, MT, NS, RI, SJen_US, es, uk
NigeriaNG
Northern Mariana Islands (the)MPCan also be loaded as country US, subdivision MPUNOFFICIAL
North MacedoniaMK
NorwayNOen_US, no, uk
PakistanPK
PanamaPA
Papua New GuineaPG
ParaguayPYen_US, es, ukGOVERNMENT
PeruPEen_US, es, uk
PhilippinesPH
PolandPLen_US, pl, uk
PortugalPTDistricts: 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 30en_US, pt_PT, ukOPTIONAL
Puerto RicoPRCan also be loaded as country US, subdivision PRUNOFFICIAL
RomaniaROen_US, ro, uk
RussiaRUen_US, ru
San MarinoSM
Saudi ArabiaSAar, en_US
SerbiaRSen_US, sr
SeychellesSCen_SC, en_US
SingaporeSG
SlovakiaSKen_US, sk, ukWORKDAY
SloveniaSIen_US, sl, uk
South AfricaZA
South KoreaKRen_US, ko, thBANK
SpainESAutonomous communities: AN, AR, AS, CB, CE, CL, CM, CN, CT, EX, GA, IB, MC, MD, ML, NC, PV, RI, VCen_US, es, uk
SwedenSEen_US, sv, uk
SwitzerlandCHCantons: AG, AI, AR, BL, BS, BE, FR, GE, GL, GR, JU, LU, NE, NW, OW, SG, SH, SZ, SO, TG, TI, UR, VD, VS, ZG, ZHde, en_US, fr, it, ukHALF_DAY, OPTIONAL
TaiwanTWen_US, th, zh_CN, zh_TW
TanzaniaTZen_US, swBANK
ThailandTHen_US, thARMED_FORCES, BANK, GOVERNMENT, SCHOOL, WORKDAY
Timor LesteTLen_US, pt_TL, tetGOVERNMENT, WORKDAY
TongaTOen_US, to
TunisiaTNar, en_US
TurkeyTRen_US, tr, ukHALF_DAY
UkraineUAar, en_US, uk
United Arab EmiratesAEar, en_US
United KingdomGBSubdivisions: ENG, NIR, SCT, WLS
United States Minor Outlying IslandsUMCan also be loaded as country US, subdivision UMUNOFFICIAL
United States of America (the)USStates and territories: AK, AL, AR, AS, AZ, CA, CO, CT, DC, DE, FL, GA, GU, HI, IA, ID, IL, IN, KS, KY, LA, MA, MD, ME, MI, MN, MO, MP, MS, MT, NC, ND, NE, NH, NJ, NM, NV, NY, OH, OK, OR, PA, PR, RI, SC, SD, TN, TX, UM, UT, VA, VI, VT, WA, WI, WV, WYUNOFFICIAL
United States Virgin Islands (the)See Virgin Islands (U.S.)UNOFFICIAL
UruguayUYen_US, es, ukBANK
UzbekistanUZen_US, uk, uz
VanuatuVU
Vatican CityVA
VenezuelaVEen_US, es, uk
VietnamVN
Virgin Islands (U.S.)VICan also be loaded as country US, subdivision VIUNOFFICIAL
ZambiaZM
ZimbabweZW

Available Financial Markets

The standard way to refer to a financial market is to use its ISO 10383 MIC (Market Identifier Code) as a "country" code when available. The following financial markets are available:

EntityCodeInfo
European Central BankECBTrans-European Automated Real-time Gross Settlement (TARGET2)
New York Stock ExchangeXNYSNYSE market holidays (used by all other US-exchanges, including NASDAQ, etc.)

Contributions

Issues and pull requests are always welcome. Please see here for more information.

License

Code and documentation are available according to the MIT License (see LICENSE).

About

Generate and work with holidays in Python

Resources

Contributing

Stars

15 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages