holidays 0.77__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.
Files changed (32) hide show
  1. holidays/calendars/islamic.py +32 -1
  2. holidays/countries/__init__.py +1 -0
  3. holidays/countries/egypt.py +203 -47
  4. holidays/countries/germany.py +41 -0
  5. holidays/countries/indonesia.py +5 -2
  6. holidays/countries/luxembourg.py +13 -0
  7. holidays/countries/pakistan.py +7 -5
  8. holidays/countries/pitcairn_islands.py +85 -0
  9. holidays/countries/saudi_arabia.py +43 -35
  10. holidays/groups/islamic.py +0 -10
  11. holidays/holiday_base.py +72 -91
  12. holidays/locale/{ar → ar_EG}/LC_MESSAGES/EG.mo +0 -0
  13. holidays/locale/de/LC_MESSAGES/DE.mo +0 -0
  14. holidays/locale/de/LC_MESSAGES/LU.mo +0 -0
  15. holidays/locale/en_US/LC_MESSAGES/DE.mo +0 -0
  16. holidays/locale/en_US/LC_MESSAGES/EG.mo +0 -0
  17. holidays/locale/en_US/LC_MESSAGES/LU.mo +0 -0
  18. holidays/locale/fr/LC_MESSAGES/EG.mo +0 -0
  19. holidays/locale/fr/LC_MESSAGES/LU.mo +0 -0
  20. holidays/locale/lb/LC_MESSAGES/LU.mo +0 -0
  21. holidays/locale/th/LC_MESSAGES/DE.mo +0 -0
  22. holidays/locale/uk/LC_MESSAGES/DE.mo +0 -0
  23. holidays/locale/uk/LC_MESSAGES/LU.mo +0 -0
  24. holidays/registry.py +1 -0
  25. holidays/utils.py +18 -18
  26. holidays/version.py +1 -1
  27. {holidays-0.77.dist-info → holidays-0.78.dist-info}/METADATA +13 -6
  28. {holidays-0.77.dist-info → holidays-0.78.dist-info}/RECORD +32 -30
  29. {holidays-0.77.dist-info → holidays-0.78.dist-info}/licenses/CONTRIBUTORS +1 -0
  30. {holidays-0.77.dist-info → holidays-0.78.dist-info}/WHEEL +0 -0
  31. {holidays-0.77.dist-info → holidays-0.78.dist-info}/licenses/LICENSE +0 -0
  32. {holidays-0.77.dist-info → holidays-0.78.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,85 @@
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 CONTRIBUTORS 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/holidays
11
+ # License: MIT (see LICENSE file)
12
+
13
+ from holidays.constants import GOVERNMENT, PUBLIC, WORKDAY
14
+ from holidays.groups import ChristianHolidays, InternationalHolidays
15
+ from holidays.holiday_base import HolidayBase
16
+
17
+
18
+ class PitcairnIslands(HolidayBase, ChristianHolidays, InternationalHolidays):
19
+ """Pitcairn Islands holidays.
20
+
21
+ References:
22
+ * <https://en.wikipedia.org/wiki/Public_holidays_in_Pitcairn_Islands>
23
+ * [Public Holidays & Commemoration Days (2016)](https://web.archive.org/web/20161112174923/https://www.government.pn/policies/GPI%20-%20Approved%20Public%20Holidays%20&%20Commemoration%20Days.pdf)
24
+ * [Public Holidays & Commemoration Days (2024)](https://web.archive.org/web/20250517050245/https://static1.squarespace.com/static/6526ff6fef608a3828c13d05/t/6673d53b1c0e2f660cc31848/1718867262145/GPI_Policy_Public_Holidays_&_Commemoration_Days_June_2024.pdf)
25
+ * [The Laws of Pitcairn, Henderson, Ducie and Oeno Islands - Volume I](https://web.archive.org/web/20240418043000/https://static1.squarespace.com/static/6526ff6fef608a3828c13d05/t/65585fca2ce3972fb3bc8da3/1700290563094/Revised+Laws+of+Pitcairn,+Henderson,+Ducie+and+Oeno+Islands,+2017+Rev.+Ed.+-+Volume+1.pdf)
26
+ * [CIA The World Factbook](https://web.archive.org/web/20211217233431/https://www.cia.gov/the-world-factbook/countries/pitcairn-islands/)
27
+ """
28
+
29
+ country = "PN"
30
+ supported_categories = (GOVERNMENT, PUBLIC, WORKDAY)
31
+ # First available online source.
32
+ start_year = 2016
33
+
34
+ def __init__(self, *args, **kwargs):
35
+ ChristianHolidays.__init__(self)
36
+ InternationalHolidays.__init__(self)
37
+ super().__init__(*args, **kwargs)
38
+
39
+ def _populate_public_holidays(self):
40
+ # New Year's Day.
41
+ self._add_new_years_day("New Year's Day")
42
+
43
+ # Bounty Day.
44
+ self._add_holiday_jan_23("Bounty Day")
45
+
46
+ # Good Friday.
47
+ self._add_good_friday("Good Friday")
48
+
49
+ # Easter Monday.
50
+ self._add_easter_monday("Easter Monday")
51
+
52
+ if self._year >= 2023:
53
+ # King's Birthday.
54
+ self._add_holiday_1st_mon_of_jun("King's Birthday")
55
+ else:
56
+ # Queen's Birthday.
57
+ self._add_holiday_2nd_sat_of_jun("Queen's Birthday")
58
+
59
+ # Pitcairn Day.
60
+ self._add_holiday_jul_2("Pitcairn Day")
61
+
62
+ # Christmas Day.
63
+ self._add_christmas_day("Christmas Day")
64
+
65
+ # Boxing Day.
66
+ self._add_christmas_day_two("Boxing Day")
67
+
68
+ def _populate_government_holidays(self):
69
+ # New Year's Day.
70
+ self._add_new_years_day_two("New Year's Day")
71
+
72
+ def _populate_workday_holidays(self):
73
+ # ANZAC Day.
74
+ self._add_anzac_day("ANZAC Day")
75
+
76
+ # Remembrance Day.
77
+ self._add_remembrance_day("Remembrance Day")
78
+
79
+
80
+ class PN(PitcairnIslands):
81
+ pass
82
+
83
+
84
+ class PCN(PitcairnIslands):
85
+ pass
@@ -13,7 +13,8 @@
13
13
  from datetime import date
14
14
  from gettext import gettext as tr
15
15
 
16
- from holidays.calendars.gregorian import JAN, FEB, SEP, NOV, THU, FRI, SAT, _timedelta
16
+ from holidays.calendars import _CustomIslamicHolidays
17
+ from holidays.calendars.gregorian import SEP, NOV, THU, FRI, SAT, _timedelta
17
18
  from holidays.groups import IslamicHolidays, StaticHolidays
18
19
  from holidays.observed_holiday_base import (
19
20
  ObservedHolidayBase,
@@ -30,9 +31,10 @@ class SaudiArabia(ObservedHolidayBase, IslamicHolidays, StaticHolidays):
30
31
  """Saudi Arabia holidays.
31
32
 
32
33
  References:
33
- * <https://laboreducation.hrsd.gov.sa/en/gallery/274>
34
+ * <https://ar.wikipedia.org/wiki/قائمة_العطل_الرسمية_في_السعودية>
34
35
  * <https://web.archive.org/web/20240610223551/http://laboreducation.hrsd.gov.sa/en/labor-education/322>
35
36
  * <https://web.archive.org/web/20250329052253/https://english.alarabiya.net/News/gulf/2022/01/27/Saudi-Arabia-to-commemorate-Founding-Day-on-Feb-22-annually-Royal-order>
37
+ * [2015 (1436 AH) Dhu al-Hijjah begin on September 15](https://web.archive.org/web/20250430191246/https://qna.org.qa/en/news/news-details?id=saudi-arabia-eid-aladha-to-start-on-september-24&date=14/09/2015)
36
38
  """
37
39
 
38
40
  country = "SA"
@@ -45,26 +47,29 @@ class SaudiArabia(ObservedHolidayBase, IslamicHolidays, StaticHolidays):
45
47
  observed_estimated_label = tr("%s (المقدرة، ملاحظة)")
46
48
  supported_languages = ("ar", "en_US")
47
49
 
48
- def __init__(self, *args, islamic_show_estimated: bool = True, **kwargs):
49
- """
50
+ def __init__(self, *args, islamic_show_estimated: bool = False, **kwargs):
51
+ """Saudi Arabia has traditionally used the Umm al-Qura calendar
52
+ for administrative purposes.
53
+
50
54
  Args:
51
55
  islamic_show_estimated:
52
56
  Whether to add "estimated" label to Islamic holidays name
53
57
  if holiday date is estimated.
54
58
  """
55
- IslamicHolidays.__init__(self, show_estimated=islamic_show_estimated)
59
+ IslamicHolidays.__init__(
60
+ self, cls=SaudiArabiaIslamicHolidays, show_estimated=islamic_show_estimated
61
+ )
56
62
  StaticHolidays.__init__(self, SaudiArabiaStaticHolidays)
57
63
  kwargs.setdefault("observed_rule", FRI_TO_PREV_THU + SAT_TO_NEXT_SUN)
58
64
  super().__init__(*args, **kwargs)
59
65
 
60
- def _add_islamic_observed(self, dts: set[date]) -> None:
66
+ def _add_islamic_observed(self, dt: date) -> None:
61
67
  # Observed days are added to make up for any days falling on a weekend.
62
68
  if not self.observed:
63
69
  return None
64
70
  observed_rule = THU_FRI_TO_NEXT_WORKDAY if self._year <= 2012 else FRI_SAT_TO_NEXT_WORKDAY
65
- for dt in dts:
66
- for i in range(4):
67
- self._add_observed(_timedelta(dt, -i), name=self[dt], rule=observed_rule)
71
+ for i in range(4):
72
+ self._add_observed(_timedelta(dt, -i), name=self[dt], rule=observed_rule)
68
73
 
69
74
  def _populate_public_holidays(self):
70
75
  # Weekend used to be THU, FRI before June 28th, 2013.
@@ -77,36 +82,38 @@ class SaudiArabia(ObservedHolidayBase, IslamicHolidays, StaticHolidays):
77
82
  )
78
83
  self.weekend = {THU, FRI} if self._year <= 2012 else {FRI, SAT}
79
84
 
80
- # Eid al-Fitr Holiday
85
+ # Eid al-Fitr Holiday.
81
86
  eid_al_fitr_name = tr("عطلة عيد الفطر")
82
- self._add_eid_al_fitr_day(eid_al_fitr_name)
87
+ eid_al_fitr_dates = self._add_eid_al_fitr_day(eid_al_fitr_name)
83
88
  self._add_eid_al_fitr_day_two(eid_al_fitr_name)
84
89
  self._add_eid_al_fitr_day_three(eid_al_fitr_name)
85
- self._add_islamic_observed(self._add_eid_al_fitr_day_four(eid_al_fitr_name))
86
90
 
87
- # Arafat Day
91
+ for dt in eid_al_fitr_dates:
92
+ if self._islamic_calendar._is_long_ramadan(dt):
93
+ # Add 30 Ramadan.
94
+ self._add_holiday(eid_al_fitr_name, _timedelta(dt, -1))
95
+ self._add_islamic_observed(_timedelta(dt, +2))
96
+ else:
97
+ # Add 4 Shawwal.
98
+ self._add_islamic_observed(self._add_holiday(eid_al_fitr_name, _timedelta(dt, +3)))
99
+
100
+ # Arafat Day.
88
101
  self._add_arafah_day(tr("يوم عرفة"))
89
- # Eid al-Adha Holiday
102
+
103
+ # Eid al-Adha Holiday.
90
104
  name = tr("عطلة عيد الأضحى")
91
105
  self._add_eid_al_adha_day(name)
92
106
  self._add_eid_al_adha_day_two(name)
93
- self._add_islamic_observed(self._add_eid_al_adha_day_three(name))
94
-
95
- # If National Day happens within the Eid al-Fitr Holiday or
96
- # Eid al-Adha Holiday, there is no extra holidays given for it.
97
- if self._year >= 2005:
98
- dt = date(self._year, SEP, 23)
99
- if dt not in self:
100
- # National Day Holiday
101
- self._add_observed(self._add_holiday(tr("اليوم الوطني"), dt))
107
+ for dt in self._add_eid_al_adha_day_three(name):
108
+ self._add_islamic_observed(dt)
102
109
 
103
- # If Founding Day happens within the Eid al-Fitr Holiday or
104
- # Eid al-Adha Holiday, there is no extra holidays given for it.
105
110
  if self._year >= 2022:
106
- dt = date(self._year, FEB, 22)
107
- if dt not in self:
108
- # Founding Day
109
- self._add_observed(self._add_holiday(tr("يوم التأسيسي"), dt))
111
+ # Founding Day.
112
+ self._add_observed(self._add_holiday_feb_22(tr("يوم التأسيسي")))
113
+
114
+ if self._year >= 2005:
115
+ # National Day.
116
+ self._add_observed(self._add_holiday_sep_23(tr("اليوم الوطني")))
110
117
 
111
118
 
112
119
  class SA(SaudiArabia):
@@ -117,13 +124,14 @@ class SAU(SaudiArabia):
117
124
  pass
118
125
 
119
126
 
127
+ class SaudiArabiaIslamicHolidays(_CustomIslamicHolidays):
128
+ EID_AL_ADHA_DATES = {
129
+ 2015: (SEP, 24),
130
+ }
131
+
132
+
120
133
  class SaudiArabiaStaticHolidays:
121
134
  special_public_holidays = {
122
- # Celebrate the country's win against Argentina in the World Cup
135
+ # Celebrate the country's win against Argentina in the World Cup.
123
136
  2022: (NOV, 23, tr("يوم وطني")),
124
137
  }
125
-
126
- special_public_holidays_observed = {
127
- # Eid al-Fitr Holiday
128
- 2001: (JAN, 1, tr("عطلة عيد الفطر")),
129
- }
@@ -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).
holidays/holiday_base.py CHANGED
@@ -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
- It is generally instantiated using the
84
- [country_holidays()][holidays.utils.country_holidays] function.
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
- The key of the `dict`-like `HolidayBase` object is the
87
- `date` of the holiday, and the value is the name of the holiday itself.
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
- When passing the `date` as a key, the `date` can be expressed in one of the
92
- following types:
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
- * `datetime.date`,
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
- The key is always returned as a `datetime.date` object.
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
- To maximize speed, the list of public holidays is built on the fly as
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
- If you need to list the holidays as opposed to querying individual dates,
108
- instantiate the class with the **years** parameter.
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
- * a `dict` with date/name key/value pairs (e.g.
169
- `{'2010-07-10': 'My birthday!'}`),
170
- * a list of dates (as a `datetime.date`, `datetime.datetime`,
171
- `str`, `int`, or `float`); `'Holiday'` will be used as a description,
172
- * or a single date item (of one of the types above); `'Holiday'` will be
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 **country** or **market**.
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
- * a `str` of any format recognized by `dateutil.parser.parse()`,
442
- * or a `float` or `int` representing a POSIX timestamp.
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
- * `datetime.date`,
621
- * `datetime.datetime`,
622
- * a `str` of any format recognized by `dateutil.parser.parse()`,
623
- * or a `float` or `int` representing a POSIX timestamp
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 class that populates (generates and adds) holidays
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() method.
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
- * a `str` of any format recognized by `dateutil.parser.parse()`,
986
- * or a `float` or `int` representing a POSIX timestamp.
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
- * a `str` of any format recognized by `dateutil.parser.parse()`,
1007
- * or a `float` or `int` representing a POSIX timestamp.
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 > 0 else -1
1106
+ direction = +1 if n >= 0 else -1
1132
1107
  dt = self.__keytransform__(key)
1133
- for _ in range(abs(n)):
1134
- dt = _timedelta(dt, direction)
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
- * a `str` of any format recognized by `dateutil.parser.parse()`,
1189
- * or a `float` or `int` representing a POSIX timestamp.
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
- * a `str` of any format recognized by `dateutil.parser.parse()`,
1296
- * or a `float` or `int` representing a POSIX timestamp.
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
- Returns a `dict`-like object resulting from the addition of two or
1312
- more individual dictionaries of public holidays. The original dictionaries
1313
- are available as a `list` in the attribute `holidays,` and
1314
- `country` and `subdiv` attributes are added
1315
- together and could become `list` s. Holiday names, when different,
1316
- are merged. All years are calculated (expanded) for all operands.
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
holidays/registry.py CHANGED
@@ -181,6 +181,7 @@ COUNTRIES: RegistryDict = {
181
181
  "paraguay": ("Paraguay", "PY", "PRY"),
182
182
  "peru": ("Peru", "PE", "PER"),
183
183
  "philippines": ("Philippines", "PH", "PHL"),
184
+ "pitcairn_islands": ("PitcairnIslands", "PN", "PCN"),
184
185
  "poland": ("Poland", "PL", "POL"),
185
186
  "portugal": ("Portugal", "PT", "PRT"),
186
187
  "puerto_rico": ("PuertoRico", "PR", "PRI", "HolidaysPR"),
holidays/utils.py CHANGED
@@ -40,9 +40,9 @@ def country_holidays(
40
40
  language: Optional[str] = None,
41
41
  categories: Optional[CategoryArg] = None,
42
42
  ) -> HolidayBase:
43
- """
44
- Returns a new dictionary-like `HolidayBase` object for the public
45
- holidays of the country matching **country** and other keyword arguments.
43
+ """Return a new dictionary-like [HolidayBase][holidays.holiday_base.HolidayBase] object.
44
+
45
+ Include public holidays for the country matching `country` and other keyword arguments.
46
46
 
47
47
  Args:
48
48
  country:
@@ -60,9 +60,9 @@ def country_holidays(
60
60
  is requested.
61
61
 
62
62
  observed:
63
- Whether to include the dates of when public holiday are observed
63
+ Whether to include the dates of when public holidays are observed
64
64
  (e.g. a holiday falling on a Sunday being observed the following
65
- Monday). False may not work for all countries.
65
+ Monday). `False` may not work for all countries.
66
66
 
67
67
  prov:
68
68
  *deprecated* use `subdiv` instead.
@@ -106,12 +106,12 @@ def country_holidays(
106
106
  Requested holiday categories.
107
107
 
108
108
  Returns:
109
- A `HolidayBase` object matching the **country**.
109
+ A `HolidayBase` object matching the `country`.
110
110
 
111
111
  The key of the `dict`-like `HolidayBase` object is the
112
112
  `date` of the holiday, and the value is the name of the holiday itself.
113
113
  Dates where a key is not present are not public holidays (or, if
114
- **observed** is False, days when a public holiday is observed).
114
+ `observed` is `False`, days when a public holiday is observed).
115
115
 
116
116
  When passing the `date` as a key, the `date` can be expressed in one of the
117
117
  following types:
@@ -125,12 +125,12 @@ def country_holidays(
125
125
 
126
126
  To maximize speed, the list of public holidays is built on the fly as
127
127
  needed, one calendar year at a time. When the object is instantiated
128
- without a **years** parameter, it is empty, but, unless **expand** is set
129
- to False, as soon as a key is accessed the class will calculate that entire
128
+ without a `years` parameter, it is empty, but, unless `expand` is set
129
+ to `False`, as soon as a key is accessed the class will calculate that entire
130
130
  year's list of holidays and set the keys with them.
131
131
 
132
132
  If you need to list the holidays as opposed to querying individual dates,
133
- instantiate the class with the **years** parameter.
133
+ instantiate the class with the `years` parameter.
134
134
 
135
135
  Example usage:
136
136
 
@@ -236,14 +236,14 @@ def financial_holidays(
236
236
  observed: bool = True,
237
237
  language: Optional[str] = None,
238
238
  ) -> HolidayBase:
239
- """
240
- Returns a new dictionary-like :py:class:`HolidayBase` object for the public
241
- holidays of the financial market matching **market** and other keyword
239
+ """Return a new dictionary-like [HolidayBase][holidays.holiday_base.HolidayBase] object.
240
+
241
+ Include public holidays for the financial market matching `market` and other keyword
242
242
  arguments.
243
243
 
244
244
  Args:
245
245
  market:
246
- An ISO 3166-1 Alpha-2 market code.
246
+ An ISO 10383 MIC code.
247
247
 
248
248
  subdiv:
249
249
  Currently not implemented for markets (see documentation).
@@ -256,9 +256,9 @@ def financial_holidays(
256
256
  is requested.
257
257
 
258
258
  observed:
259
- Whether to include the dates of when public holiday are observed
259
+ Whether to include the dates of when public holidays are observed
260
260
  (e.g. a holiday falling on a Sunday being observed the following
261
- Monday). False may not work for all countries.
261
+ Monday). `False` may not work for all markets.
262
262
 
263
263
  language:
264
264
  Specifies the language in which holiday names are returned.
@@ -293,7 +293,7 @@ def financial_holidays(
293
293
  This behavior will be updated and formalized in v1.
294
294
 
295
295
  Returns:
296
- A `HolidayBase` object matching the **market**.
296
+ A `HolidayBase` object matching the `market`.
297
297
 
298
298
  Example usage:
299
299
 
@@ -428,7 +428,7 @@ def list_supported_financial(include_aliases: bool = True) -> dict[str, list[str
428
428
 
429
429
  Args:
430
430
  include_aliases:
431
- Whether to include entity aliases (e.g. TAR for ECB, XNYS for NYSE).
431
+ Whether to include entity aliases (e.g. NYSE for XNYS, TAR for XECB).
432
432
 
433
433
  Returns:
434
434
  A dictionary where key is a market code and value is a list of supported