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.
Files changed (46) hide show
  1. holidays/__init__.py +1 -1
  2. holidays/calendars/gregorian.py +22 -7
  3. holidays/calendars/persian.py +3 -2
  4. holidays/calendars/thai.py +24 -20
  5. holidays/countries/angola.py +2 -2
  6. holidays/countries/aruba.py +2 -3
  7. holidays/countries/cambodia.py +7 -8
  8. holidays/countries/canada.py +2 -1
  9. holidays/countries/curacao.py +3 -4
  10. holidays/countries/finland.py +2 -2
  11. holidays/countries/hongkong.py +398 -133
  12. holidays/countries/israel.py +13 -13
  13. holidays/countries/italy.py +2 -4
  14. holidays/countries/japan.py +17 -6
  15. holidays/countries/jersey.py +2 -2
  16. holidays/countries/laos.py +7 -23
  17. holidays/countries/madagascar.py +2 -3
  18. holidays/countries/malaysia.py +545 -235
  19. holidays/countries/netherlands.py +2 -3
  20. holidays/countries/new_zealand.py +5 -5
  21. holidays/countries/saudi_arabia.py +2 -3
  22. holidays/countries/south_korea.py +17 -4
  23. holidays/countries/sweden.py +2 -3
  24. holidays/countries/switzerland.py +2 -3
  25. holidays/financial/__init__.py +1 -0
  26. holidays/financial/ice_futures_europe.py +47 -0
  27. holidays/financial/ny_stock_exchange.py +17 -4
  28. holidays/groups/chinese.py +2 -3
  29. holidays/groups/christian.py +18 -19
  30. holidays/groups/islamic.py +2 -2
  31. holidays/groups/persian.py +2 -2
  32. holidays/helpers.py +9 -3
  33. holidays/holiday_base.py +18 -15
  34. holidays/locale/en_US/LC_MESSAGES/MY.mo +0 -0
  35. holidays/locale/en_US/LC_MESSAGES/MY.po +250 -0
  36. holidays/locale/ms_MY/LC_MESSAGES/MY.mo +0 -0
  37. holidays/locale/ms_MY/LC_MESSAGES/MY.po +250 -0
  38. holidays/mixins.py +31 -0
  39. holidays/observed_holiday_base.py +25 -13
  40. holidays/registry.py +1 -0
  41. {holidays-0.48.dist-info → holidays-0.49.dist-info}/METADATA +7 -4
  42. {holidays-0.48.dist-info → holidays-0.49.dist-info}/RECORD +46 -40
  43. {holidays-0.48.dist-info → holidays-0.49.dist-info}/AUTHORS +0 -0
  44. {holidays-0.48.dist-info → holidays-0.49.dist-info}/LICENSE +0 -0
  45. {holidays-0.48.dist-info → holidays-0.49.dist-info}/WHEEL +0 -0
  46. {holidays-0.48.dist-info → holidays-0.49.dist-info}/top_level.txt +0 -0
holidays/__init__.py CHANGED
@@ -17,7 +17,7 @@ from holidays.holiday_base import *
17
17
  from holidays.registry import EntityLoader
18
18
  from holidays.utils import *
19
19
 
20
- __version__ = "0.48"
20
+ __version__ = "0.49"
21
21
 
22
22
 
23
23
  EntityLoader.load("countries", globals())
@@ -11,7 +11,6 @@
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
  GREGORIAN_CALENDAR = "GREGORIAN_CALENDAR"
17
16
 
