Skip to content

Commit 1518287

Browse files
committed
Added support for Iceland and Kenya (vacanza#203), doc updates
1 parent 848e992 commit 1518287

4 files changed

Lines changed: 117 additions & 0 deletions

File tree

CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Released ????? ??, ????
66
- Added Japanese holidays for new Emperor (kokinamura)
77
- Fixed Australian Canberra day holiday (explodingdinosaurs, dr-p)
88
- Added support for Estonian holidays (RaulVS14)
9+
- Added support for Iceland and Kenya (justinasfour04)
910

1011
Version 0.9.10
1112
==============

README.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ Croatia HR None
112112
Czech CZ None
113113
Denmark DK None
114114
England None
115+
Estonia EE None
115116
EuropeanCentralBank ECB,TAR Trans-European Automated Real-time Gross Settlement (TARGET2)
116117
Finland FI None
117118
France FRA **Métropole** (default), Alsace-Moselle, Guadeloupe, Guyane,
@@ -121,6 +122,7 @@ France FRA **Métropole** (default), Alsace-Moselle, Guadeloup
121122
Germany DE prov = BW, BY, BE, BB, HB, HH, HE, MV, NI, NW, RP, SL, SN,
122123
ST, SH, TH
123124
Hungary HU None
125+
Iceland IS None
124126
India IND prov = AS, SK, CG, KA, GJ, BR, RJ, OD, TN, AP, WB, KL, HR,
125127
MH, MP, UP, UK, TN
126128
Ireland IE None
@@ -129,6 +131,7 @@ Italy IT prov = AN, AO, BA, BL, BO, BS, BZ, CB, Cesena, CH,
129131
EN, FC, FE, FI, Forlì, FR, GE, GO, IS, KR, LT, MB, MI, MO,
130132
MN, MS, NA, PA, PC, PD, PG, PR, RM, SP, TS, VI
131133
Japan JP None
134+
Kenya KE None
132135
Lithuania LT None
133136
Luxembourg LU None
134137
Mexico MX None

holidays.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4433,3 +4433,64 @@ def _populate(self, year):
44334433

44344434
class EE(Estonia):
44354435
pass
4436+
4437+
4438+
class Iceland(HolidayBase):
4439+
# https://en.wikipedia.org/wiki/Public_holidays_in_Iceland
4440+
# https://www.officeholidays.com/countries/iceland/index.php
4441+
def __init__(self, **kwargs):
4442+
self.country = "IS"
4443+
HolidayBase.__init__(self, **kwargs)
4444+
4445+
def _populate(self, year):
4446+
# Public holidays
4447+
self[date(year, JAN, 1)] = "Nýársdagur"
4448+
self[easter(year) - rd(days=3)] = "Skírdagur"
4449+
self[easter(year)] = "Páskadagur"
4450+
self[easter(year) + rd(days=1)] = "Annar í páskum"
4451+
self[date(year, APR, 19) + rd(weekday=TH(+1))] = \
4452+
"Sumardagurinn fyrsti"
4453+
self[date(year, MAY, 1)] = "Verkalýðsdagurinn"
4454+
self[easter(year) + rd(days=39)] = "Uppstigningardagur"
4455+
self[easter(year) + rd(days=49)] = "Hvítasunnudagur"
4456+
self[easter(year) + rd(days=50)] = "Annar í hvítasunnu"
4457+
self[date(year, JUN, 17)] = "Þjóðhátíðardagurinn"
4458+
# First Monday of August
4459+
self[date(year, AUG, 1) + rd(weekday=MO(+1))] = \
4460+
"Frídagur verslunarmanna"
4461+
self[date(year, DEC, 24)] = "Aðfangadagur"
4462+
self[date(year, DEC, 25)] = "Jóladagur"
4463+
self[date(year, DEC, 26)] = "Annar í jólum"
4464+
self[date(year, DEC, 31)] = "Gamlársdagur"
4465+
4466+
4467+
class IS(Iceland):
4468+
pass
4469+
4470+
4471+
class Kenya(HolidayBase):
4472+
# https://en.wikipedia.org/wiki/Public_holidays_in_Kenya
4473+
# http://kenyaembassyberlin.de/Public-Holidays-in-Kenya.48.0.html
4474+
def __init__(self, **kwargs):
4475+
self.country = "KE"
4476+
HolidayBase.__init__(self, **kwargs)
4477+
4478+
def _populate(self, year):
4479+
# Public holidays
4480+
self[date(year, JAN, 1)] = "New Year's Day"
4481+
self[date(year, MAY, 1)] = "Labour Day"
4482+
self[date(year, JUN, 1)] = "Madaraka Day"
4483+
self[date(year, OCT, 20)] = "Mashujaa Day"
4484+
self[date(year, DEC, 12)] = "Jamhuri (Independence) Day"
4485+
self[date(year, DEC, 25)] = "Christmas Day"
4486+
self[date(year, DEC, 26)] = "Boxing Day"
4487+
for k, v in list(self.items()):
4488+
if self.observed and k.weekday() == SUN:
4489+
self[k + rd(days=1)] = v + " (Observed)"
4490+
4491+
self[easter(year) - rd(weekday=FR(-1))] = "Good Friday"
4492+
self[easter(year) + rd(weekday=MO(+1))] = "Easter Monday"
4493+
4494+
4495+
class KE(Kenya):
4496+
pass

tests.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5058,5 +5058,57 @@ def test_boxing_day(self):
50585058
self.assertIn(test_date, self.holidays)
50595059

50605060

5061+
class TestIceland(unittest.TestCase):
5062+
def setUp(self):
5063+
self.holidays = holidays.Iceland()
5064+
self.cur_date = datetime.now()
5065+
5066+
def test_new_year(self):
5067+
test_date = date(self.cur_date.year, 1, 1)
5068+
self.assertEqual(self.holidays.get(test_date), "Nýársdagur")
5069+
self.assertIn(test_date, self.holidays)
5070+
5071+
def test_maundy_thursday(self):
5072+
test_date = date(self.cur_date.year, 4, 18)
5073+
self.assertEqual(self.holidays.get(test_date), "Skírdagur")
5074+
self.assertIn(test_date, self.holidays)
5075+
5076+
def test_first_day_of_summer(self):
5077+
test_date = date(self.cur_date.year, 4, 25)
5078+
self.assertEqual(self.holidays.get(test_date), "Sumardagurinn fyrsti")
5079+
self.assertIn(test_date, self.holidays)
5080+
5081+
def test_commerce_day(self):
5082+
test_date = date(self.cur_date.year, 8, 5)
5083+
self.assertEqual(self.holidays.get(test_date),
5084+
"Frídagur verslunarmanna")
5085+
self.assertIn(test_date, self.holidays)
5086+
5087+
5088+
class TestKenya(unittest.TestCase):
5089+
def setUp(self):
5090+
self.holidays = holidays.Kenya()
5091+
5092+
def test_2019(self):
5093+
# New Year's Day
5094+
self.assertIn(date(2019, 1, 1), self.holidays)
5095+
# Good Friday
5096+
self.assertIn(date(2019, 4, 19), self.holidays)
5097+
# Easter Monday
5098+
self.assertIn(date(2019, 4, 22), self.holidays)
5099+
# Labour Day
5100+
self.assertIn(date(2019, 5, 1), self.holidays)
5101+
# Madaraka Day
5102+
self.assertIn(date(2019, 6, 1), self.holidays)
5103+
# Mashujaa Day
5104+
self.assertIn(date(2019, 10, 20), self.holidays)
5105+
# Jamhuri (Independence) Day
5106+
self.assertIn(date(2019, 12, 12), self.holidays)
5107+
# Christmas Day
5108+
self.assertIn(date(2019, 12, 25), self.holidays)
5109+
# Boxing Day
5110+
self.assertIn(date(2018, 12, 26), self.holidays)
5111+
5112+
50615113
if __name__ == "__main__":
50625114
unittest.main()

0 commit comments

Comments
 (0)