1010# Website: https://github.com/vacanza/holidays
1111# License: MIT (see LICENSE file)
1212
13- from holidays .calendars .gregorian import FEB , APR , AUG , SEP
14- from holidays .groups import ChristianHolidays , InternationalHolidays , StaticHolidays
15- from holidays .observed_holiday_base import ObservedHolidayBase , SUN_TO_NEXT_MON , SUN_TO_NEXT_TUE
16-
17-
18- class Kenya (ObservedHolidayBase , ChristianHolidays , InternationalHolidays , StaticHolidays ):
13+ from gettext import gettext as tr
14+
15+ from holidays .calendars import _CustomHinduHolidays , _CustomIslamicHolidays
16+ from holidays .calendars .gregorian import FEB , APR , MAY , JUN , JUL , AUG , SEP , OCT , NOV
17+ from holidays .constants import HINDU , ISLAMIC , PUBLIC
18+ from holidays .groups import (
19+ ChristianHolidays ,
20+ HinduCalendarHolidays ,
21+ InternationalHolidays ,
22+ IslamicHolidays ,
23+ StaticHolidays ,
24+ )
25+ from holidays .observed_holiday_base import ObservedHolidayBase , SUN_TO_NEXT_WORKDAY
26+
27+
28+ class Kenya (
29+ ObservedHolidayBase ,
30+ ChristianHolidays ,
31+ HinduCalendarHolidays ,
32+ InternationalHolidays ,
33+ IslamicHolidays ,
34+ StaticHolidays ,
35+ ):
1936 """
20- https://en.wikipedia.org/wiki/Public_holidays_in_Kenya
21- http://kenyaembassyberlin.de/Public-Holidays-in-Kenya.48.0.html
22- https://www.officeholidays.com/holidays/kenya/moi-day
37+ References:
38+ - https://en.wikipedia.org/wiki/Public_holidays_in_Kenya
39+ - `Public Holidays Act Cap. 110 <https://new.kenyalaw.org/akn/ke/act/1912/21/eng@2024-04-26>`_
40+ - `Constitution of Kenya (Art. 9) <https://new.kenyalaw.org/akn/ke/act/2010/constitution/eng@2010-09-03#chp_Two__sec_9>`_
2341 """
2442
2543 country = "KE"
26- observed_label = "%s (observed)"
27- start_year = 1963
44+ default_language = "en_KE"
45+ # %s (estimated).
46+ estimated_label = tr ("%s (estimated)" )
47+ # %s (observed).
48+ observed_label = tr ("%s (observed)" )
49+ # %s (observed, estimated).
50+ observed_estimated_label = tr ("%s (observed, estimated)" )
51+ supported_categories = (HINDU , ISLAMIC , PUBLIC )
52+ supported_languages = ("en_KE" , "en_US" , "sw" )
53+ # Kenya gained independence on December 12, 1963.
54+ start_year = 1964
2855
2956 def __init__ (self , * args , ** kwargs ):
3057 ChristianHolidays .__init__ (self )
58+ HinduCalendarHolidays .__init__ (self , cls = KenyaHinduHolidays )
3159 InternationalHolidays .__init__ (self )
60+ IslamicHolidays .__init__ (self , cls = KenyaIslamicHolidays )
3261 StaticHolidays .__init__ (self , cls = KenyaStaticHolidays )
33- kwargs .setdefault ("observed_rule" , SUN_TO_NEXT_MON )
62+ kwargs .setdefault ("observed_rule" , SUN_TO_NEXT_WORKDAY )
63+ kwargs .setdefault ("observed_since" , 1985 )
3464 super ().__init__ (* args , ** kwargs )
3565
3666 def _populate_public_holidays (self ):
37- # New Year's Day
38- self ._add_observed (self ._add_new_years_day ("New Year's Day" ))
67+ dts_observed = set ()
68+
69+ # New Year's Day.
70+ dts_observed .add (self ._add_new_years_day (tr ("New Year's Day" )))
71+
72+ # Good Friday.
73+ self ._add_good_friday (tr ("Good Friday" ))
74+
75+ # Easter Monday.
76+ self ._add_easter_monday (tr ("Easter Monday" ))
77+
78+ # Labor Day.
79+ dts_observed .add (self ._add_labor_day (tr ("Labour Day" )))
80+
81+ if self ._year >= 2011 :
82+ # Madaraka Day.
83+ dts_observed .add (self ._add_holiday_jun_1 (tr ("Madaraka Day" )))
84+
85+ if 1990 <= self ._year <= 2009 or self ._year >= 2018 :
86+ if self ._year >= 2025 :
87+ # Mazingira Day.
88+ name = tr ("Mazingira Day" )
89+ elif self ._year >= 2021 :
90+ # Utamaduni Day.
91+ name = tr ("Utamaduni Day" )
92+ else :
93+ # Moi Day.
94+ name = tr ("Moi Day" )
95+ dts_observed .add (self ._add_holiday_oct_10 (name ))
96+
97+ dts_observed .add (
98+ self ._add_holiday_oct_20 (
99+ # Mashujaa Day.
100+ tr ("Mashujaa Day" )
101+ if self ._year >= 2011
102+ # Kenyatta Day.
103+ else tr ("Kenyatta Day" )
104+ )
105+ )
39106
40- # Good Friday
41- self ._add_good_friday ("Good Friday" )
107+ dts_observed .add (
108+ self ._add_holiday_dec_12 (
109+ # Jamhuri Day.
110+ tr ("Jamhuri Day" )
111+ if self ._year >= 2011
112+ # Independence Day.
113+ else tr ("Independence Day" )
114+ )
115+ )
42116
43- # Easter Monday
44- self ._add_easter_monday ( "Easter Monday" )
117+ # Christmas Day.
118+ dts_observed . add ( self ._add_christmas_day ( tr ( "Christmas Day" )) )
45119
46- # Labour Day
47- self . _add_observed (self ._add_labor_day ( "Labour Day" ))
120+ # Boxing Day.
121+ dts_observed . add (self ._add_christmas_day_two ( tr ( "Boxing Day") ))
48122
49- if self ._year >= 2010 :
50- # Mandaraka Day
51- self ._add_observed (self ._add_holiday_jun_1 ("Madaraka Day" ))
123+ # Eid-al-Fitr.
124+ dts_observed .update (self ._add_eid_al_fitr_day (tr ("Idd-ul-Fitr" )))
52125
53- if 2002 <= self ._year <= 2009 or self ._year >= 2018 :
54- self ._add_observed (
55- # Utamaduni/Moi Day
56- self ._add_holiday_oct_10 ("Utamaduni Day" if self ._year >= 2021 else "Moi Day" )
57- )
126+ if self .observed :
127+ self ._populate_observed (dts_observed )
58128
59- self ._add_observed (
60- # Mashuja/Kenyatta Day
61- self ._add_holiday_oct_20 ("Mashujaa Day" if self ._year >= 2010 else "Kenyatta Day" )
62- )
129+ def _populate_hindu_holidays (self ):
130+ """Additional Hindu public holidays."""
63131
64- # Jamhuri Day
65- self ._add_observed (self ._add_holiday_dec_12 ("Jamhuri Day" ))
132+ if self ._year >= 1984 :
133+ # Diwali.
134+ self ._add_diwali (tr ("Diwali" ))
66135
67- # Christmas Day
68- self . _add_observed ( self . _add_christmas_day ( "Christmas Day" ), rule = SUN_TO_NEXT_TUE )
136+ def _populate_islamic_holidays ( self ):
137+ """Additional Islamic public holidays."""
69138
70- # Boxing Day
71- self ._add_observed ( self . _add_christmas_day_two ( "Boxing Day " ))
139+ # Eid-al-Adha.
140+ self ._add_eid_al_adha_day ( tr ( "Idd-ul-Azha " ))
72141
73142
74143class KE (Kenya ):
@@ -79,15 +148,102 @@ class KEN(Kenya):
79148 pass
80149
81150
151+ class KenyaHinduHolidays (_CustomHinduHolidays ):
152+ DIWALI_DATES = {
153+ 2014 : (OCT , 22 ),
154+ 2015 : (NOV , 10 ),
155+ 2016 : (OCT , 29 ),
156+ 2017 : (OCT , 18 ),
157+ 2018 : (NOV , 6 ),
158+ 2019 : (OCT , 28 ),
159+ 2020 : (NOV , 14 ),
160+ 2021 : (NOV , 4 ),
161+ 2022 : (OCT , 24 ),
162+ 2023 : (NOV , 12 ),
163+ 2024 : (OCT , 31 ),
164+ }
165+
166+
167+ class KenyaIslamicHolidays (_CustomIslamicHolidays ):
168+ EID_AL_ADHA_DATES = {
169+ 2014 : (OCT , 6 ),
170+ 2015 : (SEP , 24 ),
171+ 2016 : (SEP , 12 ),
172+ 2017 : (SEP , 1 ),
173+ 2018 : (AUG , 21 ),
174+ 2019 : (AUG , 12 ),
175+ 2020 : (JUL , 31 ),
176+ 2021 : (JUL , 20 ),
177+ 2022 : (JUL , 11 ),
178+ 2023 : (JUN , 28 ),
179+ 2024 : (JUN , 17 ),
180+ }
181+
182+ EID_AL_FITR_DATES = {
183+ 2014 : (JUL , 29 ),
184+ 2015 : (JUL , 18 ),
185+ 2016 : (JUL , 7 ),
186+ 2017 : (JUN , 26 ),
187+ 2018 : (JUN , 15 ),
188+ 2019 : (JUN , 5 ),
189+ 2020 : (MAY , 25 ),
190+ 2021 : (MAY , 14 ),
191+ 2022 : (MAY , 3 ),
192+ 2023 : (APR , 21 ),
193+ 2024 : (APR , 10 ),
194+ }
195+
196+
82197class KenyaStaticHolidays :
198+ """
199+ References:
200+ - https://new.kenyalaw.org/akn/ke/officialGazette/2015-11-24/129/eng@2015-11-24
201+ - https://new.kenyalaw.org/akn/ke/officialGazette/2017-08-01/107/eng@2017-08-01
202+ - https://new.kenyalaw.org/akn/ke/officialGazette/2017-10-19/156/eng@2017-10-19
203+ - https://new.kenyalaw.org/akn/ke/officialGazette/2017-10-24/159/eng@2017-10-24
204+ - https://new.kenyalaw.org/akn/ke/officialGazette/2017-11-23/174/eng@2017-11-23
205+ - https://new.kenyalaw.org/akn/ke/officialGazette/gazette/2022-07-29/147/eng@2022-07-29
206+ - https://new.kenyalaw.org/akn/ke/officialGazette/gazette/2022-09-08/182/eng@2022-09-08
207+ - https://new.kenyalaw.org/akn/ke/officialGazette/gazette/2023-11-06/238/eng@2023-11-06
208+ - https://new.kenyalaw.org/akn/ke/officialGazette/gazette/2024-05-08/61/eng@2024-05-08
209+ - https://new.kenyalaw.org/akn/ke/officialGazette/2024-10-31/184/eng@2024-10-31
210+ """
211+
212+ # Election Day.
213+ election_day = tr ("Election Day" )
214+
215+ # Inauguration Day.
216+ inauguration_day = tr ("Inauguration Day" )
217+
218+ # Day of Mourning for Queen Elizabeth II.
219+ mourning_for_queen_elizabeth = tr ("Day of Mourning for Queen Elizabeth II" )
220+
221+ # National Tree Growing Day.
222+ national_tree_growing_day = tr ("National Tree Growing Day" )
223+
83224 special_public_holidays = {
84- 2020 : (FEB , 11 , "President Moi Celebration of Life Day" ),
225+ # Visit of Pope Francis to Kenya.
226+ 2015 : (NOV , 26 , tr ("Visit of Pope Francis to Kenya" )),
227+ 2017 : (
228+ (AUG , 8 , election_day ),
229+ (OCT , 25 , election_day ),
230+ (OCT , 26 , election_day ),
231+ (NOV , 28 , inauguration_day ),
232+ ),
233+ # President Moi Memorial Day.
234+ 2020 : (FEB , 11 , tr ("President Moi Memorial Day" )),
85235 2022 : (
86- (APR , 29 , "State Funeral for Former President Mwai Kibaki" ),
87- (AUG , 9 , "Election Day" ),
88- (SEP , 10 , "Day of Mourning for Queen Elizabeth II" ),
89- (SEP , 11 , "Day of Mourning for Queen Elizabeth II" ),
90- (SEP , 12 , "Day of Mourning for Queen Elizabeth II" ),
91- (SEP , 13 , "Inauguration Day" ),
236+ # State Funeral for Former President Mwai Kibaki.
237+ (APR , 29 , tr ("State Funeral for Former President Mwai Kibaki" )),
238+ (AUG , 9 , election_day ),
239+ (SEP , 10 , mourning_for_queen_elizabeth ),
240+ (SEP , 11 , mourning_for_queen_elizabeth ),
241+ (SEP , 12 , mourning_for_queen_elizabeth ),
242+ (SEP , 13 , inauguration_day ),
243+ ),
244+ 2023 : (NOV , 13 , national_tree_growing_day ),
245+ 2024 : (
246+ (MAY , 10 , national_tree_growing_day ),
247+ (NOV , 1 , inauguration_day ),
92248 ),
93249 }
0 commit comments