holidays 0.48__py3-none-any.whl → 0.50__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 (71) hide show
  1. holidays/__init__.py +12 -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/__init__.py +1 -0
  6. holidays/countries/angola.py +2 -2
  7. holidays/countries/aruba.py +2 -3
  8. holidays/countries/botswana.py +19 -9
  9. holidays/countries/cambodia.py +7 -8
  10. holidays/countries/canada.py +2 -1
  11. holidays/countries/chile.py +14 -11
  12. holidays/countries/curacao.py +3 -4
  13. holidays/countries/finland.py +2 -2
  14. holidays/countries/georgia.py +17 -1
  15. holidays/countries/greenland.py +96 -0
  16. holidays/countries/hongkong.py +398 -133
  17. holidays/countries/isle_of_man.py +3 -8
  18. holidays/countries/israel.py +13 -13
  19. holidays/countries/italy.py +163 -133
  20. holidays/countries/japan.py +52 -33
  21. holidays/countries/jersey.py +11 -9
  22. holidays/countries/laos.py +7 -23
  23. holidays/countries/madagascar.py +2 -3
  24. holidays/countries/malaysia.py +545 -235
  25. holidays/countries/monaco.py +4 -6
  26. holidays/countries/netherlands.py +2 -3
  27. holidays/countries/new_zealand.py +5 -5
  28. holidays/countries/russia.py +18 -4
  29. holidays/countries/saudi_arabia.py +2 -3
  30. holidays/countries/south_korea.py +17 -4
  31. holidays/countries/sweden.py +2 -3
  32. holidays/countries/switzerland.py +18 -17
  33. holidays/deprecation.py +33 -0
  34. holidays/financial/__init__.py +1 -0
  35. holidays/financial/ice_futures_europe.py +47 -0
  36. holidays/financial/ny_stock_exchange.py +17 -4
  37. holidays/groups/chinese.py +2 -3
  38. holidays/groups/christian.py +18 -19
  39. holidays/groups/islamic.py +2 -2
  40. holidays/groups/persian.py +2 -2
  41. holidays/helpers.py +9 -3
  42. holidays/holiday_base.py +18 -15
  43. holidays/locale/da/LC_MESSAGES/GL.mo +0 -0
  44. holidays/locale/da/LC_MESSAGES/GL.po +91 -0
  45. holidays/locale/en_US/LC_MESSAGES/GE.mo +0 -0
  46. holidays/locale/en_US/LC_MESSAGES/GE.po +8 -4
  47. holidays/locale/en_US/LC_MESSAGES/GL.mo +0 -0
  48. holidays/locale/en_US/LC_MESSAGES/GL.po +92 -0
  49. holidays/locale/en_US/LC_MESSAGES/MY.mo +0 -0
  50. holidays/locale/en_US/LC_MESSAGES/MY.po +250 -0
  51. holidays/locale/en_US/LC_MESSAGES/RU.mo +0 -0
  52. holidays/locale/en_US/LC_MESSAGES/RU.po +11 -2
  53. holidays/locale/ka/LC_MESSAGES/GE.mo +0 -0
  54. holidays/locale/ka/LC_MESSAGES/GE.po +8 -4
  55. holidays/locale/kl/LC_MESSAGES/GL.mo +0 -0
  56. holidays/locale/kl/LC_MESSAGES/GL.po +91 -0
  57. holidays/locale/ms_MY/LC_MESSAGES/MY.mo +0 -0
  58. holidays/locale/ms_MY/LC_MESSAGES/MY.po +250 -0
  59. holidays/locale/ru/LC_MESSAGES/RU.mo +0 -0
  60. holidays/locale/ru/LC_MESSAGES/RU.po +11 -2
  61. holidays/locale/uk/LC_MESSAGES/GE.mo +0 -0
  62. holidays/locale/uk/LC_MESSAGES/GE.po +8 -4
  63. holidays/mixins.py +31 -0
  64. holidays/observed_holiday_base.py +66 -37
  65. holidays/registry.py +12 -1
  66. {holidays-0.48.dist-info → holidays-0.50.dist-info}/AUTHORS +3 -0
  67. {holidays-0.48.dist-info → holidays-0.50.dist-info}/METADATA +14 -6
  68. {holidays-0.48.dist-info → holidays-0.50.dist-info}/RECORD +71 -57
  69. {holidays-0.48.dist-info → holidays-0.50.dist-info}/LICENSE +0 -0
  70. {holidays-0.48.dist-info → holidays-0.50.dist-info}/WHEEL +0 -0
  71. {holidays-0.48.dist-info → holidays-0.50.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,91 @@
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
+ # Greenland holidays.
14
+ #
15
+ msgid ""
16
+ msgstr ""
17
+ "Project-Id-Version: Python Holidays 0.50\n"
18
+ "POT-Creation-Date: 2023-02-15 08:13-0800\n"
19
+ "PO-Revision-Date: 2024-05-30 16:36+0200\n"
20
+ "Last-Translator: ~Klintrup <github@klintrup.dk>\n"
21
+ "Language-Team: Python Holidays localization team\n"
22
+ "Language: kl\n"
23
+ "MIME-Version: 1.0\n"
24
+ "Content-Type: text/plain; charset=UTF-8\n"
25
+ "Content-Transfer-Encoding: 8bit\n"
26
+ "Generated-By: Lingua 4.15.0\n"
27
+ "X-Generator: Poedit 3.2.2\n"
28
+
29
+ #. New Year's Day.
30
+ msgid "Ukioq nutaaq"
31
+ msgstr ""
32
+
33
+ #. Maundy Thursday.
34
+ msgid "Sisamanngornermi illernartumi"
35
+ msgstr ""
36
+
37
+ #. Easter Sunday.
38
+ msgid "Poorskimi"
39
+ msgstr ""
40
+
41
+ #. Easter Monday.
42
+ msgid "Poorskimi ullut aappaat"
43
+ msgstr ""
44
+
45
+ #. Great Day of Prayers.
46
+ msgid "Ulloq qinuffiusoq"
47
+ msgstr ""
48
+
49
+ #. Ascension Day.
50
+ msgid "Ulloq Kristusip qilaliarnera"
51
+ msgstr ""
52
+
53
+ #. Whit Sunday.
54
+ msgid "Piinsip ullua"
55
+ msgstr ""
56
+
57
+ #. Whit Monday.
58
+ msgid "Piinsip ulluisa aappaanni"
59
+ msgstr ""
60
+
61
+ #. Christmas Day.
62
+ msgid "Juulli"
63
+ msgstr ""
64
+
65
+ #. Second Day of Christmas.
66
+ msgid "Juullip aappaa"
67
+ msgstr ""
68
+
69
+ #. International Workers' Day.
70
+ msgid "Sulisartut ulluat"
71
+ msgstr ""
72
+
73
+ #. Christmas Eve.
74
+ msgid "Juulliaqqami"
75
+ msgstr ""
76
+
77
+ #. New Year's Eve.
78
+ msgid "Ukiortaami"
79
+ msgstr ""
80
+
81
+ #. National Day.
82
+ msgid "Ullortuneq"
83
+ msgstr ""
84
+
85
+ #. Good Friday.
86
+ msgid "Tallimanngorneq ajortorsiorneq"
87
+ msgstr ""
88
+
89
+ #. Epiphany.
90
+ msgid "Mitaarneq"
91
+ msgstr ""
Binary file
@@ -0,0 +1,250 @@
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
+ # Malaysia holidays.
14
+ #
15
+ msgid ""
16
+ msgstr ""
17
+ "Project-Id-Version: Python Holidays 0.49\n"
18
+ "POT-Creation-Date: 2024-04-28 21:03+0300\n"
19
+ "PO-Revision-Date: 2024-04-28 21:06+0300\n"
20
+ "Last-Translator: ~Jhellico <jhellico@gmail.com>\n"
21
+ "Language-Team: Python Holidays Localization Team\n"
22
+ "Language: ms_MY\n"
23
+ "MIME-Version: 1.0\n"
24
+ "Content-Type: text/plain; charset=UTF-8\n"
25
+ "Content-Transfer-Encoding: 8bit\n"
26
+ "Generated-By: Lingva 5.0.2\n"
27
+ "X-Generator: Poedit 3.4.2\n"
28
+
29
+ #. %s (estimated).
30
+ #, c-format
31
+ msgid "%s (anggaran)"
32
+ msgstr ""
33
+
34
+ #. %s (in lieu).
35
+ #, c-format
36
+ msgid "Cuti %s"
37
+ msgstr ""
38
+
39
+ #. %s (observed, estimated).
40
+ #, c-format
41
+ msgid "Cuti %s (anggaran)"
42
+ msgstr ""
43
+
44
+ #. Chinese New Year.
45
+ msgid "Tahun Baharu Cina"
46
+ msgstr ""
47
+
48
+ #. Chinese New Year (Second Day).
49
+ msgid "Tahun Baharu Cina (Hari Kedua)"
50
+ msgstr ""
51
+
52
+ #. Vesak Day.
53
+ msgid "Hari Wesak"
54
+ msgstr ""
55
+
56
+ #. Labor Day.
57
+ msgid "Hari Pekerja"
58
+ msgstr ""
59
+
60
+ #. Birthday of HM Yang di-Pertuan Agong.
61
+ msgid "Hari Keputeraan Rasmi Seri Paduka Baginda Yang di-Pertuan Agong"
62
+ msgstr ""
63
+
64
+ #. National Day.
65
+ msgid "Hari Kebangsaan"
66
+ msgstr ""
67
+
68
+ #. Malaysia Day.
69
+ msgid "Hari Malaysia"
70
+ msgstr ""
71
+
72
+ #. Christmas Day.
73
+ msgid "Hari Krismas"
74
+ msgstr ""
75
+
76
+ #. Islamic New Year.
77
+ msgid "Awal Muharam"
78
+ msgstr ""
79
+
80
+ #. Prophet Muhammad's Birthday.
81
+ msgid "Hari Keputeraan Nabi Muhammad S.A.W."
82
+ msgstr ""
83
+
84
+ #. Eid al-Fitr.
85
+ msgid "Hari Raya Puasa"
86
+ msgstr ""
87
+
88
+ #. Eid al-Fitr (Second Day).
89
+ msgid "Hari Raya Puasa (Hari Kedua)"
90
+ msgstr ""
91
+
92
+ #. Eid al-Adha.
93
+ msgid "Hari Raya Qurban"
94
+ msgstr ""
95
+
96
+ #. Deepavali.
97
+ msgid "Hari Deepavali"
98
+ msgstr ""
99
+
100
+ #. Thaipusam.
101
+ msgid "Hari Thaipusam"
102
+ msgstr ""
103
+
104
+ #. Birthday of the Sultan of Johor.
105
+ msgid "Hari Keputeraan Sultan Johor"
106
+ msgstr ""
107
+
108
+ #. The Sultan of Johor Hol.
109
+ msgid "Hari Hol Almarhum Sultan Iskandar"
110
+ msgstr ""
111
+
112
+ #. Beginning of Ramadan.
113
+ msgid "Awal Ramadan"
114
+ msgstr ""
115
+
116
+ #. Birthday of The Sultan of Kedah.
117
+ msgid "Hari Keputeraan Sultan Kedah"
118
+ msgstr ""
119
+
120
+ #. Isra' and Mi'raj.
121
+ msgid "Israk dan Mikraj"
122
+ msgstr ""
123
+
124
+ #. Eid al-Adha (Second Day).
125
+ msgid "Hari Raya Qurban (Hari Kedua)"
126
+ msgstr ""
127
+
128
+ #. Birthday of the Sultan of Kelantan.
129
+ msgid "Hari Keputeraan Sultan Kelantan"
130
+ msgstr ""
131
+
132
+ #. Nuzul Al-Quran Day.
133
+ msgid "Hari Nuzul Al-Quran"
134
+ msgstr ""
135
+
136
+ #. New Year's Day.
137
+ msgid "Tahun Baharu"
138
+ msgstr ""
139
+
140
+ #. Federal Territory Day.
141
+ msgid "Hari Wilayah Persekutuan"
142
+ msgstr ""
143
+
144
+ #. Pesta Kaamatan.
145
+ msgid "Pesta Kaamatan"
146
+ msgstr ""
147
+
148
+ #. Declaration of Independence Day.
149
+ msgid "Hari Pengisytiharan Tarikh Kemerdekaan"
150
+ msgstr ""
151
+
152
+ #. Declaration of Malacca as a Historical City.
153
+ msgid "Hari Perisytiharan Melaka Sebagai Bandaraya Bersejarah"
154
+ msgstr ""
155
+
156
+ #. Birthday of the Governor of Malacca.
157
+ msgid "Hari Jadi Yang di-Pertua Negeri Melaka"
158
+ msgstr ""
159
+
160
+ #. Birthday of the Sultan of Negeri Sembilan.
161
+ msgid "Hari Keputeraan Yang di-Pertuan Besar Negeri Sembilan"
162
+ msgstr ""
163
+
164
+ #. The Sultan of Pahang Hol.
165
+ msgid "Hari Hol Sultan Pahang"
166
+ msgstr ""
167
+
168
+ #. Birthday of the Sultan of Pahang.
169
+ msgid "Hari Keputeraan Sultan Pahang"
170
+ msgstr ""
171
+
172
+ #. Birthday of the Raja of Perlis.
173
+ msgid "Hari Ulang Tahun Keputeraan Raja Perlis"
174
+ msgstr ""
175
+
176
+ #. George Town Heritage Day.
177
+ msgid "Hari Ulang Tahun Perisytiharan Tapak Warisan Dunia"
178
+ msgstr ""
179
+
180
+ #. Birthday of the Governor of Penang.
181
+ msgid "Hari Jadi Yang di-Pertua Negeri Pulau Pinang"
182
+ msgstr ""
183
+
184
+ #. Birthday of the Sultan of Perak.
185
+ msgid "Hari Keputeraan Sultan Perak"
186
+ msgstr ""
187
+
188
+ #. Good Friday.
189
+ msgid "Good Friday"
190
+ msgstr ""
191
+
192
+ #. Birthday of the Governor of Sabah.
193
+ msgid "Hari Jadi Yang di-Pertua Negeri Sabah"
194
+ msgstr ""
195
+
196
+ #. Christmas Eve.
197
+ msgid "Christmas Eve"
198
+ msgstr ""
199
+
200
+ #. Birthday of The Sultan of Selangor.
201
+ msgid "Hari Keputeraan Sultan Selangor"
202
+ msgstr ""
203
+
204
+ #. Dayak Festival Day.
205
+ msgid "Perayaan Hari Gawai Dayak"
206
+ msgstr ""
207
+
208
+ #. Birthday of the Governor of Sarawak.
209
+ msgid "Hari Jadi Yang di-Pertua Negeri Sarawak"
210
+ msgstr ""
211
+
212
+ #. Sarawak Independence Day.
213
+ msgid "Hari Kemerdekaan Sarawak"
214
+ msgstr ""
215
+
216
+ #. Anniversary of the Installation of the Sultan of Terengganu.
217
+ msgid "Hari Ulang Tahun Pertabalan Sultan Terengganu"
218
+ msgstr ""
219
+
220
+ #. Birthday of the Sultan of Terengganu.
221
+ msgid "Hari Keputeraan Sultan Terengganu"
222
+ msgstr ""
223
+
224
+ #. Arafat Day.
225
+ msgid "Hari Arafah"
226
+ msgstr ""
227
+
228
+ #. General election additional holiday.
229
+ msgid "Cuti Peristiwa (pilihan raya umum)"
230
+ msgstr ""
231
+
232
+ #. Malaysia Cup Holiday.
233
+ msgid "Cuti Piala Malaysia"
234
+ msgstr ""
235
+
236
+ #. Day of Installation of the 15th Yang di-Pertuan Agong.
237
+ msgid "Hari Pertabalan Yang di-Pertuan Agong ke-15"
238
+ msgstr ""
239
+
240
+ #. Day of Installation of the 16th Yang di-Pertuan Agong.
241
+ msgid "Hari Pertabalan Yang di-Pertuan Agong ke-16"
242
+ msgstr ""
243
+
244
+ #. Eid al-Fitr (additional holiday).
245
+ msgid "Hari Raya Puasa (pergantian hari)"
246
+ msgstr ""
247
+
248
+ #. Additional holiday in commemoration of the 2017 SEA Games.
249
+ msgid "Cuti tambahan sempena memperingati SAT 2017"
250
+ msgstr ""
Binary file
@@ -16,7 +16,7 @@ msgid ""
16
16
  msgstr ""
17
17
  "Project-Id-Version: Python Holidays 0.29\n"
18
18
  "POT-Creation-Date: 2023-02-15 08:13-0800\n"
19
- "PO-Revision-Date: 2023-07-13 15:57+0300\n"
19
+ "PO-Revision-Date: 2024-05-21 13:26+0700\n"
20
20
  "Last-Translator: ~Jhellico <jhellico@gmail.com>\n"
21
21
  "Language-Team: Python Holidays localization team\n"
22
22
  "Language: ru\n"
@@ -25,7 +25,7 @@ msgstr ""
25
25
  "Content-Transfer-Encoding: 8bit\n"
26
26
  "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : 2);\n"
27
27
  "Generated-By: Lingua 4.15.0\n"
28
- "X-Generator: Poedit 3.2.2\n"
28
+ "X-Generator: Poedit 3.4.4\n"
29
29
 
30
30
  #. New Year's Day.
31
31
  msgid "Новый год"
@@ -80,3 +80,12 @@ msgstr ""
80
80
  #. Anniversary of the Great October Socialist Revolution.
81
81
  msgid "Годовщина Великой Октябрьской социалистической революции"
82
82
  msgstr ""
83
+
84
+ #. Date format (see strftime() Format Codes).
85
+ msgid "%d.%m.%Y"
86
+ msgstr ""
87
+
88
+ #. Day off (substituted from %s).
89
+ #, c-format
90
+ msgid "Выходной (перенесено с %s)"
91
+ msgstr ""
Binary file
@@ -14,10 +14,10 @@
14
14
  #
15
15
  msgid ""
16
16
  msgstr ""
17
- "Project-Id-Version: Python Holidays 0.30\n"
17
+ "Project-Id-Version: Python Holidays 0.50\n"
18
18
  "POT-Creation-Date: 2023-07-18 17:31+0300\n"
19
- "PO-Revision-Date: 2023-07-18 18:06+0300\n"
20
- "Last-Translator: ~Jhellico <jhellico@gmail.com>\n"
19
+ "PO-Revision-Date: 2024-05-23 11:01+0700\n"
20
+ "Last-Translator: PPsyrius <ppsyrius@ppsyrius.dev>\n"
21
21
  "Language-Team: Python Holidays localization team\n"
22
22
  "Language: uk\n"
23
23
  "MIME-Version: 1.0\n"
@@ -25,7 +25,7 @@ msgstr ""
25
25
  "Content-Transfer-Encoding: 8bit\n"
26
26
  "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : 2);\n"
27
27
  "Generated-By: Lingua 4.15.0\n"
28
- "X-Generator: Poedit 3.2.2\n"
28
+ "X-Generator: Poedit 3.4.4\n"
29
29
 
30
30
  #. New Year's Day.
31
31
  msgid "ახალი წელი"
@@ -90,3 +90,7 @@ msgstr "Свято Светіцховлоба, Ризи Господньої"
90
90
  #. Saint George's Day.
91
91
  msgid "გიორგობა"
92
92
  msgstr "День святого Георгія"
93
+
94
+ #. Day of Family Sanctity and Respect for Parents.
95
+ msgid "ოჯახის სიწმინდისა და მშობლების პატივისცემის დღე"
96
+ msgstr "День святості родини та поваги до батьків"
holidays/mixins.py ADDED
@@ -0,0 +1,31 @@
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
+
14
+ from typing import Tuple
15
+
16
+
17
+ class PreferredDiscretionaryHolidays:
18
+ """A mixin for setting preferred discretionary holidays.
19
+
20
+ See :class:`holidays.countries.hongkong.HongKong` for an example.
21
+ """
22
+
23
+ default_preferred_discretionary_holidays: Tuple[str, ...] = ()
24
+ """Preferred discretionary holidays defaults."""
25
+
26
+ def __init__(self, preferred_discretionary_holidays):
27
+ self.preferred_discretionary_holidays = set(
28
+ preferred_discretionary_holidays
29
+ if preferred_discretionary_holidays
30
+ else self.default_preferred_discretionary_holidays
31
+ )
@@ -11,14 +11,13 @@
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 Dict, Optional, Tuple, Set
16
15
 
17
- from holidays.calendars.gregorian import MON, TUE, WED, THU, FRI, SAT, SUN
16
+ from holidays.calendars.gregorian import MON, TUE, WED, THU, FRI, SAT, SUN, _timedelta
18
17
  from holidays.holiday_base import DateArg, HolidayBase
19
18
 
20
19
 
21
- class ObservedRule(Dict[int, int]):
20
+ class ObservedRule(Dict[int, Optional[int]]):
22
21
  __slots__ = ()
23
22
 
24
23
  def __add__(self, other):
@@ -28,9 +27,11 @@ class ObservedRule(Dict[int, int]):
28
27
  # Observance calculation rules: +7 - next workday, -7 - previous workday.
29
28
  # Single days.
30
29
  MON_TO_NEXT_TUE = ObservedRule({MON: +1})
30
+ MON_ONLY = ObservedRule({TUE: None, WED: None, THU: None, FRI: None, SAT: None, SUN: None})
31
31
 
32
32
  TUE_TO_PREV_MON = ObservedRule({TUE: -1})
33
33
  TUE_TO_PREV_FRI = ObservedRule({TUE: -4})
34
+ TUE_TO_NONE = ObservedRule({TUE: None})
34
35
 
35
36
  WED_TO_PREV_MON = ObservedRule({WED: -2})
36
37
  WED_TO_NEXT_FRI = ObservedRule({WED: +2})
@@ -46,6 +47,7 @@ FRI_TO_NEXT_MON = ObservedRule({FRI: +3})
46
47
  FRI_TO_NEXT_TUE = ObservedRule({FRI: +4})
47
48
  FRI_TO_NEXT_SAT = ObservedRule({FRI: +1})
48
49
  FRI_TO_NEXT_WORKDAY = ObservedRule({FRI: +7})
50
+ FRI_ONLY = ObservedRule({MON: None, TUE: None, WED: None, THU: None, SAT: None, SUN: None})
49
51
 
50
52
  SAT_TO_PREV_THU = ObservedRule({SAT: -2})
51
53
  SAT_TO_PREV_FRI = ObservedRule({SAT: -1})
@@ -54,11 +56,13 @@ SAT_TO_NEXT_MON = ObservedRule({SAT: +2})
54
56
  SAT_TO_NEXT_TUE = ObservedRule({SAT: +3})
55
57
  SAT_TO_NEXT_SUN = ObservedRule({SAT: +1})
56
58
  SAT_TO_NEXT_WORKDAY = ObservedRule({SAT: +7})
59
+ SAT_TO_NONE = ObservedRule({SAT: None})
57
60
 
58
61
  SUN_TO_NEXT_MON = ObservedRule({SUN: +1})
59
62
  SUN_TO_NEXT_TUE = ObservedRule({SUN: +2})
60
63
  SUN_TO_NEXT_WED = ObservedRule({SUN: +3})
61
64
  SUN_TO_NEXT_WORKDAY = ObservedRule({SUN: +7})
65
+ SUN_TO_NONE = ObservedRule({SUN: None})
62
66
 
63
67
  # Multiple days.
64
68
  ALL_TO_NEAREST_MON = ObservedRule({TUE: -1, WED: -2, THU: -3, FRI: +3, SAT: +2, SUN: +1})
@@ -70,6 +74,8 @@ WORKDAY_TO_NEAREST_MON = ObservedRule({TUE: -1, WED: -2, THU: -3, FRI: +3})
70
74
  WORKDAY_TO_NEXT_MON = ObservedRule({TUE: +6, WED: +5, THU: +4, FRI: +3})
71
75
  WORKDAY_TO_NEXT_WORKDAY = ObservedRule({MON: +7, TUE: +7, WED: +7, THU: +7, FRI: +7})
72
76
 
77
+ MON_FRI_ONLY = ObservedRule({TUE: None, WED: None, THU: None, SAT: None, SUN: None})
78
+
73
79
  TUE_WED_TO_PREV_MON = ObservedRule({TUE: -1, WED: -2})
74
80
  TUE_WED_THU_TO_PREV_MON = ObservedRule({TUE: -1, WED: -2, THU: -3})
75
81
 
@@ -96,36 +102,46 @@ class ObservedHolidayBase(HolidayBase):
96
102
 
97
103
  observed_label = "%s"
98
104
 
99
- def __init__(self, observed_rule: ObservedRule, observed_since: int = None, *args, **kwargs):
100
- self._observed_rule = observed_rule
105
+ def __init__(
106
+ self, observed_rule: ObservedRule = None, observed_since: int = None, *args, **kwargs
107
+ ):
108
+ self._observed_rule = observed_rule or ObservedRule()
101
109
  self._observed_since = observed_since
102
-
103
110
  super().__init__(*args, **kwargs)
104
111
 
105
112
  def _is_observed(self, *args, **kwargs) -> bool:
106
113
  return self._observed_since is None or self._year >= self._observed_since
107
114
 
108
115
  def _get_next_workday(self, dt: date, delta: int = +1) -> date:
109
- dt_work = dt + td(days=delta)
116
+ dt_work = _timedelta(dt, delta)
110
117
  while dt_work.year == self._year:
111
118
  if dt_work in self or self._is_weekend(dt_work): # type: ignore[operator]
112
- dt_work += td(days=delta)
119
+ dt_work = _timedelta(dt_work, delta)
113
120
  else:
114
121
  return dt_work
115
122
  return dt
116
123
 
117
- def _get_observed_date(self, dt: date, rule: ObservedRule) -> date:
124
+ def _get_observed_date(self, dt: date, rule: ObservedRule) -> Optional[date]:
118
125
  delta = rule.get(dt.weekday(), 0)
119
- if delta != 0:
120
- if abs(delta) == 7:
121
- dt = self._get_next_workday(dt, delta // 7)
122
- else:
123
- dt += td(days=delta)
126
+ if delta:
127
+ return (
128
+ self._get_next_workday(dt, delta // 7)
129
+ if abs(delta) == 7
130
+ else _timedelta(dt, delta)
131
+ )
132
+ # Goes after `if delta` case as a less probable.
133
+ elif delta is None:
134
+ return None
135
+
124
136
  return dt
125
137
 
126
138
  def _add_observed(
127
- self, dt: DateArg, name: Optional[str] = None, rule: Optional[ObservedRule] = None
128
- ) -> Tuple[bool, date]:
139
+ self,
140
+ dt: DateArg,
141
+ name: Optional[str] = None,
142
+ rule: Optional[ObservedRule] = None,
143
+ show_observed_label: bool = True,
144
+ ) -> Tuple[bool, Optional[date]]:
129
145
  dt = dt if isinstance(dt, date) else date(self._year, *dt)
130
146
 
131
147
  if not self.observed or not self._is_observed(dt):
@@ -135,32 +151,45 @@ class ObservedHolidayBase(HolidayBase):
135
151
  if dt_observed == dt:
136
152
  return False, dt
137
153
 
138
- estimated_label = self.tr(getattr(self, "estimated_label", ""))
139
- observed_label = self.tr(
140
- getattr(
141
- self,
142
- "observed_label_before" if dt_observed < dt else "observed_label",
143
- self.observed_label,
154
+ # SAT_TO_NONE and similar cases.
155
+ if dt_observed is None:
156
+ self.pop(dt)
157
+ return False, None
158
+
159
+ if show_observed_label:
160
+ estimated_label = self.tr(getattr(self, "estimated_label", ""))
161
+ observed_label = self.tr(
162
+ getattr(
163
+ self,
164
+ "observed_label_before" if dt_observed < dt else "observed_label",
165
+ self.observed_label,
166
+ )
144
167
  )
145
- )
146
168
 
147
- estimated_label_text = estimated_label.strip("%s ()")
148
- # Use observed_estimated_label instead of observed_label for estimated dates.
149
- for name in (name,) if name else self.get_list(dt):
150
- holiday_name = self.tr(name)
151
- observed_estimated_label = None
152
- if len(estimated_label_text) > 0 and estimated_label_text in holiday_name:
153
- holiday_name = holiday_name.replace(f"({estimated_label_text})", "").strip()
154
- observed_estimated_label = self.tr(getattr(self, "observed_estimated_label"))
155
-
156
- super()._add_holiday(
157
- (observed_estimated_label or observed_label) % holiday_name, dt_observed
158
- )
169
+ estimated_label_text = estimated_label.strip("%s ()")
170
+ # Use observed_estimated_label instead of observed_label for estimated dates.
171
+ for name in (name,) if name else self.get_list(dt):
172
+ holiday_name = self.tr(name)
173
+ observed_estimated_label = None
174
+ if len(estimated_label_text) > 0 and estimated_label_text in holiday_name:
175
+ holiday_name = holiday_name.replace(f"({estimated_label_text})", "").strip()
176
+ observed_estimated_label = self.tr(getattr(self, "observed_estimated_label"))
177
+
178
+ super()._add_holiday(
179
+ (observed_estimated_label or observed_label) % holiday_name, dt_observed
180
+ )
181
+ else:
182
+ for name in (name,) if name else self.get_list(dt):
183
+ super()._add_holiday(name, dt_observed)
159
184
 
160
185
  return True, dt_observed
161
186
 
162
- def _move_holiday(self, dt: date, rule: Optional[ObservedRule] = None) -> Tuple[bool, date]:
163
- is_observed, dt_observed = self._add_observed(dt, rule=rule)
187
+ def _move_holiday(
188
+ self, dt: date, rule: Optional[ObservedRule] = None, show_observed_label: bool = True
189
+ ) -> Tuple[bool, Optional[date]]:
190
+ is_observed, dt_observed = self._add_observed(
191
+ dt, rule=rule, show_observed_label=show_observed_label
192
+ )
164
193
  if is_observed:
165
194
  self.pop(dt)
166
195
  return is_observed, dt_observed if is_observed else dt
holidays/registry.py CHANGED
@@ -11,6 +11,7 @@
11
11
  # License: MIT (see LICENSE file)
12
12
 
13
13
  import importlib
14
+ from threading import RLock
14
15
  from typing import Any, Dict, Iterable, Optional, Tuple, Union
15
16
 
16
17
  from holidays.holiday_base import HolidayBase
@@ -74,6 +75,7 @@ COUNTRIES: RegistryDict = {
74
75
  "germany": ("Germany", "DE", "DEU"),
75
76
  "ghana": ("Ghana", "GH", "GHA"),
76
77
  "greece": ("Greece", "GR", "GRC"),
78
+ "greenland": ("Greenland", "GL", "GRL"),
77
79
  "guam": ("Guam", "GU", "GUM", "HolidaysGU"),
78
80
  "guatemala": ("Guatemala", "GT", "GUA"),
79
81
  "honduras": ("Honduras", "HN", "HND"),
@@ -174,9 +176,15 @@ COUNTRIES: RegistryDict = {
174
176
 
175
177
  FINANCIAL: RegistryDict = {
176
178
  "european_central_bank": ("EuropeanCentralBank", "ECB", "TAR"),
179
+ "ice_futures_europe": ("ICEFuturesEurope", "IFEU"),
177
180
  "ny_stock_exchange": ("NewYorkStockExchange", "NYSE", "XNYS"),
178
181
  }
179
182
 
183
+ # A re-entrant lock. Once a thread has acquired a re-entrant lock,
184
+ # the same thread may acquire it again without blocking.
185
+ # https://docs.python.org/3/library/threading.html#rlock-objects
186
+ IMPORT_LOCK = RLock()
187
+
180
188
 
181
189
  class EntityLoader:
182
190
  """Country and financial holidays entities lazy loader."""
@@ -222,7 +230,10 @@ class EntityLoader:
222
230
  def get_entity(self) -> Optional[HolidayBase]:
223
231
  """Return lazy-loaded entity."""
224
232
  if self.entity is None:
225
- self.entity = getattr(importlib.import_module(self.module_name), self.entity_name)
233
+ # Avoid deadlock due to importlib.import_module not being thread-safe by caching all
234
+ # the first imports in a dedicated thread.
235
+ with IMPORT_LOCK:
236
+ self.entity = getattr(importlib.import_module(self.module_name), self.entity_name)
226
237
 
227
238
  return self.entity
228
239
 
@@ -9,6 +9,7 @@ Alejandro Antunes
9
9
  Alexander Schulze
10
10
  Alexandre Carvalho
11
11
  Anders Wenhaug
12
+ Andrei Klimenko
12
13
  Andres Marrugo
13
14
  Anthony Rose
14
15
  Anton Daitche
@@ -52,6 +53,7 @@ Heikki Orsila
52
53
  Henrik Sozzi
53
54
  Hugh McNamara
54
55
  Hugo van Kemenade
56
+ Isabelle COWAN-BERGMAN
55
57
  Jacky Han
56
58
  Jacob Punter
57
59
  Jaemin Kim
@@ -124,6 +126,7 @@ Simon Gurcke
124
126
  Sugato Ray
125
127
  Sylvain Pasche
126
128
  Sylvia van Os
129
+ Søren Klintrup
127
130
  Takeshi Osoekawa
128
131
  Tasnim Nishat Islam
129
132
  Tewodros Meshesha