holidays 0.76__py3-none-any.whl → 0.78__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/calendars/islamic.py +32 -1
- holidays/countries/__init__.py +20 -0
- holidays/countries/australia.py +6 -8
- holidays/countries/british_virgin_islands.py +6 -6
- holidays/countries/cabo_verde.py +293 -0
- holidays/countries/cayman_islands.py +162 -0
- holidays/countries/central_african_republic.py +143 -0
- holidays/countries/christmas_island.py +215 -0
- holidays/countries/cocos_islands.py +4 -4
- holidays/countries/dr_congo.py +139 -0
- holidays/countries/egypt.py +203 -47
- holidays/countries/faroe_islands.py +102 -0
- holidays/countries/georgia.py +11 -5
- holidays/countries/germany.py +41 -0
- holidays/countries/gibraltar.py +219 -0
- holidays/countries/guernsey.py +6 -6
- holidays/countries/indonesia.py +5 -2
- holidays/countries/japan.py +6 -8
- holidays/countries/jersey.py +2 -2
- holidays/countries/lebanon.py +448 -0
- holidays/countries/luxembourg.py +13 -0
- holidays/countries/mali.py +151 -0
- holidays/countries/montserrat.py +177 -0
- holidays/countries/nepal.py +8 -8
- holidays/countries/new_zealand.py +2 -2
- holidays/countries/niue.py +115 -0
- holidays/countries/norfolk_island.py +129 -0
- holidays/countries/pakistan.py +7 -5
- holidays/countries/palau.py +1 -1
- holidays/countries/palestine.py +177 -0
- holidays/countries/peru.py +12 -0
- holidays/countries/pitcairn_islands.py +85 -0
- holidays/countries/saint_vincent_and_the_grenadines.py +130 -0
- holidays/countries/saudi_arabia.py +43 -35
- holidays/countries/seychelles.py +1 -1
- holidays/countries/solomon_islands.py +2 -2
- holidays/countries/tokelau.py +66 -0
- holidays/countries/turks_and_caicos_islands.py +2 -2
- holidays/countries/united_kingdom.py +2 -2
- holidays/countries/united_states.py +2 -5
- holidays/groups/christian.py +10 -10
- holidays/groups/hebrew.py +2 -2
- holidays/groups/islamic.py +17 -10
- holidays/holiday_base.py +73 -92
- holidays/locale/ar/LC_MESSAGES/LB.mo +0 -0
- holidays/locale/ar/LC_MESSAGES/PS.mo +0 -0
- holidays/locale/{ar → ar_EG}/LC_MESSAGES/EG.mo +0 -0
- holidays/locale/da/LC_MESSAGES/FO.mo +0 -0
- holidays/locale/de/LC_MESSAGES/CV.mo +0 -0
- holidays/locale/de/LC_MESSAGES/DE.mo +0 -0
- holidays/locale/de/LC_MESSAGES/LU.mo +0 -0
- holidays/locale/en_CX/LC_MESSAGES/CX.mo +0 -0
- holidays/locale/en_GB/LC_MESSAGES/GI.mo +0 -0
- holidays/locale/en_GB/LC_MESSAGES/KY.mo +0 -0
- holidays/locale/en_MS/LC_MESSAGES/MS.mo +0 -0
- holidays/locale/en_NF/LC_MESSAGES/NF.mo +0 -0
- holidays/locale/en_NU/LC_MESSAGES/NU.mo +0 -0
- holidays/locale/en_TK/LC_MESSAGES/TK.mo +0 -0
- holidays/locale/en_US/LC_MESSAGES/CD.mo +0 -0
- holidays/locale/en_US/LC_MESSAGES/CF.mo +0 -0
- holidays/locale/en_US/LC_MESSAGES/CV.mo +0 -0
- holidays/locale/en_US/LC_MESSAGES/CX.mo +0 -0
- holidays/locale/en_US/LC_MESSAGES/DE.mo +0 -0
- holidays/locale/en_US/LC_MESSAGES/EG.mo +0 -0
- holidays/locale/en_US/LC_MESSAGES/FO.mo +0 -0
- holidays/locale/en_US/LC_MESSAGES/GI.mo +0 -0
- holidays/locale/en_US/LC_MESSAGES/KY.mo +0 -0
- holidays/locale/en_US/LC_MESSAGES/LB.mo +0 -0
- holidays/locale/en_US/LC_MESSAGES/LU.mo +0 -0
- holidays/locale/en_US/LC_MESSAGES/ML.mo +0 -0
- holidays/locale/en_US/LC_MESSAGES/MS.mo +0 -0
- holidays/locale/en_US/LC_MESSAGES/NF.mo +0 -0
- holidays/locale/en_US/LC_MESSAGES/NU.mo +0 -0
- holidays/locale/en_US/LC_MESSAGES/PE.mo +0 -0
- holidays/locale/en_US/LC_MESSAGES/PS.mo +0 -0
- holidays/locale/en_US/LC_MESSAGES/TK.mo +0 -0
- holidays/locale/en_US/LC_MESSAGES/VC.mo +0 -0
- holidays/locale/en_VC/LC_MESSAGES/VC.mo +0 -0
- holidays/locale/es/LC_MESSAGES/CV.mo +0 -0
- holidays/locale/fo/LC_MESSAGES/FO.mo +0 -0
- holidays/locale/fr/LC_MESSAGES/CD.mo +0 -0
- holidays/locale/fr/LC_MESSAGES/CF.mo +0 -0
- holidays/locale/fr/LC_MESSAGES/CV.mo +0 -0
- holidays/locale/fr/LC_MESSAGES/EG.mo +0 -0
- holidays/locale/fr/LC_MESSAGES/LU.mo +0 -0
- holidays/locale/fr/LC_MESSAGES/ML.mo +0 -0
- holidays/locale/is/LC_MESSAGES/FO.mo +0 -0
- holidays/locale/lb/LC_MESSAGES/LU.mo +0 -0
- holidays/locale/no/LC_MESSAGES/FO.mo +0 -0
- holidays/locale/pt_CV/LC_MESSAGES/CV.mo +0 -0
- holidays/locale/sv/LC_MESSAGES/FO.mo +0 -0
- holidays/locale/th/LC_MESSAGES/DE.mo +0 -0
- holidays/locale/tkl/LC_MESSAGES/TK.mo +0 -0
- holidays/locale/uk/LC_MESSAGES/DE.mo +0 -0
- holidays/locale/uk/LC_MESSAGES/LU.mo +0 -0
- holidays/locale/uk/LC_MESSAGES/PE.mo +0 -0
- holidays/observed_holiday_base.py +3 -1
- holidays/registry.py +16 -0
- holidays/utils.py +18 -18
- holidays/version.py +1 -1
- {holidays-0.76.dist-info → holidays-0.78.dist-info}/METADATA +118 -6
- {holidays-0.76.dist-info → holidays-0.78.dist-info}/RECORD +106 -51
- {holidays-0.76.dist-info → holidays-0.78.dist-info}/licenses/CONTRIBUTORS +4 -0
- {holidays-0.76.dist-info → holidays-0.78.dist-info}/WHEEL +0 -0
- {holidays-0.76.dist-info → holidays-0.78.dist-info}/licenses/LICENSE +0 -0
- {holidays-0.76.dist-info → holidays-0.78.dist-info}/top_level.txt +0 -0
|
@@ -351,8 +351,8 @@ class UnitedStates(ObservedHolidayBase, ChristianHolidays, InternationalHolidays
|
|
|
351
351
|
}
|
|
352
352
|
# Thanksgiving Day.
|
|
353
353
|
name = tr("Thanksgiving Day")
|
|
354
|
-
if self._year
|
|
355
|
-
self._add_holiday(name,
|
|
354
|
+
if dt := thanksgiving_day_dates.get(self._year):
|
|
355
|
+
self._add_holiday(name, dt)
|
|
356
356
|
elif self._year >= 1942:
|
|
357
357
|
self._add_holiday_4th_thu_of_nov(name)
|
|
358
358
|
else:
|
|
@@ -994,7 +994,6 @@ class UnitedStates(ObservedHolidayBase, ChristianHolidays, InternationalHolidays
|
|
|
994
994
|
# Lincoln's Birthday.
|
|
995
995
|
self._add_observed(self._add_holiday_feb_12(tr("Lincoln's Birthday")))
|
|
996
996
|
|
|
997
|
-
if self._year >= 1971:
|
|
998
997
|
# Presidents Day.
|
|
999
998
|
self._add_holiday_3rd_mon_of_feb(tr("Presidents Day"))
|
|
1000
999
|
|
|
@@ -1176,7 +1175,6 @@ class UnitedStates(ObservedHolidayBase, ChristianHolidays, InternationalHolidays
|
|
|
1176
1175
|
# Christmas Eve.
|
|
1177
1176
|
self._add_christmas_eve_holiday()
|
|
1178
1177
|
|
|
1179
|
-
if self._year >= 1981:
|
|
1180
1178
|
# Day After Christmas.
|
|
1181
1179
|
self._add_christmas_day_two(tr("Day After Christmas"))
|
|
1182
1180
|
|
|
@@ -1217,7 +1215,6 @@ class UnitedStates(ObservedHolidayBase, ChristianHolidays, InternationalHolidays
|
|
|
1217
1215
|
# George Washington Day.
|
|
1218
1216
|
self._add_holiday_3rd_mon_of_feb(tr("George Washington Day"))
|
|
1219
1217
|
|
|
1220
|
-
if self._year >= 1971:
|
|
1221
1218
|
self._add_holiday_2nd_mon_of_oct(
|
|
1222
1219
|
# Indigenous Peoples' Day.
|
|
1223
1220
|
tr("Indigenous Peoples' Day")
|
holidays/groups/christian.py
CHANGED
|
@@ -116,7 +116,7 @@ class ChristianHolidays:
|
|
|
116
116
|
"""
|
|
117
117
|
return self._add_holiday_nov_2(name)
|
|
118
118
|
|
|
119
|
-
def _add_ascension_thursday(self, name) -> date:
|
|
119
|
+
def _add_ascension_thursday(self, name, calendar=None) -> date:
|
|
120
120
|
"""
|
|
121
121
|
Add Ascension Thursday (39 days after the Easter Sunday).
|
|
122
122
|
|
|
@@ -124,7 +124,7 @@ class ChristianHolidays:
|
|
|
124
124
|
Day, or sometimes Holy Thursday.
|
|
125
125
|
https://en.wikipedia.org/wiki/Feast_of_the_Ascension
|
|
126
126
|
"""
|
|
127
|
-
return self._add_holiday(name, _timedelta(self.
|
|
127
|
+
return self._add_holiday(name, _timedelta(self.__get_easter_sunday(calendar), +39))
|
|
128
128
|
|
|
129
129
|
def _add_ash_monday(self, name) -> date:
|
|
130
130
|
"""
|
|
@@ -316,16 +316,16 @@ class ChristianHolidays:
|
|
|
316
316
|
"""
|
|
317
317
|
return self._add_holiday(name, _timedelta(self.__get_easter_sunday(calendar), -2))
|
|
318
318
|
|
|
319
|
-
def _add_holy_saturday(self, name) -> date:
|
|
319
|
+
def _add_holy_saturday(self, name, calendar=None) -> date:
|
|
320
320
|
"""
|
|
321
321
|
Add Holy Saturday (1 day before Easter Sunday).
|
|
322
322
|
|
|
323
323
|
Great and Holy Saturday is a day between Good Friday and Easter Sunday.
|
|
324
324
|
https://en.wikipedia.org/wiki/Holy_Saturday
|
|
325
325
|
"""
|
|
326
|
-
return self._add_holiday(name, _timedelta(self.
|
|
326
|
+
return self._add_holiday(name, _timedelta(self.__get_easter_sunday(calendar), -1))
|
|
327
327
|
|
|
328
|
-
def _add_holy_thursday(self, name) -> date:
|
|
328
|
+
def _add_holy_thursday(self, name, calendar=None) -> date:
|
|
329
329
|
"""
|
|
330
330
|
Add Holy Thursday (3 days before Easter Sunday).
|
|
331
331
|
|
|
@@ -334,7 +334,7 @@ class ChristianHolidays:
|
|
|
334
334
|
Jesus Christ with the Apostles, as described in the canonical gospels.
|
|
335
335
|
https://en.wikipedia.org/wiki/Maundy_Thursday
|
|
336
336
|
"""
|
|
337
|
-
return self._add_holiday(name, _timedelta(self.
|
|
337
|
+
return self._add_holiday(name, _timedelta(self.__get_easter_sunday(calendar), -3))
|
|
338
338
|
|
|
339
339
|
def _add_immaculate_conception_day(self, name) -> date:
|
|
340
340
|
"""
|
|
@@ -355,7 +355,7 @@ class ChristianHolidays:
|
|
|
355
355
|
"""
|
|
356
356
|
return self._add_holiday_sep_8(name)
|
|
357
357
|
|
|
358
|
-
def _add_palm_sunday(self, name) -> date:
|
|
358
|
+
def _add_palm_sunday(self, name, calendar=None) -> date:
|
|
359
359
|
"""
|
|
360
360
|
Add Palm Sunday (7 days before Easter Sunday).
|
|
361
361
|
|
|
@@ -365,7 +365,7 @@ class ChristianHolidays:
|
|
|
365
365
|
Palm Sunday marks the first day of Holy Week.
|
|
366
366
|
https://en.wikipedia.org/wiki/Palm_Sunday
|
|
367
367
|
"""
|
|
368
|
-
return self._add_holiday(name, _timedelta(self.
|
|
368
|
+
return self._add_holiday(name, _timedelta(self.__get_easter_sunday(calendar), -7))
|
|
369
369
|
|
|
370
370
|
def _add_rejoicing_day(self, name) -> date:
|
|
371
371
|
"""
|
|
@@ -440,7 +440,7 @@ class ChristianHolidays:
|
|
|
440
440
|
"""
|
|
441
441
|
return self._add_holiday(name, _timedelta(self._easter_sunday, +50))
|
|
442
442
|
|
|
443
|
-
def _add_whit_sunday(self, name) -> date:
|
|
443
|
+
def _add_whit_sunday(self, name, calendar=None) -> date:
|
|
444
444
|
"""
|
|
445
445
|
Add Whit Sunday (49 days after Easter Sunday).
|
|
446
446
|
|
|
@@ -450,7 +450,7 @@ class ChristianHolidays:
|
|
|
450
450
|
Feast of Weeks.
|
|
451
451
|
https://en.wikipedia.org/wiki/Pentecost
|
|
452
452
|
"""
|
|
453
|
-
return self._add_holiday(name, _timedelta(self.
|
|
453
|
+
return self._add_holiday(name, _timedelta(self.__get_easter_sunday(calendar), +49))
|
|
454
454
|
|
|
455
455
|
def _add_trinity_sunday(self, name) -> date:
|
|
456
456
|
"""
|
holidays/groups/hebrew.py
CHANGED
|
@@ -27,11 +27,11 @@ class HebrewCalendarHolidays:
|
|
|
27
27
|
self._hebrew_calendar = _HebrewLunisolar()
|
|
28
28
|
|
|
29
29
|
def _add_hebrew_calendar_holiday(
|
|
30
|
-
self, name: str,
|
|
30
|
+
self, name: str, holiday_date: date, days_delta: Union[int, Iterable[int]] = 0
|
|
31
31
|
) -> set[date]:
|
|
32
32
|
added_dates = set()
|
|
33
33
|
for delta in (days_delta,) if isinstance(days_delta, int) else days_delta:
|
|
34
|
-
if dt := self._add_holiday(name, _timedelta(
|
|
34
|
+
if dt := self._add_holiday(name, _timedelta(holiday_date, delta)):
|
|
35
35
|
added_dates.add(dt)
|
|
36
36
|
return added_dates
|
|
37
37
|
|
holidays/groups/islamic.py
CHANGED
|
@@ -182,16 +182,6 @@ class IslamicHolidays(EasternCalendarHolidays):
|
|
|
182
182
|
name, self._islamic_calendar.eid_al_fitr_dates(self._year), days_delta=+2
|
|
183
183
|
)
|
|
184
184
|
|
|
185
|
-
def _add_eid_al_fitr_day_four(self, name) -> set[date]:
|
|
186
|
-
"""
|
|
187
|
-
Add Eid al-Fitr Day Four.
|
|
188
|
-
|
|
189
|
-
https://en.wikipedia.org/wiki/Eid_al-Fitr
|
|
190
|
-
"""
|
|
191
|
-
return self._add_islamic_calendar_holiday(
|
|
192
|
-
name, self._islamic_calendar.eid_al_fitr_dates(self._year), days_delta=+3
|
|
193
|
-
)
|
|
194
|
-
|
|
195
185
|
def _add_eid_al_fitr_eve(self, name) -> set[date]:
|
|
196
186
|
"""
|
|
197
187
|
Add Eid al-Fitr Eve (last day of 9th month of Islamic calendar).
|
|
@@ -373,6 +363,23 @@ class IslamicHolidays(EasternCalendarHolidays):
|
|
|
373
363
|
name, self._islamic_calendar.nuzul_al_quran_dates(self._year)
|
|
374
364
|
)
|
|
375
365
|
|
|
366
|
+
def _add_prophet_baptism_day(self, name) -> set[date]:
|
|
367
|
+
"""
|
|
368
|
+
Add Prophet's Baptism.
|
|
369
|
+
|
|
370
|
+
Celebrated one week after the Prophet Mohammed's Birthday, this
|
|
371
|
+
marks the traditional Islamic birth rites that take place seven
|
|
372
|
+
days after birth. While it is not recognized in mainstream Islam,
|
|
373
|
+
Mali celebrates it as a cultural-religious public holiday that
|
|
374
|
+
reflects the local interpretation and honor of the Prophet Muhammad.
|
|
375
|
+
The term "baptism" is symbolic and not literal - there's no Islamic
|
|
376
|
+
ritual akin to Christian baptism.
|
|
377
|
+
https://www.officeholidays.com/holidays/mali/prophets-baptism
|
|
378
|
+
"""
|
|
379
|
+
return self._add_islamic_calendar_holiday(
|
|
380
|
+
name, self._islamic_calendar.mawlid_dates(self._year), days_delta=+7
|
|
381
|
+
)
|
|
382
|
+
|
|
376
383
|
def _add_prophet_death_day(self, name) -> set[date]:
|
|
377
384
|
"""
|
|
378
385
|
Add death of Prophet Muhammad and Hasan ibn Ali day (28th day of 2nd month).
|
holidays/holiday_base.py
CHANGED
|
@@ -44,7 +44,7 @@ from holidays.constants import HOLIDAY_NAME_DELIMITER, PUBLIC, DEFAULT_START_YEA
|
|
|
44
44
|
from holidays.helpers import _normalize_arguments, _normalize_tuple
|
|
45
45
|
|
|
46
46
|
CategoryArg = Union[str, Iterable[str]]
|
|
47
|
-
DateArg = Union[date, tuple[int, int]]
|
|
47
|
+
DateArg = Union[date, tuple[int, int], tuple[int, int, int]]
|
|
48
48
|
DateLike = Union[date, datetime, str, float, int]
|
|
49
49
|
SpecialHoliday = Union[tuple[int, int, str], tuple[tuple[int, int, str], ...]]
|
|
50
50
|
SubstitutedHoliday = Union[
|
|
@@ -55,57 +55,32 @@ YearArg = Union[int, Iterable[int]]
|
|
|
55
55
|
|
|
56
56
|
|
|
57
57
|
class HolidayBase(dict[date, str]):
|
|
58
|
-
"""
|
|
59
|
-
A `dict`-like object containing the holidays for a specific country (and
|
|
60
|
-
province or state if so initiated); inherits the `dict` class (so behaves
|
|
61
|
-
similarly to a `dict`). Dates without a key in the Holiday object are not
|
|
62
|
-
holidays.
|
|
63
|
-
|
|
64
|
-
The key of the object is the date of the holiday and the value is the name
|
|
65
|
-
of the holiday itself. When passing the date as a key, the date can be
|
|
66
|
-
expressed as one of the following formats:
|
|
67
|
-
|
|
68
|
-
* `datetime.datetime` type;
|
|
69
|
-
* `datetime.date` types;
|
|
70
|
-
* a `float` representing a Unix timestamp;
|
|
71
|
-
* or a string of any format (recognized by `dateutil.parser.parse()`).
|
|
72
|
-
|
|
73
|
-
The key is always returned as a `datetime.date` object.
|
|
74
|
-
|
|
75
|
-
To maximize speed, the list of holidays is built as needed on the fly, one
|
|
76
|
-
calendar year at a time. When you instantiate the object, it is empty, but
|
|
77
|
-
the moment a key is accessed it will build that entire year's list of
|
|
78
|
-
holidays. To pre-populate holidays, instantiate the class with the years
|
|
79
|
-
argument:
|
|
80
|
-
|
|
81
|
-
us_holidays = holidays.US(years=2020)
|
|
58
|
+
"""Represent a dictionary-like collection of holidays for a specific country or region.
|
|
82
59
|
|
|
83
|
-
|
|
84
|
-
|
|
60
|
+
This class inherits from `dict` and maps holiday dates to their names. It supports
|
|
61
|
+
customization by country and, optionally, by province or state (subdivision). A date
|
|
62
|
+
not present as a key is not considered a holiday (or, if `observed` is `False`, not
|
|
63
|
+
considered an observed holiday).
|
|
85
64
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
Dates where a key is not present are not public holidays (or, if
|
|
89
|
-
**observed** is False, days when a public holiday is observed).
|
|
65
|
+
Keys are holiday dates, and values are corresponding holiday names. When accessing or
|
|
66
|
+
assigning holidays by date, the following input formats are accepted:
|
|
90
67
|
|
|
91
|
-
|
|
92
|
-
|
|
68
|
+
* `datetime.date`
|
|
69
|
+
* `datetime.datetime`
|
|
70
|
+
* `float` or `int` (Unix timestamp)
|
|
71
|
+
* `str` of any format recognized by `dateutil.parser.parse()`
|
|
93
72
|
|
|
94
|
-
|
|
95
|
-
* `datetime.datetime`,
|
|
96
|
-
* a `str` of any format recognized by `dateutil.parser.parse()`,
|
|
97
|
-
* or a `float` or `int` representing a POSIX timestamp.
|
|
73
|
+
Keys are always returned as `datetime.date` objects.
|
|
98
74
|
|
|
99
|
-
|
|
75
|
+
To maximize performance, the holiday list is lazily populated one year at a time.
|
|
76
|
+
On instantiation, the object is empty. Once a date is accessed, the full calendar
|
|
77
|
+
year for that date is generated, unless `expand` is set to `False`. To pre-populate
|
|
78
|
+
holidays, instantiate the class with the `years` argument:
|
|
100
79
|
|
|
101
|
-
|
|
102
|
-
needed, one calendar year at a time. When the object is instantiated
|
|
103
|
-
without a **years** parameter, it is empty, but, unless **expand** is set
|
|
104
|
-
to False, as soon as a key is accessed the class will calculate that entire
|
|
105
|
-
year's list of holidays and set the keys with them.
|
|
80
|
+
us_holidays = holidays.US(years=2020)
|
|
106
81
|
|
|
107
|
-
|
|
108
|
-
|
|
82
|
+
It is recommended to use the
|
|
83
|
+
[country_holidays()][holidays.utils.country_holidays] function for instantiation.
|
|
109
84
|
|
|
110
85
|
Example usage:
|
|
111
86
|
|
|
@@ -163,14 +138,13 @@ class HolidayBase(dict[date, str]):
|
|
|
163
138
|
>>> assert '2018-01-06' not in us_holidays
|
|
164
139
|
>>> assert '2018-01-06' in us_pr_holidays
|
|
165
140
|
|
|
166
|
-
Append custom holiday dates by passing one of:
|
|
141
|
+
Append custom holiday dates by passing one of the following:
|
|
167
142
|
|
|
168
|
-
*
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
used as a description:
|
|
143
|
+
* A dict mapping date values to holiday names (e.g. `{'2010-07-10': 'My birthday!'}`).
|
|
144
|
+
* A list of date values (`datetime.date`, `datetime.datetime`, `str`, `int`, or `float`);
|
|
145
|
+
each will be added with 'Holiday' as the default name.
|
|
146
|
+
* A single date value of any of the supported types above; 'Holiday' will be used as
|
|
147
|
+
the default name.
|
|
174
148
|
|
|
175
149
|
```python
|
|
176
150
|
>>> custom_holidays = country_holidays('US', years=2015)
|
|
@@ -325,7 +299,7 @@ class HolidayBase(dict[date, str]):
|
|
|
325
299
|
Requested holiday categories.
|
|
326
300
|
|
|
327
301
|
Returns:
|
|
328
|
-
A `HolidayBase` object matching the
|
|
302
|
+
A `HolidayBase` object matching the `country` or `market`.
|
|
329
303
|
"""
|
|
330
304
|
super().__init__()
|
|
331
305
|
|
|
@@ -436,10 +410,10 @@ class HolidayBase(dict[date, str]):
|
|
|
436
410
|
|
|
437
411
|
The method supports the following input types:
|
|
438
412
|
|
|
439
|
-
* `datetime.date
|
|
440
|
-
* `datetime.datetime
|
|
441
|
-
*
|
|
442
|
-
*
|
|
413
|
+
* `datetime.date`
|
|
414
|
+
* `datetime.datetime`
|
|
415
|
+
* `float` or `int` (Unix timestamp)
|
|
416
|
+
* `str` of any format recognized by `dateutil.parser.parse()`
|
|
443
417
|
|
|
444
418
|
Args:
|
|
445
419
|
key:
|
|
@@ -617,10 +591,11 @@ class HolidayBase(dict[date, str]):
|
|
|
617
591
|
"""Convert various date-like formats to `datetime.date`.
|
|
618
592
|
|
|
619
593
|
The method supports the following input types:
|
|
620
|
-
|
|
621
|
-
* `datetime.
|
|
622
|
-
*
|
|
623
|
-
*
|
|
594
|
+
|
|
595
|
+
* `datetime.date`
|
|
596
|
+
* `datetime.datetime`
|
|
597
|
+
* `float` or `int` (Unix timestamp)
|
|
598
|
+
* `str` of any format recognized by `dateutil.parser.parse()`
|
|
624
599
|
|
|
625
600
|
Args:
|
|
626
601
|
key:
|
|
@@ -816,9 +791,7 @@ class HolidayBase(dict[date, str]):
|
|
|
816
791
|
self.tr = gettext
|
|
817
792
|
|
|
818
793
|
def _is_leap_year(self) -> bool:
|
|
819
|
-
"""
|
|
820
|
-
Returns True if the year is leap. Returns False otherwise.
|
|
821
|
-
"""
|
|
794
|
+
"""Returns True if the year is leap. Returns False otherwise."""
|
|
822
795
|
return isleap(self._year)
|
|
823
796
|
|
|
824
797
|
def _add_holiday(self, name: str, *args) -> Optional[date]:
|
|
@@ -899,12 +872,13 @@ class HolidayBase(dict[date, str]):
|
|
|
899
872
|
return dt.weekday() in self.weekend
|
|
900
873
|
|
|
901
874
|
def _populate(self, year: int) -> None:
|
|
902
|
-
"""This is a private
|
|
875
|
+
"""This is a private method that populates (generates and adds) holidays
|
|
903
876
|
for a given year. To keep things fast, it assumes that no holidays for
|
|
904
877
|
the year have already been populated. It is required to be called
|
|
905
|
-
internally by any country populate() method, while should not be called
|
|
878
|
+
internally by any country `populate()` method, while should not be called
|
|
906
879
|
directly from outside.
|
|
907
|
-
To add holidays to an object, use the update()
|
|
880
|
+
To add holidays to an object, use the [update()][holidays.holiday_base.HolidayBase.update]
|
|
881
|
+
method.
|
|
908
882
|
|
|
909
883
|
Args:
|
|
910
884
|
year: The year to populate with holidays.
|
|
@@ -980,10 +954,10 @@ class HolidayBase(dict[date, str]):
|
|
|
980
954
|
key:
|
|
981
955
|
The date expressed in one of the following types:
|
|
982
956
|
|
|
983
|
-
* `datetime.date
|
|
984
|
-
* `datetime.datetime
|
|
985
|
-
*
|
|
986
|
-
*
|
|
957
|
+
* `datetime.date`
|
|
958
|
+
* `datetime.datetime`
|
|
959
|
+
* `float` or `int` (Unix timestamp)
|
|
960
|
+
* `str` of any format recognized by `dateutil.parser.parse()`
|
|
987
961
|
|
|
988
962
|
default:
|
|
989
963
|
The default value to return if no value is found.
|
|
@@ -1001,10 +975,10 @@ class HolidayBase(dict[date, str]):
|
|
|
1001
975
|
key:
|
|
1002
976
|
The date expressed in one of the following types:
|
|
1003
977
|
|
|
1004
|
-
* `datetime.date
|
|
1005
|
-
* `datetime.datetime
|
|
1006
|
-
*
|
|
1007
|
-
*
|
|
978
|
+
* `datetime.date`
|
|
979
|
+
* `datetime.datetime`
|
|
980
|
+
* `float` or `int` (Unix timestamp)
|
|
981
|
+
* `str` of any format recognized by `dateutil.parser.parse()`
|
|
1008
982
|
|
|
1009
983
|
Returns:
|
|
1010
984
|
A list of holiday names if the date is a holiday, otherwise an empty list.
|
|
@@ -1116,6 +1090,7 @@ class HolidayBase(dict[date, str]):
|
|
|
1116
1090
|
"""Find the n-th working day from a given date.
|
|
1117
1091
|
|
|
1118
1092
|
Moves forward if n is positive, or backward if n is negative.
|
|
1093
|
+
If n is 0, returns the given date if it is a working day; otherwise the next working day.
|
|
1119
1094
|
|
|
1120
1095
|
Args:
|
|
1121
1096
|
key:
|
|
@@ -1128,10 +1103,11 @@ class HolidayBase(dict[date, str]):
|
|
|
1128
1103
|
Returns:
|
|
1129
1104
|
The calculated working day after shifting by n working days.
|
|
1130
1105
|
"""
|
|
1131
|
-
direction = +1 if n
|
|
1106
|
+
direction = +1 if n >= 0 else -1
|
|
1132
1107
|
dt = self.__keytransform__(key)
|
|
1133
|
-
for _ in range(abs(n)):
|
|
1134
|
-
|
|
1108
|
+
for _ in range(abs(n) or 1):
|
|
1109
|
+
if n:
|
|
1110
|
+
dt = _timedelta(dt, direction)
|
|
1135
1111
|
while not self.is_working_day(dt):
|
|
1136
1112
|
dt = _timedelta(dt, direction)
|
|
1137
1113
|
return dt
|
|
@@ -1183,10 +1159,10 @@ class HolidayBase(dict[date, str]):
|
|
|
1183
1159
|
key:
|
|
1184
1160
|
The date expressed in one of the following types:
|
|
1185
1161
|
|
|
1186
|
-
* `datetime.date
|
|
1187
|
-
* `datetime.datetime
|
|
1188
|
-
*
|
|
1189
|
-
*
|
|
1162
|
+
* `datetime.date`
|
|
1163
|
+
* `datetime.datetime`
|
|
1164
|
+
* `float` or `int` (Unix timestamp)
|
|
1165
|
+
* `str` of any format recognized by `dateutil.parser.parse()`
|
|
1190
1166
|
|
|
1191
1167
|
default:
|
|
1192
1168
|
The default value to return if no match is found.
|
|
@@ -1290,10 +1266,10 @@ class HolidayBase(dict[date, str]):
|
|
|
1290
1266
|
|
|
1291
1267
|
Dates can be expressed in one or more of the following types:
|
|
1292
1268
|
|
|
1293
|
-
* `datetime.date
|
|
1294
|
-
* `datetime.datetime
|
|
1295
|
-
*
|
|
1296
|
-
*
|
|
1269
|
+
* `datetime.date`
|
|
1270
|
+
* `datetime.datetime`
|
|
1271
|
+
* `float` or `int` (Unix timestamp)
|
|
1272
|
+
* `str` of any format recognized by `dateutil.parser.parse()`
|
|
1297
1273
|
"""
|
|
1298
1274
|
for arg in args:
|
|
1299
1275
|
if isinstance(arg, dict):
|
|
@@ -1308,12 +1284,17 @@ class HolidayBase(dict[date, str]):
|
|
|
1308
1284
|
|
|
1309
1285
|
class HolidaySum(HolidayBase):
|
|
1310
1286
|
"""
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1287
|
+
Combine multiple holiday collections into a single dictionary-like object.
|
|
1288
|
+
|
|
1289
|
+
This class represents the sum of two or more `HolidayBase` instances.
|
|
1290
|
+
The resulting object behaves like a dictionary mapping dates to holiday
|
|
1291
|
+
names, with the following behaviors:
|
|
1292
|
+
|
|
1293
|
+
* The `holidays` attribute stores the original holiday collections as a list.
|
|
1294
|
+
* The `country` and `subdiv` attributes are combined from all operands and
|
|
1295
|
+
may become lists.
|
|
1296
|
+
* If multiple holidays fall on the same date, their names are merged.
|
|
1297
|
+
* Holidays are generated (expanded) for all years included in the operands.
|
|
1317
1298
|
"""
|
|
1318
1299
|
|
|
1319
1300
|
country: Union[str, list[str]] # type: ignore[assignment]
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -151,7 +151,9 @@ class ObservedHolidayBase(HolidayBase):
|
|
|
151
151
|
if dt is None:
|
|
152
152
|
return False, None
|
|
153
153
|
|
|
154
|
-
|
|
154
|
+
# Use as is if already a date.
|
|
155
|
+
# Convert to date: (m, d) → use self._year; (y, m, d) → use directly.
|
|
156
|
+
dt = dt if isinstance(dt, date) else date(self._year, *dt) if len(dt) == 2 else date(*dt)
|
|
155
157
|
|
|
156
158
|
if not self.observed or not self._is_observed(dt):
|
|
157
159
|
return False, dt
|