holidays 0.48__py3-none-any.whl → 0.49__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/gregorian.py +22 -7
- holidays/calendars/persian.py +3 -2
- holidays/calendars/thai.py +24 -20
- holidays/countries/angola.py +2 -2
- holidays/countries/aruba.py +2 -3
- holidays/countries/cambodia.py +7 -8
- holidays/countries/canada.py +2 -1
- holidays/countries/curacao.py +3 -4
- holidays/countries/finland.py +2 -2
- holidays/countries/hongkong.py +398 -133
- holidays/countries/israel.py +13 -13
- holidays/countries/italy.py +2 -4
- holidays/countries/japan.py +17 -6
- holidays/countries/jersey.py +2 -2
- holidays/countries/laos.py +7 -23
- holidays/countries/madagascar.py +2 -3
- holidays/countries/malaysia.py +545 -235
- holidays/countries/netherlands.py +2 -3
- holidays/countries/new_zealand.py +5 -5
- holidays/countries/saudi_arabia.py +2 -3
- holidays/countries/south_korea.py +17 -4
- holidays/countries/sweden.py +2 -3
- holidays/countries/switzerland.py +2 -3
- holidays/financial/__init__.py +1 -0
- holidays/financial/ice_futures_europe.py +47 -0
- holidays/financial/ny_stock_exchange.py +17 -4
- holidays/groups/chinese.py +2 -3
- holidays/groups/christian.py +18 -19
- holidays/groups/islamic.py +2 -2
- holidays/groups/persian.py +2 -2
- holidays/helpers.py +9 -3
- holidays/holiday_base.py +18 -15
- holidays/locale/en_US/LC_MESSAGES/MY.mo +0 -0
- holidays/locale/en_US/LC_MESSAGES/MY.po +250 -0
- holidays/locale/ms_MY/LC_MESSAGES/MY.mo +0 -0
- holidays/locale/ms_MY/LC_MESSAGES/MY.po +250 -0
- holidays/mixins.py +31 -0
- holidays/observed_holiday_base.py +25 -13
- holidays/registry.py +1 -0
- {holidays-0.48.dist-info → holidays-0.49.dist-info}/METADATA +7 -4
- {holidays-0.48.dist-info → holidays-0.49.dist-info}/RECORD +46 -40
- {holidays-0.48.dist-info → holidays-0.49.dist-info}/AUTHORS +0 -0
- {holidays-0.48.dist-info → holidays-0.49.dist-info}/LICENSE +0 -0
- {holidays-0.48.dist-info → holidays-0.49.dist-info}/WHEEL +0 -0
- {holidays-0.48.dist-info → holidays-0.49.dist-info}/top_level.txt +0 -0
|
@@ -11,10 +11,9 @@
|
|
|
11
11
|
# License: MIT (see LICENSE file)
|
|
12
12
|
|
|
13
13
|
from datetime import date
|
|
14
|
-
from datetime import timedelta as td
|
|
15
14
|
from gettext import gettext as tr
|
|
16
15
|
|
|
17
|
-
from holidays.calendars.gregorian import APR, AUG
|
|
16
|
+
from holidays.calendars.gregorian import APR, AUG, _timedelta
|
|
18
17
|
from holidays.constants import OPTIONAL, PUBLIC
|
|
19
18
|
from holidays.groups import ChristianHolidays, InternationalHolidays
|
|
20
19
|
from holidays.holiday_base import HolidayBase
|
|
@@ -65,7 +64,7 @@ class Netherlands(HolidayBase, ChristianHolidays, InternationalHolidays):
|
|
|
65
64
|
else:
|
|
66
65
|
dt = date(self._year, AUG, 31)
|
|
67
66
|
if self._is_sunday(dt):
|
|
68
|
-
dt
|
|
67
|
+
dt = _timedelta(dt, -1 if self._year >= 1980 else +1)
|
|
69
68
|
self._add_holiday(name, dt)
|
|
70
69
|
|
|
71
70
|
if self._year >= 1950 and self._year % 5 == 0:
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
# License: MIT (see LICENSE file)
|
|
12
12
|
|
|
13
13
|
from datetime import date
|
|
14
|
-
from
|
|
14
|
+
from typing import Optional
|
|
15
15
|
|
|
16
|
-
from holidays.calendars.gregorian import JAN, FEB, MAR, JUN, JUL, SEP, NOV, DEC
|
|
16
|
+
from holidays.calendars.gregorian import JAN, FEB, MAR, JUN, JUL, SEP, NOV, DEC, _timedelta
|
|
17
17
|
from holidays.groups import ChristianHolidays, InternationalHolidays, StaticHolidays
|
|
18
18
|
from holidays.observed_holiday_base import (
|
|
19
19
|
ObservedHolidayBase,
|
|
@@ -75,7 +75,7 @@ class NewZealand(ObservedHolidayBase, ChristianHolidays, InternationalHolidays,
|
|
|
75
75
|
kwargs.setdefault("observed_rule", SAT_SUN_TO_NEXT_MON)
|
|
76
76
|
super().__init__(*args, **kwargs)
|
|
77
77
|
|
|
78
|
-
def _get_nearest_monday(self, *args) -> date:
|
|
78
|
+
def _get_nearest_monday(self, *args) -> Optional[date]:
|
|
79
79
|
dt = args if len(args) > 1 else args[0]
|
|
80
80
|
dt = dt if isinstance(dt, date) else date(self._year, *dt)
|
|
81
81
|
return self._get_observed_date(dt, rule=ALL_TO_NEAREST_MON)
|
|
@@ -243,8 +243,8 @@ class NewZealand(ObservedHolidayBase, ChristianHolidays, InternationalHolidays,
|
|
|
243
243
|
def _populate_subdiv_ota_public_holidays(self):
|
|
244
244
|
# there is no easily determined single day of local observance?!?!
|
|
245
245
|
dt = self._get_nearest_monday(MAR, 23)
|
|
246
|
-
if dt == self._easter_sunday +
|
|
247
|
-
dt
|
|
246
|
+
if dt == _timedelta(self._easter_sunday, +1): # Avoid Easter Monday
|
|
247
|
+
dt = _timedelta(dt, +1)
|
|
248
248
|
self._add_holiday("Otago Anniversary Day", dt)
|
|
249
249
|
|
|
250
250
|
def _populate_subdiv_stc_public_holidays(self):
|
|
@@ -11,11 +11,10 @@
|
|
|
11
11
|
# License: MIT (see LICENSE file)
|
|
12
12
|
|
|
13
13
|
from datetime import date
|
|
14
|
-
from datetime import timedelta as td
|
|
15
14
|
from gettext import gettext as tr
|
|
16
15
|
from typing import Set
|
|
17
16
|
|
|
18
|
-
from holidays.calendars.gregorian import JAN, FEB, SEP, NOV, THU, FRI, SAT
|
|
17
|
+
from holidays.calendars.gregorian import JAN, FEB, SEP, NOV, THU, FRI, SAT, _timedelta
|
|
19
18
|
from holidays.groups import IslamicHolidays, StaticHolidays
|
|
20
19
|
from holidays.observed_holiday_base import (
|
|
21
20
|
ObservedHolidayBase,
|
|
@@ -67,7 +66,7 @@ class SaudiArabia(ObservedHolidayBase, IslamicHolidays, StaticHolidays):
|
|
|
67
66
|
observed_rule = THU_FRI_TO_NEXT_WORKDAY if self._year <= 2012 else FRI_SAT_TO_NEXT_WORKDAY
|
|
68
67
|
for dt in dts:
|
|
69
68
|
for i in range(4):
|
|
70
|
-
self._add_observed(dt
|
|
69
|
+
self._add_observed(_timedelta(dt, -i), name=self[dt], rule=observed_rule)
|
|
71
70
|
|
|
72
71
|
def _populate_public_holidays(self):
|
|
73
72
|
# Weekend used to be THU, FRI before June 28th, 2013.
|
|
@@ -12,12 +12,25 @@
|
|
|
12
12
|
|
|
13
13
|
import warnings
|
|
14
14
|
from datetime import date
|
|
15
|
-
from datetime import timedelta as td
|
|
16
15
|
from gettext import gettext as tr
|
|
17
16
|
from typing import Dict, Set
|
|
18
17
|
|
|
19
18
|
from holidays.calendars import _CustomChineseHolidays
|
|
20
|
-
from holidays.calendars.gregorian import
|
|
19
|
+
from holidays.calendars.gregorian import (
|
|
20
|
+
JAN,
|
|
21
|
+
FEB,
|
|
22
|
+
MAR,
|
|
23
|
+
APR,
|
|
24
|
+
MAY,
|
|
25
|
+
JUN,
|
|
26
|
+
JUL,
|
|
27
|
+
AUG,
|
|
28
|
+
SEP,
|
|
29
|
+
OCT,
|
|
30
|
+
NOV,
|
|
31
|
+
DEC,
|
|
32
|
+
_timedelta,
|
|
33
|
+
)
|
|
21
34
|
from holidays.constants import BANK, PUBLIC
|
|
22
35
|
from holidays.groups import (
|
|
23
36
|
ChineseCalendarHolidays,
|
|
@@ -115,10 +128,10 @@ class SouthKorea(
|
|
|
115
128
|
name = self.tr(name)
|
|
116
129
|
for dt_alt in (
|
|
117
130
|
# The day preceding %s.
|
|
118
|
-
self._add_holiday(self.tr("%s 전날") % name, dt
|
|
131
|
+
self._add_holiday(self.tr("%s 전날") % name, _timedelta(dt, -1)),
|
|
119
132
|
dt,
|
|
120
133
|
# The second day of %s.
|
|
121
|
-
self._add_holiday(self.tr("%s 다음날") % name, dt +
|
|
134
|
+
self._add_holiday(self.tr("%s 다음날") % name, _timedelta(dt, +1)),
|
|
122
135
|
):
|
|
123
136
|
three_days_holidays[dt_alt] = name
|
|
124
137
|
|
holidays/countries/sweden.py
CHANGED
|
@@ -10,10 +10,9 @@
|
|
|
10
10
|
# Website: https://github.com/vacanza/python-holidays
|
|
11
11
|
# License: MIT (see LICENSE file)
|
|
12
12
|
|
|
13
|
-
from datetime import timedelta as td
|
|
14
13
|
from gettext import gettext as tr
|
|
15
14
|
|
|
16
|
-
from holidays.calendars.gregorian import _get_all_sundays
|
|
15
|
+
from holidays.calendars.gregorian import _timedelta, _get_all_sundays
|
|
17
16
|
from holidays.groups import ChristianHolidays, InternationalHolidays
|
|
18
17
|
from holidays.holiday_base import HolidayBase
|
|
19
18
|
|
|
@@ -101,7 +100,7 @@ class Sweden(HolidayBase, ChristianHolidays, InternationalHolidays):
|
|
|
101
100
|
)
|
|
102
101
|
|
|
103
102
|
# Midsummer Day.
|
|
104
|
-
self._add_holiday(tr("Midsommardagen"), dt +
|
|
103
|
+
self._add_holiday(tr("Midsommardagen"), _timedelta(dt, +1))
|
|
105
104
|
|
|
106
105
|
# All Saints' Day.
|
|
107
106
|
self._add_holiday_1st_sat_from_oct_31(tr("Alla helgons dag"))
|
|
@@ -10,10 +10,9 @@
|
|
|
10
10
|
# Website: https://github.com/vacanza/python-holidays
|
|
11
11
|
# License: MIT (see LICENSE file)
|
|
12
12
|
|
|
13
|
-
from datetime import timedelta as td
|
|
14
13
|
from gettext import gettext as tr
|
|
15
14
|
|
|
16
|
-
from holidays.calendars.gregorian import APR, THU, _get_nth_weekday_of_month
|
|
15
|
+
from holidays.calendars.gregorian import APR, THU, _timedelta, _get_nth_weekday_of_month
|
|
17
16
|
from holidays.constants import HALF_DAY, OPTIONAL, PUBLIC
|
|
18
17
|
from holidays.groups import ChristianHolidays, InternationalHolidays
|
|
19
18
|
from holidays.holiday_base import HolidayBase
|
|
@@ -202,7 +201,7 @@ class Switzerland(HolidayBase, ChristianHolidays, InternationalHolidays):
|
|
|
202
201
|
self._add_holiday(
|
|
203
202
|
# Battle of Naefels Victory Day.
|
|
204
203
|
tr("Näfelser Fahrt"),
|
|
205
|
-
dt +
|
|
204
|
+
_timedelta(dt, +7) if dt == _timedelta(self._easter_sunday, -3) else dt,
|
|
206
205
|
)
|
|
207
206
|
|
|
208
207
|
self._add_good_friday(tr("Karfreitag"))
|
holidays/financial/__init__.py
CHANGED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# holidays
|
|
2
|
+
# --------
|
|
3
|
+
# A fast, efficient Python library for generating country, province and state
|
|
4
|
+
# specific sets of holidays on the fly. It aims to make determining whether a
|
|
5
|
+
# specific date is a holiday as fast and flexible as possible.
|
|
6
|
+
#
|
|
7
|
+
# Authors: Vacanza Team and individual contributors (see AUTHORS file)
|
|
8
|
+
# dr-prodigy <dr.prodigy.github@gmail.com> (c) 2017-2023
|
|
9
|
+
# ryanss <ryanssdev@icloud.com> (c) 2014-2017
|
|
10
|
+
# Website: https://github.com/vacanza/python-holidays
|
|
11
|
+
# License: MIT (see LICENSE file)
|
|
12
|
+
|
|
13
|
+
from holidays.groups import ChristianHolidays, InternationalHolidays
|
|
14
|
+
from holidays.observed_holiday_base import ObservedHolidayBase, SAT_TO_NONE, SUN_TO_NEXT_MON
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class ICEFuturesEurope(ObservedHolidayBase, ChristianHolidays, InternationalHolidays):
|
|
18
|
+
"""
|
|
19
|
+
References:
|
|
20
|
+
- https://www.ice.com/publicdocs/futures/Trading_Schedule_Migrated_Liffe_Contracts.pdf
|
|
21
|
+
- https://www.ice.com/publicdocs/Trading_Schedule.pdf
|
|
22
|
+
- https://web.archive.org/web/20230927015846/https://www.ice.com/publicdocs/Trading_Schedule.pdf
|
|
23
|
+
- https://web.archive.org/web/20211022183728/https://www.ice.com/publicdocs/Trading_Schedule.pdf
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
market = "IFEU"
|
|
27
|
+
|
|
28
|
+
def __init__(self, *args, **kwargs):
|
|
29
|
+
ChristianHolidays.__init__(self)
|
|
30
|
+
InternationalHolidays.__init__(self)
|
|
31
|
+
kwargs.setdefault("observed_rule", SAT_TO_NONE + SUN_TO_NEXT_MON)
|
|
32
|
+
super().__init__(*args, **kwargs)
|
|
33
|
+
|
|
34
|
+
def _populate(self, year):
|
|
35
|
+
if year <= 2013:
|
|
36
|
+
return None
|
|
37
|
+
super()._populate(year)
|
|
38
|
+
|
|
39
|
+
self._move_holiday(self._add_new_years_day("New Year's Day"))
|
|
40
|
+
|
|
41
|
+
self._add_good_friday("Good Friday")
|
|
42
|
+
|
|
43
|
+
self._move_holiday(self._add_christmas_day("Christmas Day"))
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class IFEU(ICEFuturesEurope):
|
|
47
|
+
pass
|
|
@@ -11,9 +11,22 @@
|
|
|
11
11
|
# License: MIT (see LICENSE file)
|
|
12
12
|
|
|
13
13
|
from datetime import date
|
|
14
|
-
from datetime import timedelta as td
|
|
15
14
|
|
|
16
|
-
from holidays.calendars.gregorian import
|
|
15
|
+
from holidays.calendars.gregorian import (
|
|
16
|
+
JAN,
|
|
17
|
+
FEB,
|
|
18
|
+
MAR,
|
|
19
|
+
APR,
|
|
20
|
+
MAY,
|
|
21
|
+
JUN,
|
|
22
|
+
JUL,
|
|
23
|
+
AUG,
|
|
24
|
+
SEP,
|
|
25
|
+
OCT,
|
|
26
|
+
NOV,
|
|
27
|
+
DEC,
|
|
28
|
+
_timedelta,
|
|
29
|
+
)
|
|
17
30
|
from holidays.groups import ChristianHolidays, InternationalHolidays, StaticHolidays
|
|
18
31
|
from holidays.observed_holiday_base import ObservedHolidayBase, SAT_TO_PREV_FRI, SUN_TO_NEXT_MON
|
|
19
32
|
|
|
@@ -114,7 +127,7 @@ class NewYorkStockExchange(
|
|
|
114
127
|
# Beginning of WWI.
|
|
115
128
|
begin = date(year, JUL, 31)
|
|
116
129
|
end = date(year, NOV, 27)
|
|
117
|
-
for dt in (begin
|
|
130
|
+
for dt in (_timedelta(begin, n) for n in range((end - begin).days + 1)):
|
|
118
131
|
if self._is_weekend(dt) or dt in self:
|
|
119
132
|
continue
|
|
120
133
|
self._add_holiday("World War I", dt)
|
|
@@ -122,7 +135,7 @@ class NewYorkStockExchange(
|
|
|
122
135
|
begin = date(year, JUN, 12)
|
|
123
136
|
end = date(year, DEC, 24)
|
|
124
137
|
# Wednesday special holiday.
|
|
125
|
-
for dt in (begin
|
|
138
|
+
for dt in (_timedelta(begin, n) for n in range(0, (end - begin).days + 1, 7)):
|
|
126
139
|
self._add_holiday("Paper Crisis", dt)
|
|
127
140
|
|
|
128
141
|
|
holidays/groups/chinese.py
CHANGED
|
@@ -11,11 +11,10 @@
|
|
|
11
11
|
# License: MIT (see LICENSE file)
|
|
12
12
|
|
|
13
13
|
from datetime import date
|
|
14
|
-
from datetime import timedelta as td
|
|
15
14
|
from typing import Optional, Tuple
|
|
16
15
|
|
|
17
16
|
from holidays.calendars import _ChineseLunisolar
|
|
18
|
-
from holidays.calendars.gregorian import APR
|
|
17
|
+
from holidays.calendars.gregorian import APR, _timedelta
|
|
19
18
|
|
|
20
19
|
|
|
21
20
|
class ChineseCalendarHolidays:
|
|
@@ -61,7 +60,7 @@ class ChineseCalendarHolidays:
|
|
|
61
60
|
dt, is_estimated = dt_estimated
|
|
62
61
|
|
|
63
62
|
if days_delta != 0:
|
|
64
|
-
dt
|
|
63
|
+
dt = _timedelta(dt, days_delta)
|
|
65
64
|
|
|
66
65
|
return self._add_holiday(
|
|
67
66
|
self.tr(estimated_label) % self.tr(name)
|
holidays/groups/christian.py
CHANGED
|
@@ -11,11 +11,10 @@
|
|
|
11
11
|
# License: MIT (see LICENSE file)
|
|
12
12
|
|
|
13
13
|
from datetime import date
|
|
14
|
-
from datetime import timedelta as td
|
|
15
14
|
|
|
16
15
|
from dateutil.easter import EASTER_ORTHODOX, EASTER_WESTERN, easter
|
|
17
16
|
|
|
18
|
-
from holidays.calendars.gregorian import GREGORIAN_CALENDAR, JAN, DEC
|
|
17
|
+
from holidays.calendars.gregorian import GREGORIAN_CALENDAR, JAN, DEC, _timedelta
|
|
19
18
|
from holidays.calendars.julian import JULIAN_CALENDAR
|
|
20
19
|
from holidays.calendars.julian_revised import JULIAN_REVISED_CALENDAR
|
|
21
20
|
|
|
@@ -123,7 +122,7 @@ class ChristianHolidays:
|
|
|
123
122
|
Day, or sometimes Holy Thursday.
|
|
124
123
|
https://en.wikipedia.org/wiki/Feast_of_the_Ascension
|
|
125
124
|
"""
|
|
126
|
-
return self._add_holiday(name, self._easter_sunday +
|
|
125
|
+
return self._add_holiday(name, _timedelta(self._easter_sunday, +39))
|
|
127
126
|
|
|
128
127
|
def _add_ash_monday(self, name) -> date:
|
|
129
128
|
"""
|
|
@@ -133,7 +132,7 @@ class ChristianHolidays:
|
|
|
133
132
|
or Green Monday. The first day of Great Lent.
|
|
134
133
|
https://en.wikipedia.org/wiki/Clean_Monday
|
|
135
134
|
"""
|
|
136
|
-
return self._add_holiday(name, self._easter_sunday
|
|
135
|
+
return self._add_holiday(name, _timedelta(self._easter_sunday, -48))
|
|
137
136
|
|
|
138
137
|
def _add_ash_wednesday(self, name) -> date:
|
|
139
138
|
"""
|
|
@@ -142,7 +141,7 @@ class ChristianHolidays:
|
|
|
142
141
|
A holy day of prayer and fasting. It marks the beginning of Lent.
|
|
143
142
|
https://en.wikipedia.org/wiki/Ash_Wednesday
|
|
144
143
|
"""
|
|
145
|
-
return self._add_holiday(name, self._easter_sunday
|
|
144
|
+
return self._add_holiday(name, _timedelta(self._easter_sunday, -46))
|
|
146
145
|
|
|
147
146
|
def _add_assumption_of_mary_day(self, name, calendar=None) -> date:
|
|
148
147
|
"""
|
|
@@ -182,7 +181,7 @@ class ChristianHolidays:
|
|
|
182
181
|
the liturgical season of Lent.
|
|
183
182
|
https://en.wikipedia.org/wiki/Carnival
|
|
184
183
|
"""
|
|
185
|
-
return self._add_holiday(name, self._easter_sunday
|
|
184
|
+
return self._add_holiday(name, _timedelta(self._easter_sunday, -48))
|
|
186
185
|
|
|
187
186
|
def _add_carnival_tuesday(self, name) -> date:
|
|
188
187
|
"""
|
|
@@ -192,7 +191,7 @@ class ChristianHolidays:
|
|
|
192
191
|
the liturgical season of Lent.
|
|
193
192
|
https://en.wikipedia.org/wiki/Carnival
|
|
194
193
|
"""
|
|
195
|
-
return self._add_holiday(name, self._easter_sunday
|
|
194
|
+
return self._add_holiday(name, _timedelta(self._easter_sunday, -47))
|
|
196
195
|
|
|
197
196
|
def _add_christmas_day(self, name, calendar=None) -> date:
|
|
198
197
|
"""
|
|
@@ -212,7 +211,7 @@ class ChristianHolidays:
|
|
|
212
211
|
https://en.wikipedia.org/wiki/Boxing_Day
|
|
213
212
|
https://en.wikipedia.org/wiki/Christmas
|
|
214
213
|
"""
|
|
215
|
-
return self._add_holiday(name, self.__get_christmas_day(calendar) +
|
|
214
|
+
return self._add_holiday(name, _timedelta(self.__get_christmas_day(calendar), +1))
|
|
216
215
|
|
|
217
216
|
def _add_christmas_day_three(self, name, calendar=None) -> date:
|
|
218
217
|
"""
|
|
@@ -221,7 +220,7 @@ class ChristianHolidays:
|
|
|
221
220
|
A holiday celebrated 2 days after Christmas Day (in some countries).
|
|
222
221
|
https://en.wikipedia.org/wiki/Christmas
|
|
223
222
|
"""
|
|
224
|
-
return self._add_holiday(name, self.__get_christmas_day(calendar) +
|
|
223
|
+
return self._add_holiday(name, _timedelta(self.__get_christmas_day(calendar), +2))
|
|
225
224
|
|
|
226
225
|
def _add_christmas_eve(self, name, calendar=None) -> date:
|
|
227
226
|
"""
|
|
@@ -231,7 +230,7 @@ class ChristianHolidays:
|
|
|
231
230
|
the festival commemorating the birth of Jesus Christ.
|
|
232
231
|
https://en.wikipedia.org/wiki/Christmas_Eve
|
|
233
232
|
"""
|
|
234
|
-
return self._add_holiday(name, self.__get_christmas_day(calendar)
|
|
233
|
+
return self._add_holiday(name, _timedelta(self.__get_christmas_day(calendar), -1))
|
|
235
234
|
|
|
236
235
|
def _add_corpus_christi_day(self, name) -> date:
|
|
237
236
|
"""
|
|
@@ -243,7 +242,7 @@ class ChristianHolidays:
|
|
|
243
242
|
of Jesus Christ in the elements of the Eucharist.
|
|
244
243
|
https://en.wikipedia.org/wiki/Feast_of_Corpus_Christi
|
|
245
244
|
"""
|
|
246
|
-
return self._add_holiday(name, self._easter_sunday +
|
|
245
|
+
return self._add_holiday(name, _timedelta(self._easter_sunday, +60))
|
|
247
246
|
|
|
248
247
|
def _add_easter_monday(self, name, calendar=None) -> date:
|
|
249
248
|
"""
|
|
@@ -254,7 +253,7 @@ class ChristianHolidays:
|
|
|
254
253
|
some countries.
|
|
255
254
|
https://en.wikipedia.org/wiki/Easter_Monday
|
|
256
255
|
"""
|
|
257
|
-
return self._add_holiday(name, self.__get_easter_sunday(calendar) +
|
|
256
|
+
return self._add_holiday(name, _timedelta(self.__get_easter_sunday(calendar), +1))
|
|
258
257
|
|
|
259
258
|
def _add_easter_sunday(self, name, calendar=None) -> date:
|
|
260
259
|
"""
|
|
@@ -294,7 +293,7 @@ class ChristianHolidays:
|
|
|
294
293
|
Great Friday, Great and Holy Friday.
|
|
295
294
|
https://en.wikipedia.org/wiki/Good_Friday
|
|
296
295
|
"""
|
|
297
|
-
return self._add_holiday(name, self.__get_easter_sunday(calendar)
|
|
296
|
+
return self._add_holiday(name, _timedelta(self.__get_easter_sunday(calendar), -2))
|
|
298
297
|
|
|
299
298
|
def _add_holy_saturday(self, name) -> date:
|
|
300
299
|
"""
|
|
@@ -303,7 +302,7 @@ class ChristianHolidays:
|
|
|
303
302
|
Great and Holy Saturday is a day between Good Friday and Easter Sunday.
|
|
304
303
|
https://en.wikipedia.org/wiki/Holy_Saturday
|
|
305
304
|
"""
|
|
306
|
-
return self._add_holiday(name, self._easter_sunday
|
|
305
|
+
return self._add_holiday(name, _timedelta(self._easter_sunday, -1))
|
|
307
306
|
|
|
308
307
|
def _add_holy_thursday(self, name) -> date:
|
|
309
308
|
"""
|
|
@@ -314,7 +313,7 @@ class ChristianHolidays:
|
|
|
314
313
|
Jesus Christ with the Apostles, as described in the canonical gospels.
|
|
315
314
|
https://en.wikipedia.org/wiki/Maundy_Thursday
|
|
316
315
|
"""
|
|
317
|
-
return self._add_holiday(name, self._easter_sunday
|
|
316
|
+
return self._add_holiday(name, _timedelta(self._easter_sunday, -3))
|
|
318
317
|
|
|
319
318
|
def _add_immaculate_conception_day(self, name) -> date:
|
|
320
319
|
"""
|
|
@@ -345,7 +344,7 @@ class ChristianHolidays:
|
|
|
345
344
|
Palm Sunday marks the first day of Holy Week.
|
|
346
345
|
https://en.wikipedia.org/wiki/Palm_Sunday
|
|
347
346
|
"""
|
|
348
|
-
return self._add_holiday(name, self._easter_sunday
|
|
347
|
+
return self._add_holiday(name, _timedelta(self._easter_sunday, -7))
|
|
349
348
|
|
|
350
349
|
def _add_rejoicing_day(self, name) -> date:
|
|
351
350
|
"""
|
|
@@ -356,7 +355,7 @@ class ChristianHolidays:
|
|
|
356
355
|
Pascha (Easter).In Ukrainian tradition it is called Provody.
|
|
357
356
|
https://en.wikipedia.org/wiki/Radonitsa
|
|
358
357
|
"""
|
|
359
|
-
return self._add_holiday(name, self._easter_sunday +
|
|
358
|
+
return self._add_holiday(name, _timedelta(self._easter_sunday, +9))
|
|
360
359
|
|
|
361
360
|
def _add_saint_georges_day(self, name) -> date:
|
|
362
361
|
"""
|
|
@@ -418,7 +417,7 @@ class ChristianHolidays:
|
|
|
418
417
|
https://en.wikipedia.org/wiki/Pentecost
|
|
419
418
|
https://en.wikipedia.org/wiki/Whit_Monday
|
|
420
419
|
"""
|
|
421
|
-
return self._add_holiday(name, self._easter_sunday +
|
|
420
|
+
return self._add_holiday(name, _timedelta(self._easter_sunday, +50))
|
|
422
421
|
|
|
423
422
|
def _add_whit_sunday(self, name) -> date:
|
|
424
423
|
"""
|
|
@@ -430,4 +429,4 @@ class ChristianHolidays:
|
|
|
430
429
|
Feast of Weeks.
|
|
431
430
|
https://en.wikipedia.org/wiki/Pentecost
|
|
432
431
|
"""
|
|
433
|
-
return self._add_holiday(name, self._easter_sunday +
|
|
432
|
+
return self._add_holiday(name, _timedelta(self._easter_sunday, +49))
|
holidays/groups/islamic.py
CHANGED
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
# License: MIT (see LICENSE file)
|
|
12
12
|
|
|
13
13
|
from datetime import date
|
|
14
|
-
from datetime import timedelta as td
|
|
15
14
|
from typing import Iterable, Set, Tuple
|
|
16
15
|
|
|
17
16
|
from holidays.calendars import _IslamicLunar
|
|
17
|
+
from holidays.calendars.gregorian import _timedelta
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
class IslamicHolidays:
|
|
@@ -264,7 +264,7 @@ class IslamicHolidays:
|
|
|
264
264
|
estimated_label = getattr(self, "estimated_label", "%s (estimated)")
|
|
265
265
|
for dt, is_estimated in dates:
|
|
266
266
|
if days_delta != 0:
|
|
267
|
-
dt
|
|
267
|
+
dt = _timedelta(dt, days_delta)
|
|
268
268
|
|
|
269
269
|
dt = self._add_holiday(
|
|
270
270
|
self.tr(estimated_label) % self.tr(name) if is_estimated else name, dt
|
holidays/groups/persian.py
CHANGED
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
# License: MIT (see LICENSE file)
|
|
12
12
|
|
|
13
13
|
from datetime import date
|
|
14
|
-
from datetime import timedelta as td
|
|
15
14
|
from typing import Optional
|
|
16
15
|
|
|
16
|
+
from holidays.calendars.gregorian import _timedelta
|
|
17
17
|
from holidays.calendars.persian import _Persian
|
|
18
18
|
|
|
19
19
|
|
|
@@ -142,5 +142,5 @@ class PersianCalendarHolidays:
|
|
|
142
142
|
if dt is None:
|
|
143
143
|
return None
|
|
144
144
|
if days_delta != 0:
|
|
145
|
-
dt
|
|
145
|
+
dt = _timedelta(dt, days_delta)
|
|
146
146
|
return self._add_holiday(name, dt)
|
holidays/helpers.py
CHANGED
|
@@ -24,13 +24,19 @@ def _normalize_arguments(cls, value):
|
|
|
24
24
|
A set created from `value` argument.
|
|
25
25
|
|
|
26
26
|
"""
|
|
27
|
+
if value is None:
|
|
28
|
+
return set()
|
|
29
|
+
|
|
27
30
|
if isinstance(value, cls):
|
|
28
31
|
return {value}
|
|
29
32
|
|
|
30
|
-
|
|
33
|
+
try:
|
|
34
|
+
return {v if isinstance(v, cls) else cls(v) for v in value}
|
|
35
|
+
except TypeError: # non-iterable
|
|
36
|
+
return {value if isinstance(value, cls) else cls(value)}
|
|
31
37
|
|
|
32
38
|
|
|
33
|
-
def _normalize_tuple(
|
|
39
|
+
def _normalize_tuple(value):
|
|
34
40
|
"""Normalize tuple.
|
|
35
41
|
|
|
36
42
|
:param data:
|
|
@@ -40,4 +46,4 @@ def _normalize_tuple(data):
|
|
|
40
46
|
An unchanged object for tuple of tuples, e.g., ((JAN, 10), (DEC, 31)).
|
|
41
47
|
An object put into a tuple otherwise, e.g., ((JAN, 10),).
|
|
42
48
|
"""
|
|
43
|
-
return
|
|
49
|
+
return value if not value or isinstance(value[0], tuple) else (value,)
|
holidays/holiday_base.py
CHANGED
|
@@ -31,6 +31,7 @@ from holidays.calendars.gregorian import (
|
|
|
31
31
|
FRI,
|
|
32
32
|
SAT,
|
|
33
33
|
SUN,
|
|
34
|
+
_timedelta,
|
|
34
35
|
_get_nth_weekday_from,
|
|
35
36
|
_get_nth_weekday_of_month,
|
|
36
37
|
DAYS,
|
|
@@ -479,8 +480,10 @@ class HolidayBase(Dict[date, str]):
|
|
|
479
480
|
):
|
|
480
481
|
return lambda name: self._add_holiday(
|
|
481
482
|
name,
|
|
482
|
-
|
|
483
|
-
|
|
483
|
+
_timedelta(
|
|
484
|
+
self._easter_sunday,
|
|
485
|
+
+int(days) if delta_direction == "past" else -int(days),
|
|
486
|
+
),
|
|
484
487
|
)
|
|
485
488
|
|
|
486
489
|
# Handle <n> day(s) <past/prior> <last/<nth> <weekday> of <month> patterns (e.g.,
|
|
@@ -500,13 +503,15 @@ class HolidayBase(Dict[date, str]):
|
|
|
500
503
|
):
|
|
501
504
|
return lambda name: self._add_holiday(
|
|
502
505
|
name,
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
506
|
+
_timedelta(
|
|
507
|
+
_get_nth_weekday_of_month(
|
|
508
|
+
-1 if number == "last" else int(number[0]),
|
|
509
|
+
WEEKDAYS[weekday],
|
|
510
|
+
MONTHS[month],
|
|
511
|
+
self._year,
|
|
512
|
+
),
|
|
513
|
+
+int(days) if delta_direction == "past" else -int(days),
|
|
514
|
+
),
|
|
510
515
|
)
|
|
511
516
|
|
|
512
517
|
# Handle <nth> <weekday> <before/from> <month> <day> patterns (e.g.,
|
|
@@ -557,7 +562,7 @@ class HolidayBase(Dict[date, str]):
|
|
|
557
562
|
|
|
558
563
|
days_in_range = []
|
|
559
564
|
for delta_days in range(0, date_diff.days, step):
|
|
560
|
-
day = start
|
|
565
|
+
day = _timedelta(start, delta_days)
|
|
561
566
|
if day in self:
|
|
562
567
|
days_in_range.append(day)
|
|
563
568
|
|
|
@@ -963,9 +968,9 @@ class HolidayBase(Dict[date, str]):
|
|
|
963
968
|
direction = +1 if n > 0 else -1
|
|
964
969
|
dt = self.__keytransform__(key)
|
|
965
970
|
for _ in range(abs(n)):
|
|
966
|
-
dt
|
|
971
|
+
dt = _timedelta(dt, direction)
|
|
967
972
|
while not self.is_workday(dt):
|
|
968
|
-
dt
|
|
973
|
+
dt = _timedelta(dt, direction)
|
|
969
974
|
return dt
|
|
970
975
|
|
|
971
976
|
def get_workdays_number(self, key1: DateLike, key2: DateLike) -> int:
|
|
@@ -977,9 +982,7 @@ class HolidayBase(Dict[date, str]):
|
|
|
977
982
|
if dt1 > dt2:
|
|
978
983
|
dt1, dt2 = dt2, dt1
|
|
979
984
|
|
|
980
|
-
return sum(
|
|
981
|
-
self.is_workday(dt1 + timedelta(days=n)) for n in range(1, (dt2 - dt1).days + 1)
|
|
982
|
-
)
|
|
985
|
+
return sum(self.is_workday(_timedelta(dt1, n)) for n in range(1, (dt2 - dt1).days + 1))
|
|
983
986
|
|
|
984
987
|
def is_workday(self, key: DateLike) -> bool:
|
|
985
988
|
"""Return True if date is a working day (not a holiday or a weekend)."""
|
|
Binary file
|