holidays 0.69__py3-none-any.whl → 0.71__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- holidays/__init__.py +1 -1
- holidays/calendars/__init__.py +1 -1
- holidays/calendars/balinese_saka.py +3 -3
- holidays/calendars/buddhist.py +1 -1
- holidays/calendars/chinese.py +1 -1
- holidays/calendars/custom.py +1 -1
- holidays/calendars/gregorian.py +1 -1
- holidays/calendars/hebrew.py +1 -1
- holidays/calendars/hindu.py +1 -1
- holidays/calendars/islamic.py +161 -1
- holidays/calendars/julian.py +1 -1
- holidays/calendars/julian_revised.py +1 -1
- holidays/calendars/persian.py +1 -1
- holidays/calendars/sinhala.py +1 -1
- holidays/calendars/thai.py +309 -257
- holidays/constants.py +2 -1
- holidays/countries/__init__.py +10 -1
- holidays/countries/afghanistan.py +11 -7
- holidays/countries/albania.py +10 -7
- holidays/countries/algeria.py +10 -10
- holidays/countries/american_samoa.py +6 -4
- holidays/countries/andorra.py +5 -4
- holidays/countries/angola.py +15 -14
- holidays/countries/antigua_and_barbuda.py +145 -0
- holidays/countries/argentina.py +787 -169
- holidays/countries/armenia.py +5 -6
- holidays/countries/aruba.py +11 -9
- holidays/countries/australia.py +21 -20
- holidays/countries/austria.py +3 -1
- holidays/countries/azerbaijan.py +24 -19
- holidays/countries/bahamas.py +13 -11
- holidays/countries/bahrain.py +8 -7
- holidays/countries/bangladesh.py +5 -4
- holidays/countries/barbados.py +11 -9
- holidays/countries/belarus.py +15 -15
- holidays/countries/belgium.py +8 -6
- holidays/countries/belize.py +7 -6
- holidays/countries/bolivia.py +12 -11
- holidays/countries/bosnia_and_herzegovina.py +15 -11
- holidays/countries/botswana.py +8 -6
- holidays/countries/brazil.py +8 -7
- holidays/countries/brunei.py +50 -62
- holidays/countries/bulgaria.py +9 -10
- holidays/countries/burkina_faso.py +8 -5
- holidays/countries/burundi.py +13 -12
- holidays/countries/cambodia.py +15 -24
- holidays/countries/cameroon.py +10 -7
- holidays/countries/canada.py +13 -12
- holidays/countries/chad.py +9 -6
- holidays/countries/chile.py +29 -28
- holidays/countries/china.py +39 -38
- holidays/countries/colombia.py +15 -20
- holidays/countries/congo.py +6 -7
- holidays/countries/costa_rica.py +11 -10
- holidays/countries/croatia.py +8 -5
- holidays/countries/cuba.py +30 -27
- holidays/countries/curacao.py +6 -4
- holidays/countries/cyprus.py +4 -5
- holidays/countries/czechia.py +7 -6
- holidays/countries/denmark.py +5 -6
- holidays/countries/djibouti.py +7 -3
- holidays/countries/dominica.py +18 -16
- holidays/countries/dominican_republic.py +6 -4
- holidays/countries/ecuador.py +5 -4
- holidays/countries/egypt.py +6 -11
- holidays/countries/el_salvador.py +6 -5
- holidays/countries/estonia.py +3 -1
- holidays/countries/eswatini.py +6 -4
- holidays/countries/ethiopia.py +20 -11
- holidays/countries/fiji.py +183 -0
- holidays/countries/finland.py +11 -10
- holidays/countries/france.py +7 -10
- holidays/countries/french_southern_territories.py +53 -0
- holidays/countries/gabon.py +11 -8
- holidays/countries/georgia.py +7 -7
- holidays/countries/germany.py +11 -11
- holidays/countries/ghana.py +10 -6
- holidays/countries/greece.py +4 -5
- holidays/countries/greenland.py +5 -6
- holidays/countries/guam.py +6 -4
- holidays/countries/guatemala.py +7 -9
- holidays/countries/guernsey.py +37 -34
- holidays/countries/guinea.py +182 -0
- holidays/countries/haiti.py +6 -5
- holidays/countries/honduras.py +8 -4
- holidays/countries/hongkong.py +11 -8
- holidays/countries/hungary.py +26 -23
- holidays/countries/iceland.py +5 -4
- holidays/countries/india.py +14 -10
- holidays/countries/indonesia.py +57 -53
- holidays/countries/iran.py +12 -9
- holidays/countries/ireland.py +5 -4
- holidays/countries/isle_of_man.py +2 -2
- holidays/countries/israel.py +4 -5
- holidays/countries/italy.py +5 -4
- holidays/countries/ivory_coast.py +156 -0
- holidays/countries/jamaica.py +6 -4
- holidays/countries/japan.py +5 -5
- holidays/countries/jersey.py +29 -26
- holidays/countries/jordan.py +9 -6
- holidays/countries/kazakhstan.py +66 -51
- holidays/countries/kenya.py +22 -18
- holidays/countries/kuwait.py +10 -7
- holidays/countries/kyrgyzstan.py +7 -6
- holidays/countries/laos.py +21 -29
- holidays/countries/latvia.py +7 -5
- holidays/countries/lesotho.py +6 -5
- holidays/countries/liechtenstein.py +5 -5
- holidays/countries/lithuania.py +4 -5
- holidays/countries/luxembourg.py +5 -3
- holidays/countries/macau.py +32 -26
- holidays/countries/madagascar.py +5 -4
- holidays/countries/malawi.py +6 -4
- holidays/countries/malaysia.py +29 -19
- holidays/countries/maldives.py +10 -7
- holidays/countries/malta.py +10 -19
- holidays/countries/marshall_islands.py +6 -4
- holidays/countries/mauritania.py +9 -6
- holidays/countries/mexico.py +8 -7
- holidays/countries/moldova.py +6 -4
- holidays/countries/monaco.py +6 -4
- holidays/countries/montenegro.py +10 -7
- holidays/countries/morocco.py +9 -8
- holidays/countries/mozambique.py +3 -1
- holidays/countries/namibia.py +7 -5
- holidays/countries/netherlands.py +6 -6
- holidays/countries/new_zealand.py +3 -1
- holidays/countries/nicaragua.py +6 -5
- holidays/countries/nigeria.py +9 -5
- holidays/countries/north_macedonia.py +9 -5
- holidays/countries/northern_mariana_islands.py +6 -4
- holidays/countries/norway.py +15 -15
- holidays/countries/oman.py +185 -0
- holidays/countries/pakistan.py +48 -17
- holidays/countries/palau.py +13 -11
- holidays/countries/panama.py +9 -8
- holidays/countries/papua_new_guinea.py +25 -21
- holidays/countries/paraguay.py +10 -9
- holidays/countries/peru.py +4 -5
- holidays/countries/philippines.py +25 -21
- holidays/countries/poland.py +6 -5
- holidays/countries/portugal.py +13 -15
- holidays/countries/puerto_rico.py +6 -4
- holidays/countries/qatar.py +172 -0
- holidays/countries/romania.py +6 -4
- holidays/countries/russia.py +6 -4
- holidays/countries/saint_kitts_and_nevis.py +24 -22
- holidays/countries/saint_lucia.py +8 -7
- holidays/countries/samoa.py +7 -6
- holidays/countries/san_marino.py +4 -3
- holidays/countries/saudi_arabia.py +11 -15
- holidays/countries/serbia.py +3 -4
- holidays/countries/seychelles.py +22 -26
- holidays/countries/sierra_leone.py +149 -0
- holidays/countries/singapore.py +29 -39
- holidays/countries/slovakia.py +6 -5
- holidays/countries/slovenia.py +7 -6
- holidays/countries/south_africa.py +8 -6
- holidays/countries/south_korea.py +39 -47
- holidays/countries/spain.py +25 -24
- holidays/countries/sri_lanka.py +46 -42
- holidays/countries/suriname.py +227 -0
- holidays/countries/sweden.py +20 -19
- holidays/countries/switzerland.py +6 -5
- holidays/countries/taiwan.py +52 -49
- holidays/countries/tanzania.py +28 -27
- holidays/countries/thailand.py +134 -142
- holidays/countries/timor_leste.py +20 -18
- holidays/countries/tonga.py +46 -42
- holidays/countries/tunisia.py +5 -3
- holidays/countries/turkey.py +11 -9
- holidays/countries/tuvalu.py +12 -11
- holidays/countries/ukraine.py +54 -54
- holidays/countries/united_arab_emirates.py +37 -30
- holidays/countries/united_kingdom.py +7 -6
- holidays/countries/united_states.py +50 -55
- holidays/countries/united_states_minor_outlying_islands.py +6 -4
- holidays/countries/united_states_virgin_islands.py +6 -4
- holidays/countries/uruguay.py +10 -9
- holidays/countries/uzbekistan.py +10 -7
- holidays/countries/vanuatu.py +7 -5
- holidays/countries/vatican_city.py +16 -15
- holidays/countries/venezuela.py +11 -14
- holidays/countries/vietnam.py +15 -11
- holidays/countries/zambia.py +8 -6
- holidays/countries/zimbabwe.py +6 -4
- holidays/deprecations/v1_incompatibility.py +1 -1
- holidays/financial/__init__.py +1 -1
- holidays/financial/brasil_bolsa_balcao.py +14 -13
- holidays/financial/european_central_bank.py +7 -6
- holidays/financial/ice_futures_europe.py +7 -6
- holidays/financial/ny_stock_exchange.py +13 -10
- holidays/groups/__init__.py +1 -1
- holidays/groups/balinese_saka.py +1 -1
- holidays/groups/buddhist.py +1 -1
- holidays/groups/chinese.py +1 -1
- holidays/groups/christian.py +1 -1
- holidays/groups/custom.py +1 -1
- holidays/groups/eastern.py +1 -1
- holidays/groups/hebrew.py +1 -1
- holidays/groups/hindu.py +1 -1
- holidays/groups/international.py +1 -1
- holidays/groups/islamic.py +22 -1
- holidays/groups/persian.py +1 -1
- holidays/groups/sinhala.py +1 -1
- holidays/groups/thai.py +1 -7
- holidays/helpers.py +1 -1
- holidays/holiday_base.py +393 -245
- holidays/ical.py +228 -0
- holidays/locale/ar/LC_MESSAGES/OM.mo +0 -0
- holidays/locale/ar_QA/LC_MESSAGES/QA.mo +0 -0
- holidays/locale/en_CI/LC_MESSAGES/CI.mo +0 -0
- holidays/locale/en_PK/LC_MESSAGES/PK.mo +0 -0
- holidays/locale/en_SL/LC_MESSAGES/SL.mo +0 -0
- holidays/locale/en_TL/LC_MESSAGES/TL.mo +0 -0
- holidays/locale/en_US/LC_MESSAGES/AR.mo +0 -0
- holidays/locale/en_US/LC_MESSAGES/CI.mo +0 -0
- holidays/locale/en_US/LC_MESSAGES/GN.mo +0 -0
- holidays/locale/en_US/LC_MESSAGES/OM.mo +0 -0
- holidays/locale/en_US/LC_MESSAGES/PK.mo +0 -0
- holidays/locale/en_US/LC_MESSAGES/QA.mo +0 -0
- holidays/locale/en_US/LC_MESSAGES/SL.mo +0 -0
- holidays/locale/en_US/LC_MESSAGES/SR.mo +0 -0
- holidays/locale/en_US/LC_MESSAGES/TF.mo +0 -0
- holidays/locale/en_US/LC_MESSAGES/TL.mo +0 -0
- holidays/locale/es/LC_MESSAGES/AR.mo +0 -0
- holidays/locale/fr/LC_MESSAGES/CI.mo +0 -0
- holidays/locale/fr/LC_MESSAGES/GN.mo +0 -0
- holidays/locale/fr/LC_MESSAGES/TF.mo +0 -0
- holidays/locale/hi/LC_MESSAGES/IN.mo +0 -0
- holidays/locale/nl/LC_MESSAGES/SR.mo +0 -0
- holidays/locale/pt_TL/LC_MESSAGES/TL.mo +0 -0
- holidays/locale/tet/LC_MESSAGES/TL.mo +0 -0
- holidays/locale/th/LC_MESSAGES/TL.mo +0 -0
- holidays/locale/uk/LC_MESSAGES/AR.mo +0 -0
- holidays/locale/uk/LC_MESSAGES/TF.mo +0 -0
- holidays/locale/ur_PK/LC_MESSAGES/PK.mo +0 -0
- holidays/mixins.py +2 -2
- holidays/observed_holiday_base.py +10 -3
- holidays/registry.py +10 -1
- holidays/utils.py +203 -151
- holidays/version.py +2 -2
- holidays-0.71.dist-info/METADATA +1432 -0
- {holidays-0.69.dist-info → holidays-0.71.dist-info}/RECORD +248 -217
- {holidays-0.69.dist-info → holidays-0.71.dist-info}/WHEEL +1 -1
- holidays-0.69.dist-info/AUTHORS → holidays-0.71.dist-info/licenses/AUTHORS.md +9 -2
- {holidays-0.69.dist-info → holidays-0.71.dist-info/licenses}/LICENSE +1 -1
- holidays-0.69.dist-info/METADATA +0 -1085
- {holidays-0.69.dist-info → holidays-0.71.dist-info}/top_level.txt +0 -0
holidays/utils.py
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# specific sets of holidays on the fly. It aims to make determining whether a
|
|
5
5
|
# specific date is a holiday as fast and flexible as possible.
|
|
6
6
|
#
|
|
7
|
-
# Authors: Vacanza Team and individual contributors (see AUTHORS file)
|
|
7
|
+
# Authors: Vacanza Team and individual contributors (see AUTHORS.md file)
|
|
8
8
|
# dr-prodigy <dr.prodigy.github@gmail.com> (c) 2017-2023
|
|
9
9
|
# ryanss <ryanssdev@icloud.com> (c) 2014-2017
|
|
10
10
|
# Website: https://github.com/vacanza/holidays
|
|
@@ -41,47 +41,74 @@ def country_holidays(
|
|
|
41
41
|
categories: Optional[CategoryArg] = None,
|
|
42
42
|
) -> HolidayBase:
|
|
43
43
|
"""
|
|
44
|
-
Returns a new dictionary-like
|
|
44
|
+
Returns a new dictionary-like `HolidayBase` object for the public
|
|
45
45
|
holidays of the country matching **country** and other keyword arguments.
|
|
46
46
|
|
|
47
|
-
:
|
|
48
|
-
|
|
47
|
+
Args:
|
|
48
|
+
country:
|
|
49
|
+
An ISO 3166-1 Alpha-2 country code.
|
|
50
|
+
|
|
51
|
+
subdiv:
|
|
52
|
+
The subdivision (e.g. state or province) as a ISO 3166-2 code
|
|
53
|
+
or its alias; not implemented for all countries (see documentation).
|
|
54
|
+
|
|
55
|
+
years:
|
|
56
|
+
The year(s) to pre-calculate public holidays for at instantiation.
|
|
57
|
+
|
|
58
|
+
expand:
|
|
59
|
+
Whether the entire year is calculated when one date from that year
|
|
60
|
+
is requested.
|
|
61
|
+
|
|
62
|
+
observed:
|
|
63
|
+
Whether to include the dates of when public holiday are observed
|
|
64
|
+
(e.g. a holiday falling on a Sunday being observed the following
|
|
65
|
+
Monday). False may not work for all countries.
|
|
66
|
+
|
|
67
|
+
prov:
|
|
68
|
+
*deprecated* use `subdiv` instead.
|
|
69
|
+
|
|
70
|
+
state:
|
|
71
|
+
*deprecated* use `subdiv` instead.
|
|
49
72
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
or its alias; not implemented for all countries (see documentation).
|
|
73
|
+
language:
|
|
74
|
+
Specifies the language in which holiday names are returned.
|
|
53
75
|
|
|
54
|
-
|
|
55
|
-
The year(s) to pre-calculate public holidays for at instantiation.
|
|
76
|
+
Accepts either:
|
|
56
77
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
78
|
+
* A two-letter ISO 639-1 language code (e.g., 'en' for English, 'fr' for French),
|
|
79
|
+
or
|
|
80
|
+
* A language and entity combination using an underscore (e.g., 'en_US' for U.S.
|
|
81
|
+
English, 'pt_BR' for Brazilian Portuguese).
|
|
60
82
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
83
|
+
!!! warning
|
|
84
|
+
The provided language or locale code must be supported by the holiday
|
|
85
|
+
entity. Unsupported values will result in names being shown in the entity's
|
|
86
|
+
original language.
|
|
65
87
|
|
|
66
|
-
|
|
67
|
-
|
|
88
|
+
If not explicitly set (`language=None`), the system attempts to infer the
|
|
89
|
+
language from the environment's locale settings. The following environment
|
|
90
|
+
variables are checked, in order of precedence: LANGUAGE, LC_ALL, LC_MESSAGES, LANG.
|
|
68
91
|
|
|
69
|
-
|
|
70
|
-
|
|
92
|
+
If none of these are set or they are empty, holiday names will default to the
|
|
93
|
+
original language of the entity's holiday implementation.
|
|
71
94
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
language translation is not supported the original holiday names
|
|
76
|
-
will be used.
|
|
95
|
+
!!! warning
|
|
96
|
+
This fallback mechanism may yield inconsistent results across environments
|
|
97
|
+
(e.g., between a terminal session and a Jupyter notebook).
|
|
77
98
|
|
|
78
|
-
|
|
79
|
-
|
|
99
|
+
To ensure consistent behavior, it is recommended to set the language parameter
|
|
100
|
+
explicitly. If the specified language is not supported, holiday names will remain
|
|
101
|
+
in the original language of the entity's holiday implementation.
|
|
80
102
|
|
|
81
|
-
|
|
82
|
-
A :py:class:`HolidayBase` object matching the **country**.
|
|
103
|
+
This behavior will be updated and formalized in v1.
|
|
83
104
|
|
|
84
|
-
|
|
105
|
+
categories:
|
|
106
|
+
Requested holiday categories.
|
|
107
|
+
|
|
108
|
+
Returns:
|
|
109
|
+
A `HolidayBase` object matching the **country**.
|
|
110
|
+
|
|
111
|
+
The key of the `dict`-like `HolidayBase` object is the
|
|
85
112
|
`date` of the holiday, and the value is the name of the holiday itself.
|
|
86
113
|
Dates where a key is not present are not public holidays (or, if
|
|
87
114
|
**observed** is False, days when a public holiday is observed).
|
|
@@ -89,12 +116,12 @@ def country_holidays(
|
|
|
89
116
|
When passing the `date` as a key, the `date` can be expressed in one of the
|
|
90
117
|
following types:
|
|
91
118
|
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
* a
|
|
95
|
-
* or a
|
|
119
|
+
* `datetime.date`,
|
|
120
|
+
* `datetime.datetime`,
|
|
121
|
+
* a `str` of any format recognized by `dateutil.parser.parse()`,
|
|
122
|
+
* or a `float` or `int` representing a POSIX timestamp.
|
|
96
123
|
|
|
97
|
-
The key is always returned as a
|
|
124
|
+
The key is always returned as a `datetime.date` object.
|
|
98
125
|
|
|
99
126
|
To maximize speed, the list of public holidays is built on the fly as
|
|
100
127
|
needed, one calendar year at a time. When the object is instantiated
|
|
@@ -107,70 +134,70 @@ def country_holidays(
|
|
|
107
134
|
|
|
108
135
|
Example usage:
|
|
109
136
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
137
|
+
>>> from holidays import country_holidays
|
|
138
|
+
>>> us_holidays = country_holidays('US')
|
|
139
|
+
# For a specific subdivision (e.g. state or province):
|
|
140
|
+
>>> calif_holidays = country_holidays('US', subdiv='CA')
|
|
114
141
|
|
|
115
142
|
The below will cause 2015 holidays to be calculated on the fly:
|
|
116
143
|
|
|
117
|
-
|
|
118
|
-
|
|
144
|
+
>>> from datetime import date
|
|
145
|
+
>>> assert date(2015, 1, 1) in us_holidays
|
|
119
146
|
|
|
120
147
|
This will be faster because 2015 holidays are already calculated:
|
|
121
148
|
|
|
122
|
-
|
|
149
|
+
>>> assert date(2015, 1, 2) not in us_holidays
|
|
123
150
|
|
|
124
|
-
The
|
|
151
|
+
The `HolidayBase` class also recognizes strings of many formats
|
|
125
152
|
and numbers representing a POSIX timestamp:
|
|
126
153
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
154
|
+
>>> assert '2014-01-01' in us_holidays
|
|
155
|
+
>>> assert '1/1/2014' in us_holidays
|
|
156
|
+
>>> assert 1388597445 in us_holidays
|
|
130
157
|
|
|
131
158
|
Show the holiday's name:
|
|
132
159
|
|
|
133
|
-
|
|
134
|
-
|
|
160
|
+
>>> us_holidays.get('2014-01-01')
|
|
161
|
+
"New Year's Day"
|
|
135
162
|
|
|
136
163
|
Check a range:
|
|
137
164
|
|
|
138
|
-
|
|
139
|
-
|
|
165
|
+
>>> us_holidays['2014-01-01': '2014-01-03']
|
|
166
|
+
[datetime.date(2014, 1, 1)]
|
|
140
167
|
|
|
141
168
|
List all 2020 holidays:
|
|
142
169
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
170
|
+
>>> us_holidays = country_holidays('US', years=2020)
|
|
171
|
+
>>> for day in sorted(us_holidays.items()):
|
|
172
|
+
... print(day)
|
|
173
|
+
(datetime.date(2020, 1, 1), "New Year's Day")
|
|
174
|
+
(datetime.date(2020, 1, 20), 'Martin Luther King Jr. Day')
|
|
175
|
+
(datetime.date(2020, 2, 17), "Washington's Birthday")
|
|
176
|
+
(datetime.date(2020, 5, 25), 'Memorial Day')
|
|
177
|
+
(datetime.date(2020, 7, 3), 'Independence Day (observed)')
|
|
178
|
+
(datetime.date(2020, 7, 4), 'Independence Day')
|
|
179
|
+
(datetime.date(2020, 9, 7), 'Labor Day')
|
|
180
|
+
(datetime.date(2020, 10, 12), 'Columbus Day')
|
|
181
|
+
(datetime.date(2020, 11, 11), 'Veterans Day')
|
|
182
|
+
(datetime.date(2020, 11, 26), 'Thanksgiving Day')
|
|
183
|
+
(datetime.date(2020, 12, 25), 'Christmas Day')
|
|
157
184
|
|
|
158
185
|
Some holidays are only present in parts of a country:
|
|
159
186
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
187
|
+
>>> us_pr_holidays = country_holidays('US', subdiv='PR')
|
|
188
|
+
>>> assert '2018-01-06' not in us_holidays
|
|
189
|
+
>>> assert '2018-01-06' in us_pr_holidays
|
|
163
190
|
|
|
164
191
|
Append custom holiday dates by passing one of:
|
|
165
192
|
|
|
166
|
-
* a
|
|
167
|
-
|
|
168
|
-
* a list of dates (as a
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
* or a single date item (of one of the types above); ``'Holiday'`` will be
|
|
193
|
+
* a `dict` with date/name key/value pairs (e.g.
|
|
194
|
+
`{'2010-07-10': 'My birthday!'}`),
|
|
195
|
+
* a list of dates (as a `datetime.date`, `datetime.datetime`,
|
|
196
|
+
`str`, `int`, or `float`); "Holiday" will be used as a description,
|
|
197
|
+
* or a single date item (of one of the types above); "Holiday" will be
|
|
172
198
|
used as a description:
|
|
173
199
|
|
|
200
|
+
```python
|
|
174
201
|
>>> custom_holidays = country_holidays('US', years=2015)
|
|
175
202
|
>>> custom_holidays.update({'2015-01-01': "New Year's Day"})
|
|
176
203
|
>>> custom_holidays.update(['2015-07-01', '07/04/2015'])
|
|
@@ -178,9 +205,10 @@ def country_holidays(
|
|
|
178
205
|
>>> assert date(2015, 1, 1) in custom_holidays
|
|
179
206
|
>>> assert date(2015, 1, 2) not in custom_holidays
|
|
180
207
|
>>> assert '12/25/2015' in custom_holidays
|
|
208
|
+
```
|
|
181
209
|
|
|
182
210
|
For more complex logic, like 4th Monday of January, you can inherit the
|
|
183
|
-
|
|
211
|
+
`HolidayBase` class and define your own `_populate` method.
|
|
184
212
|
See documentation for examples.
|
|
185
213
|
"""
|
|
186
214
|
import holidays
|
|
@@ -213,40 +241,67 @@ def financial_holidays(
|
|
|
213
241
|
holidays of the financial market matching **market** and other keyword
|
|
214
242
|
arguments.
|
|
215
243
|
|
|
216
|
-
:
|
|
217
|
-
|
|
244
|
+
Args:
|
|
245
|
+
market:
|
|
246
|
+
An ISO 3166-1 Alpha-2 market code.
|
|
247
|
+
|
|
248
|
+
subdiv:
|
|
249
|
+
Currently not implemented for markets (see documentation).
|
|
250
|
+
|
|
251
|
+
years:
|
|
252
|
+
The year(s) to pre-calculate public holidays for at instantiation.
|
|
253
|
+
|
|
254
|
+
expand:
|
|
255
|
+
Whether the entire year is calculated when one date from that year
|
|
256
|
+
is requested.
|
|
257
|
+
|
|
258
|
+
observed:
|
|
259
|
+
Whether to include the dates of when public holiday are observed
|
|
260
|
+
(e.g. a holiday falling on a Sunday being observed the following
|
|
261
|
+
Monday). False may not work for all countries.
|
|
218
262
|
|
|
219
|
-
|
|
220
|
-
|
|
263
|
+
language:
|
|
264
|
+
Specifies the language in which holiday names are returned.
|
|
221
265
|
|
|
222
|
-
|
|
223
|
-
The year(s) to pre-calculate public holidays for at instantiation.
|
|
266
|
+
Accepts either:
|
|
224
267
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
268
|
+
* A two-letter ISO 639-1 language code (e.g., 'en' for English, 'fr' for French),
|
|
269
|
+
or
|
|
270
|
+
* A language and entity combination using an underscore (e.g., 'en_US' for U.S.
|
|
271
|
+
English, 'pt_BR' for Brazilian Portuguese).
|
|
228
272
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
273
|
+
!!! warning
|
|
274
|
+
The provided language or locale code must be supported by the holiday
|
|
275
|
+
entity. Unsupported values will result in names being shown in the entity's
|
|
276
|
+
original language.
|
|
233
277
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
language translation is not supported the original holiday names
|
|
238
|
-
will be used.
|
|
278
|
+
If not explicitly set (`language=None`), the system attempts to infer the
|
|
279
|
+
language from the environment's locale settings. The following environment
|
|
280
|
+
variables are checked, in order of precedence: LANGUAGE, LC_ALL, LC_MESSAGES, LANG.
|
|
239
281
|
|
|
240
|
-
|
|
241
|
-
|
|
282
|
+
If none of these are set or they are empty, holiday names will default to the
|
|
283
|
+
original language of the entity's holiday implementation.
|
|
284
|
+
|
|
285
|
+
!!! warning
|
|
286
|
+
This fallback mechanism may yield inconsistent results across environments
|
|
287
|
+
(e.g., between a terminal session and a Jupyter notebook).
|
|
288
|
+
|
|
289
|
+
To ensure consistent behavior, it is recommended to set the language parameter
|
|
290
|
+
explicitly. If the specified language is not supported, holiday names will remain
|
|
291
|
+
in the original language of the entity's holiday implementation.
|
|
292
|
+
|
|
293
|
+
This behavior will be updated and formalized in v1.
|
|
294
|
+
|
|
295
|
+
Returns:
|
|
296
|
+
A `HolidayBase` object matching the **market**.
|
|
242
297
|
|
|
243
298
|
Example usage:
|
|
244
299
|
|
|
245
|
-
|
|
246
|
-
|
|
300
|
+
>>> from holidays import financial_holidays
|
|
301
|
+
>>> nyse_holidays = financial_holidays('XNYS')
|
|
247
302
|
|
|
248
|
-
See
|
|
249
|
-
examples.
|
|
303
|
+
See [country_holidays()][holidays.utils.country_holidays] documentation for further
|
|
304
|
+
details and examples.
|
|
250
305
|
"""
|
|
251
306
|
import holidays
|
|
252
307
|
|
|
@@ -268,9 +323,8 @@ def CountryHoliday( # noqa: N802
|
|
|
268
323
|
state: Optional[str] = None,
|
|
269
324
|
) -> HolidayBase:
|
|
270
325
|
"""
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
:meta private:
|
|
326
|
+
Note:
|
|
327
|
+
Deprecated name for `country_holidays()`.
|
|
274
328
|
"""
|
|
275
329
|
|
|
276
330
|
warnings.warn(
|
|
@@ -280,16 +334,16 @@ def CountryHoliday( # noqa: N802
|
|
|
280
334
|
|
|
281
335
|
|
|
282
336
|
def _list_localized_entities(entity_codes: Iterable[str]) -> dict[str, list[str]]:
|
|
283
|
-
"""
|
|
284
|
-
Get all localized entities and languages they support.
|
|
337
|
+
"""Get all localized entities and languages they support.
|
|
285
338
|
|
|
286
|
-
:
|
|
287
|
-
|
|
339
|
+
Args:
|
|
340
|
+
entity_codes:
|
|
341
|
+
A list of entity codes.
|
|
288
342
|
|
|
289
|
-
:
|
|
290
|
-
A dictionary where key is an entity code and
|
|
291
|
-
|
|
292
|
-
|
|
343
|
+
Returns:
|
|
344
|
+
A dictionary where key is an entity code and value is a list of supported
|
|
345
|
+
languages (either ISO 639-1 or a combination of ISO 639-1 and ISO 3166-1 codes joined
|
|
346
|
+
with "_").
|
|
293
347
|
"""
|
|
294
348
|
import holidays
|
|
295
349
|
|
|
@@ -304,48 +358,46 @@ def _list_localized_entities(entity_codes: Iterable[str]) -> dict[str, list[str]
|
|
|
304
358
|
|
|
305
359
|
|
|
306
360
|
@lru_cache
|
|
307
|
-
def list_localized_countries(include_aliases=True) -> dict[str, list[str]]:
|
|
308
|
-
"""
|
|
309
|
-
Get all localized countries and languages they support.
|
|
361
|
+
def list_localized_countries(include_aliases: bool = True) -> dict[str, list[str]]:
|
|
362
|
+
"""Get all localized countries and languages they support.
|
|
310
363
|
|
|
311
|
-
:
|
|
312
|
-
|
|
364
|
+
Args:
|
|
365
|
+
include_aliases:
|
|
366
|
+
Whether to include entity aliases (e.g. UK for GB).
|
|
313
367
|
|
|
314
|
-
:
|
|
315
|
-
A dictionary where key is an ISO 3166-1 alpha-2 country code and
|
|
316
|
-
|
|
317
|
-
|
|
368
|
+
Returns:
|
|
369
|
+
A dictionary where key is an ISO 3166-1 alpha-2 country code and value is a
|
|
370
|
+
list of supported languages (either ISO 639-1 or a combination of ISO 639-1
|
|
371
|
+
and ISO 3166-1 codes joined with "_").
|
|
318
372
|
"""
|
|
319
|
-
|
|
320
373
|
return _list_localized_entities(EntityLoader.get_country_codes(include_aliases))
|
|
321
374
|
|
|
322
375
|
|
|
323
376
|
@lru_cache
|
|
324
|
-
def list_localized_financial(include_aliases=True) -> dict[str, list[str]]:
|
|
325
|
-
"""
|
|
326
|
-
Get all localized financial markets and languages they support.
|
|
377
|
+
def list_localized_financial(include_aliases: bool = True) -> dict[str, list[str]]:
|
|
378
|
+
"""Get all localized financial markets and languages they support.
|
|
327
379
|
|
|
328
|
-
:
|
|
329
|
-
|
|
380
|
+
Args:
|
|
381
|
+
include_aliases:
|
|
382
|
+
Whether to include entity aliases (e.g. TAR for ECB, XNYS for NYSE).
|
|
330
383
|
|
|
331
|
-
:
|
|
332
|
-
A dictionary where key is a market code and value is a list of
|
|
333
|
-
|
|
384
|
+
Returns:
|
|
385
|
+
A dictionary where key is a market code and value is a list of supported
|
|
386
|
+
subdivision codes.
|
|
334
387
|
"""
|
|
335
|
-
|
|
336
388
|
return _list_localized_entities(EntityLoader.get_financial_codes(include_aliases))
|
|
337
389
|
|
|
338
390
|
|
|
339
391
|
def _list_supported_entities(entity_codes: Iterable[str]) -> dict[str, list[str]]:
|
|
340
|
-
"""
|
|
341
|
-
Get all supported entities and their subdivisions.
|
|
392
|
+
"""Get all supported entities and their subdivisions.
|
|
342
393
|
|
|
343
|
-
:
|
|
344
|
-
|
|
394
|
+
Args:
|
|
395
|
+
entity_codes:
|
|
396
|
+
A list of entity codes.
|
|
345
397
|
|
|
346
|
-
:
|
|
347
|
-
A dictionary where key is an entity code and value is a list
|
|
348
|
-
|
|
398
|
+
Returns:
|
|
399
|
+
A dictionary where key is an entity code and value is a list of supported
|
|
400
|
+
subdivision codes.
|
|
349
401
|
"""
|
|
350
402
|
import holidays
|
|
351
403
|
|
|
@@ -356,30 +408,30 @@ def _list_supported_entities(entity_codes: Iterable[str]) -> dict[str, list[str]
|
|
|
356
408
|
|
|
357
409
|
|
|
358
410
|
@lru_cache
|
|
359
|
-
def list_supported_countries(include_aliases=True) -> dict[str, list[str]]:
|
|
360
|
-
"""
|
|
361
|
-
Get all supported countries and their subdivisions.
|
|
411
|
+
def list_supported_countries(include_aliases: bool = True) -> dict[str, list[str]]:
|
|
412
|
+
"""Get all supported countries and their subdivisions.
|
|
362
413
|
|
|
363
|
-
:
|
|
364
|
-
|
|
414
|
+
Args:
|
|
415
|
+
include_aliases:
|
|
416
|
+
Whether to include entity aliases (e.g. UK for GB).
|
|
365
417
|
|
|
366
|
-
:
|
|
367
|
-
A dictionary where key is an ISO 3166-1 alpha-2 country code and
|
|
368
|
-
|
|
418
|
+
Returns:
|
|
419
|
+
A dictionary where key is an ISO 3166-1 alpha-2 country code and value
|
|
420
|
+
is a list of supported subdivision codes.
|
|
369
421
|
"""
|
|
370
422
|
return _list_supported_entities(EntityLoader.get_country_codes(include_aliases))
|
|
371
423
|
|
|
372
424
|
|
|
373
425
|
@lru_cache
|
|
374
|
-
def list_supported_financial(include_aliases=True) -> dict[str, list[str]]:
|
|
375
|
-
"""
|
|
376
|
-
Get all supported financial markets and their subdivisions.
|
|
426
|
+
def list_supported_financial(include_aliases: bool = True) -> dict[str, list[str]]:
|
|
427
|
+
"""Get all supported financial markets and their subdivisions.
|
|
377
428
|
|
|
378
|
-
:
|
|
379
|
-
|
|
429
|
+
Args:
|
|
430
|
+
include_aliases:
|
|
431
|
+
Whether to include entity aliases (e.g. TAR for ECB, XNYS for NYSE).
|
|
380
432
|
|
|
381
|
-
:
|
|
382
|
-
A dictionary where key is a market code and value is a list of
|
|
383
|
-
|
|
433
|
+
Returns:
|
|
434
|
+
A dictionary where key is a market code and value is a list of supported
|
|
435
|
+
subdivision codes.
|
|
384
436
|
"""
|
|
385
437
|
return _list_supported_entities(EntityLoader.get_financial_codes(include_aliases))
|
holidays/version.py
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
# specific sets of holidays on the fly. It aims to make determining whether a
|
|
5
5
|
# specific date is a holiday as fast and flexible as possible.
|
|
6
6
|
#
|
|
7
|
-
# Authors: Vacanza Team and individual contributors (see AUTHORS file)
|
|
7
|
+
# Authors: Vacanza Team and individual contributors (see AUTHORS.md file)
|
|
8
8
|
# dr-prodigy <dr.prodigy.github@gmail.com> (c) 2017-2023
|
|
9
9
|
# ryanss <ryanssdev@icloud.com> (c) 2014-2017
|
|
10
10
|
# Website: https://github.com/vacanza/holidays
|
|
11
11
|
# License: MIT (see LICENSE file)
|
|
12
12
|
|
|
13
|
-
__version__ = "0.
|
|
13
|
+
__version__ = "0.71"
|