@@ -30,6 +29,19 @@ MONTHS = {
30
29
  WEEKDAYS = {w: i for i, w in enumerate(("mon", "tue", "wed", "thu", "fri", "sat", "sun"))}
31
30
 
32
31
 
32
+ # Holiday names.
33
+ CHRISTMAS = "christmas"
34
+ WINTER_SOLSTICE = "winter_solstice"
35
+
36
+
37
+ def _timedelta(dt: date, days: int = 0) -> date:
38
+ """
39
+ Return date that is `days` days after (days > 0) or before (days < 0) specified date.
40
+ """
41
+
42
+ return date.fromordinal(dt.toordinal() + days)
43
+
44
+
33
45
  def _get_nth_weekday_from(n: int, weekday: int, from_dt: date) -> date:
34
46
  """
35
47
  Return date of a n-th weekday before a specific date
@@ -39,10 +51,13 @@ def _get_nth_weekday_from(n: int, weekday: int, from_dt: date) -> date:
39
51
  Examples: 1st Monday, 2nd Saturday, etc).
40
52
  """
41
53
 
42
- return from_dt + td(
43
- days=(n - 1) * 7 + (weekday - from_dt.weekday()) % 7
44
- if n > 0
45
- else (n + 1) * 7 - (from_dt.weekday() - weekday) % 7
54
+ return _timedelta(
55
+ from_dt,
56
+ (
57
+ (n - 1) * 7 + (weekday - from_dt.weekday()) % 7
58
+ if n > 0
59
+ else (n + 1) * 7 - (from_dt.weekday() - weekday) % 7
60
+ ),
46
61
  )
47
62
 
48
63
 
@@ -61,7 +76,7 @@ def _get_nth_weekday_of_month(n: int, weekday: int, month: int, year: int) -> da
61
76
  if month > 12:
62
77
  month = 1
63
78
  year += 1
64
- start_date = date(year, month, 1) + td(days=-1)
79
+ start_date = _timedelta(date(year, month, 1), -1)
65
80
  else:
66
81
  start_date = date(year, month, 1)
67
82
 
@@ -77,4 +92,4 @@ def _get_nth_weekday_of_month(n: int, weekday: int, month: int, year: int) -> da
77
92
  def _get_all_sundays(year):
78
93
  first_sunday = _get_nth_weekday_of_month(1, SUN, JAN, year)
79
94
  for n in range(0, (date(year, DEC, 31) - first_sunday).days + 1, 7):
80
- yield first_sunday + td(days=n)
95
+ yield _timedelta(first_sunday, n)
@@ -11,9 +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
16
15
 
16
+ from holidays.calendars.gregorian import _timedelta
17
+
17
18
 
18
19
  class _Persian:
19
20
  """
@@ -54,4 +55,4 @@ class _Persian:
54
55
 
55
56
  m = j_month - 1
56
57
  delta = (31 * m if m < 6 else 186 + 30 * (m - 6)) + j_day - 1
57
- return start_date + td(days=delta)
58
+ return _timedelta(start_date, delta)
@@ -11,10 +11,11 @@
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 functools import lru_cache
16
15
  from typing import Optional
17
16
 
17
+ from holidays.calendars.gregorian import _timedelta
18
+
18
19
  KHMER_CALENDAR = "KHMER_CALENDAR"
19
20
  THAI_CALENDAR = "THAI_CALENDAR"
20
21
 
@@ -230,7 +231,7 @@ class _ThaiLunisolar:
230
231
  elif iter_year in _ThaiLunisolar.ATHIKAWAN_YEARS_GREGORIAN:
231
232
  delta_days += 1
232
233
 
233
- return _ThaiLunisolar.START_DATE + td(days=delta_days)
234
+ return _timedelta(_ThaiLunisolar.START_DATE, delta_days)
234
235
 
235
236
  def makha_bucha_date(self, year: int, calendar=None) -> Optional[date]:
236
237
  """
@@ -267,13 +268,14 @@ class _ThaiLunisolar:
267
268
  if not start_date:
268
269
  return None
269
270
 
270
- return start_date + td(
271
- days=+102
271
+ return _timedelta(
272
+ start_date,
273
+ +102
272
274
  if (
273
275
  year in _ThaiLunisolar.ATHIKAMAT_YEARS_GREGORIAN
274
276
  and not self.__is_khmer_calendar(calendar)
275
277
  )
276
- else +73
278
+ else +73,
277
279
  )
278
280
 
279
281
  def visakha_bucha_date(self, year: int, calendar=None) -> Optional[date]:
@@ -310,13 +312,14 @@ class _ThaiLunisolar:
310
312
  if not start_date:
311
313
  return None
312
314
 
313
- return start_date + td(
314
- days=+191
315
+ return _timedelta(
316
+ start_date,
317
+ +191
315
318
  if (
316
319
  year in _ThaiLunisolar.ATHIKAMAT_YEARS_GREGORIAN
317
320
  and not self.__is_khmer_calendar(calendar)
318
321
  )
319
- else +161
322
+ else +161,
320
323
  )
321
324
 
322
325
  def preah_neangkoal_date(self, year: int) -> Optional[date]:
@@ -346,7 +349,7 @@ class _ThaiLunisolar:
346
349
  if not start_date:
347
350
  return None
348
351
 
349
- return start_date + td(days=+165)
352
+ return _timedelta(start_date, +165)
350
353
 
351
354
  def atthami_bucha_date(self, year: int, calendar=None) -> Optional[date]:
352
355
  """
@@ -383,13 +386,14 @@ class _ThaiLunisolar:
383
386
  if not start_date:
384
387
  return None
385
388
 
386
- return start_date + td(
387
- days=+199
389
+ return _timedelta(
390
+ start_date,
391
+ +199
388
392
  if (
389
393
  year in _ThaiLunisolar.ATHIKAMAT_YEARS_GREGORIAN
390
394
  and not self.__is_khmer_calendar(calendar)
391
395
  )
392
- else +169
396
+ else +169,
393
397
  )
394
398
 
395
399
  def asarnha_bucha_date(self, year: int) -> Optional[date]:
@@ -430,7 +434,7 @@ class _ThaiLunisolar:
430
434
  delta_days = +221
431
435
  else:
432
436
  delta_days = +220
433
- return start_date + td(days=delta_days)
437
+ return _timedelta(start_date, delta_days)
434
438
 
435
439
  def khao_phansa_date(self, year: int) -> Optional[date]:
436
440
  """
@@ -469,7 +473,7 @@ class _ThaiLunisolar:
469
473
  delta_days = +222
470
474
  else:
471
475
  delta_days = +221
472
- return start_date + td(days=delta_days)
476
+ return _timedelta(start_date, delta_days)
473
477
 
474
478
  def boun_haw_khao_padapdin_date(self, year: int) -> Optional[date]:
475
479
  """
@@ -503,7 +507,7 @@ class _ThaiLunisolar:
503
507
  delta_days = +265
504
508
  else:
505
509
  delta_days = +264
506
- return start_date + td(days=delta_days)
510
+ return _timedelta(start_date, delta_days)
507
511
 
508
512
  def boun_haw_khao_salark_date(self, year: int) -> Optional[date]:
509
513
  """
@@ -537,7 +541,7 @@ class _ThaiLunisolar:
537
541
  delta_days = +280
538
542
  else:
539
543
  delta_days = +279
540
- return start_date + td(days=delta_days)
544
+ return _timedelta(start_date, delta_days)
541
545
 
542
546
  def pchum_ben_date(self, year: int) -> Optional[date]:
543
547
  """
@@ -571,7 +575,7 @@ class _ThaiLunisolar:
571
575
  delta_days = +295
572
576
  else:
573
577
  delta_days = +294
574
- return start_date + td(days=delta_days)
578
+ return _timedelta(start_date, delta_days)
575
579
 
576
580
  def ok_phansa_date(self, year: int) -> Optional[date]:
577
581
  """
@@ -605,7 +609,7 @@ class _ThaiLunisolar:
605
609
  delta_days = +310
606
610
  else:
607
611
  delta_days = +309
608
- return start_date + td(days=delta_days)
612
+ return _timedelta(start_date, delta_days)
609
613
 
610
614
  def boun_suang_heua_date(self, year: int) -> Optional[date]:
611
615
  """
@@ -639,7 +643,7 @@ class _ThaiLunisolar:
639
643
  delta_days = +311
640
644
  else:
641
645
  delta_days = +310
642
- return start_date + td(days=delta_days)
646
+ return _timedelta(start_date, delta_days)
643
647
 
644
648
  def loy_krathong_date(self, year: int) -> Optional[date]:
645
649
  """
@@ -673,4 +677,4 @@ class _ThaiLunisolar:
673
677
  delta_days = +339
674
678
  else:
675
679
  delta_days = +338
676
- return start_date + td(days=delta_days)
680
+ return _timedelta(start_date, delta_days)
@@ -12,7 +12,7 @@
12
12
 
13
13
  from datetime import date
14
14
  from gettext import gettext as tr
15
- from typing import Tuple
15
+ from typing import Optional, Tuple
16
16
 
17
17
  from holidays.calendars.gregorian import AUG, SEP
18
18
  from holidays.groups import ChristianHolidays, InternationalHolidays, StaticHolidays
@@ -59,7 +59,7 @@ class Angola(ObservedHolidayBase, ChristianHolidays, InternationalHolidays, Stat
59
59
  # it rolls over to the following Monday.
60
60
  return dt >= date(1996, SEP, 27)
61
61
 
62
- def _add_observed(self, dt: date, **kwargs) -> Tuple[bool, date]:
62
+ def _add_observed(self, dt: date, **kwargs) -> Tuple[bool, Optional[date]]:
63
63
  # As per Law # #11/18, from 2018/9/10, when public holiday falls on Tuesday or Thursday,
64
64
  # the Monday or Friday is also a holiday.
65
65
  kwargs.setdefault(
@@ -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.groups import ChristianHolidays, InternationalHolidays
19
18
  from holidays.holiday_base import HolidayBase
20
19
 
@@ -118,7 +117,7 @@ class Aruba(HolidayBase, ChristianHolidays, InternationalHolidays):
118
117
  else:
119
118
  dt = (AUG, 31)
120
119
  if self._is_sunday(dt):
121
- dt = date(self._year, *dt) + td(days=-1 if self._year >= 1980 else +1)
120
+ dt = _timedelta(date(self._year, *dt), -1 if self._year >= 1980 else +1)
122
121
  self._add_holiday(name, dt)
123
122
 
124
123
  # Dia di Labor/Dia di Obrero.
@@ -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 MAY, AUG, SEP
15
+ from holidays.calendars.gregorian import MAY, AUG, SEP, _timedelta
17
16
  from holidays.calendars.thai import KHMER_CALENDAR
18
17
  from holidays.groups import InternationalHolidays, StaticHolidays, ThaiCalendarHolidays
19
18
  from holidays.holiday_base import HolidayBase
@@ -98,8 +97,8 @@ class Cambodia(HolidayBase, InternationalHolidays, StaticHolidays, ThaiCalendarH
98
97
  if self._year in sangkranta_years_apr_14
99
98
  else self._add_holiday_apr_13(sangkranta)
100
99
  )
101
- self._add_holiday(sangkranta, dt + td(days=+1))
102
- self._add_holiday(sangkranta, dt + td(days=+2))
100
+ self._add_holiday(sangkranta, _timedelta(dt, +1))
101
+ self._add_holiday(sangkranta, _timedelta(dt, +2))
103
102
 
104
103
  # ទិវាពលកម្មអន្តរជាតិ
105
104
  # Status: In-Use.
@@ -253,9 +252,9 @@ class Cambodia(HolidayBase, InternationalHolidays, StaticHolidays, ThaiCalendarH
253
252
  pchum_ben = tr("ពិធីបុណ្យភ្ផុំបិណ្ឌ")
254
253
  pchum_ben_date = self._add_pchum_ben(pchum_ben)
255
254
  if pchum_ben_date:
256
- self._add_holiday(pchum_ben, pchum_ben_date + td(days=-1))
255
+ self._add_holiday(pchum_ben, _timedelta(pchum_ben_date, -1))
257
256
  if self._year >= 2017:
258
- self._add_holiday(pchum_ben, pchum_ben_date + td(days=+1))
257
+ self._add_holiday(pchum_ben, _timedelta(pchum_ben_date, +1))
259
258
 
260
259
  # ព្រះរាជពិធីបុណ្យអុំទូក បណ្តែតប្រទីប និងសំពះព្រះខែអកអំបុក
261
260
  # Status: In-Use.
@@ -265,8 +264,8 @@ class Cambodia(HolidayBase, InternationalHolidays, StaticHolidays, ThaiCalendarH
265
264
  bon_om_touk = tr("ព្រះរាជពិធីបុណ្យអុំទូក បណ្តែតប្រទីប និងសំពះព្រះខែអកអំបុក")
266
265
  bon_om_touk_date = self._add_loy_krathong(bon_om_touk)
267
266
  if bon_om_touk_date:
268
- self._add_holiday(bon_om_touk, bon_om_touk_date + td(days=-1))
269
- self._add_holiday(bon_om_touk, bon_om_touk_date + td(days=+1))
267
+ self._add_holiday(bon_om_touk, _timedelta(bon_om_touk_date, -1))
268
+ self._add_holiday(bon_om_touk, _timedelta(bon_om_touk_date, +1))
270
269
 
271
270
 
272
271
  class KH(Cambodia):
@@ -12,6 +12,7 @@
12
12
 
13
13
  from datetime import date
14
14
  from gettext import gettext as tr
15
+ from typing import Optional
15
16
 
16
17
  from holidays.calendars.gregorian import MAR, APR, JUN, JUL, SEP
17
18
  from holidays.constants import GOVERNMENT, OPTIONAL, PUBLIC
@@ -69,7 +70,7 @@ class Canada(ObservedHolidayBase, ChristianHolidays, InternationalHolidays, Stat
69
70
  kwargs.setdefault("observed_rule", SAT_SUN_TO_NEXT_MON)
70
71
  super().__init__(*args, **kwargs)
71
72
 
72
- def _get_nearest_monday(self, *args) -> date:
73
+ def _get_nearest_monday(self, *args) -> Optional[date]:
73
74
  return self._get_observed_date(date(self._year, *args), rule=ALL_TO_NEAREST_MON)
74
75
 
75
76
  def _add_statutory_holidays(self):
@@ -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, MAY
16
+ from holidays.calendars.gregorian import APR, MAY, _timedelta
18
17
  from holidays.groups import ChristianHolidays, InternationalHolidays
19
18
  from holidays.holiday_base import HolidayBase
20
19
 
@@ -90,7 +89,7 @@ class Curacao(HolidayBase, ChristianHolidays, InternationalHolidays):
90
89
  )
91
90
  dt = date(self._year, APR, 27 if self._year >= 2014 else 30)
92
91
  if self._is_sunday(dt):
93
- dt += td(days=-1 if self._year >= 1980 else +1)
92
+ dt = _timedelta(dt, -1 if self._year >= 1980 else +1)
94
93
  self._add_holiday(name, dt)
95
94
 
96
95
  # Dia di Obrero.
@@ -99,7 +98,7 @@ class Curacao(HolidayBase, ChristianHolidays, InternationalHolidays):
99
98
 
100
99
  dt = date(self._year, MAY, 1)
101
100
  if self._is_sunday(dt) or (self._is_monday(dt) and self._year <= 1979):
102
- dt += td(days=+1)
101
+ dt = _timedelta(dt, +1)
103
102
  # Labor Day
104
103
  self._add_holiday(tr("Dia di Obrero"), dt)
105
104
 
@@ -10,9 +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
 
15
+ from holidays.calendars.gregorian import _timedelta
16
16
  from holidays.groups import ChristianHolidays, InternationalHolidays
17
17
  from holidays.holiday_base import HolidayBase
18
18
 
@@ -72,7 +72,7 @@ class Finland(HolidayBase, ChristianHolidays, InternationalHolidays):
72
72
  dt = self._add_holiday_jun_23(name)
73
73
 
74
74
  # Midsummer Day.
75
- self._add_holiday(tr("Juhannuspäivä"), dt + td(days=+1))
75
+ self._add_holiday(tr("Juhannuspäivä"), _timedelta(dt, +1))
76
76
 
77
77
  # All Saints' Day.
78
78
  name = tr("Pyhäinpäivä")