Skip to content

Commit

Permalink
0.9.6
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-prodigy committed Aug 1, 2018
1 parent 0843d76 commit eca5f11
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 32 deletions.
9 changes: 9 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
Version 0.9.6
=============

Released August 1, 2018

- Added India (Shaurya Uppal)
- Fixed Canadian holidays (Canada / Dominion Day)
- Fixed German holidays (Buß- und Bettag, Ostern, Pfingsten)

Version 0.9.5
=============

Expand Down
9 changes: 5 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,12 @@ France FRA **Métropole** (default), Alsace-Moselle, Guadeloup
Martinique, Mayotte, Nouvelle-Calédonie, La Réunion,
Polynésie Française, Saint-Barthélémy, Saint-Martin,
Wallis-et-Futuna
Germany DE BW, BY, BE, BB, HB, HH, HE, MV, NI, NW, RP, SL, SN, ST,
SH, TH
Germany DE prov = BW, BY, BE, BB, HB, HH, HE, MV, NI, NW, RP, SL, SN,
ST, SH, TH
Hungary HU None
India IND AS, SK, CG, KA, GJ, BR, RJ, OD, TN, AP, WB, KL, HR, MH, MP, UP, UK, TN
Ireland IE
India IND prov = AS, SK, CG, KA, GJ, BR, RJ, OD, TN, AP, WB, KL, HR,
MH, MP, UP, UK, TN
Ireland IE None
Isle of Man None
Italy IT prov = MI, RM
Japan JP None
Expand Down
38 changes: 22 additions & 16 deletions holidays.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from dateutil.relativedelta import MO, TU, WE, TH, FR, SA, SU
import six

__version__ = '0.9.5'
__version__ = '0.9.6'


MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY = range(7)
Expand Down Expand Up @@ -452,14 +452,22 @@ def _populate(self, year):

# Canada Day / Memorial Day (NL)
if self.prov != 'NL' and year >= 1867:
name = "Canada Day"
if year >= 1983:
name = "Canada Day"
else:
name = "Dominion Day"
self[date(year, 7, 1)] = name
if self.observed and date(year, 7, 1).weekday() in (5, 6):
if year >= 1879 and self.observed \
and date(year, 7, 1).weekday() in (5, 6):
self[date(year, 7, 1) + rd(weekday=MO)] = name + " (Observed)"
elif year >= 1867:
name = "Memorial Day"
if year >= 1983:
name = "Memorial Day"
else:
name = "Dominion Day"
self[date(year, 7, 1)] = name
if self.observed and date(year, 7, 1).weekday() in (5, 6):
if year >= 1879 and self.observed \
and date(year, 7, 1).weekday() in (5, 6):
self[date(year, 7, 1) + rd(weekday=MO)] = name + " (Observed)"

# Nunavut Day
Expand Down Expand Up @@ -1707,23 +1715,21 @@ def _populate(self, year):

self[easter(year) - rd(days=2)] = 'Karfreitag'

if self.prov == 'BB':
# will always be a Sunday and we have no "observed" rule so
# this is pretty pointless but it's nonetheless an official
# holiday by law
self[easter(year)] = 'Ostern'
# will always be a Sunday and we have no "observed" rule so
# this is pretty pointless but it's nonetheless an official
# holiday by law
self[easter(year)] = 'Ostern'

self[easter(year) + rd(days=1)] = 'Ostermontag'

self[date(year, 5, 1)] = 'Maifeiertag'

self[easter(year) + rd(days=39)] = 'Christi Himmelfahrt'

if self.prov == 'BB':
# will always be a Sunday and we have no "observed" rule so
# this is pretty pointless but it's nonetheless an official
# holiday by law
self[easter(year) + rd(days=49)] = 'Pfingsten'
# will always be a Sunday and we have no "observed" rule so
# this is pretty pointless but it's nonetheless an official
# holiday by law
self[easter(year) + rd(days=49)] = 'Pfingsten'

self[easter(year) + rd(days=50)] = 'Pfingstmontag'

Expand All @@ -1746,7 +1752,7 @@ def _populate(self, year):
if self.prov in ('BW', 'BY', 'NW', 'RP', 'SL'):
self[date(year, 11, 1)] = 'Allerheiligen'

if self.prov == 'SN':
if (year >= 1990 and year <= 1994) or self.prov == 'SN':
# can be calculated as "last wednesday before year-11-23" which is
# why we need to go back two wednesdays if year-11-23 happens to be
# a wednesday
Expand Down
22 changes: 10 additions & 12 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ def test_add(self):
self.assertIn("2015-02-16", a)
na = holidays.CA() + holidays.US() + holidays.MX()
self.assertIn(date(1969, 12, 25), na)
self.assertEqual(na.get(date(1969, 7, 1)), "Canada Day")
self.assertEqual(na.get(date(1969, 7, 1)), "Dominion Day")
self.assertEqual(na.get(date(1983, 7, 1)), "Canada Day")
self.assertEqual(na.get(date(1969, 12, 25)),
"Christmas Day, Navidad [Christmas]")
na = holidays.MX() + holidays.CA() + holidays.US()
Expand Down Expand Up @@ -204,7 +205,7 @@ def test_get_list(self):
self.assertIn(date(1969, 12, 25), na)
self.assertEqual(na.get_list(date(1969, 12, 25)),
["Christmas Day", "Navidad [Christmas]"])
self.assertEqual(na.get_list(date(1969, 7, 1)), ["Canada Day"])
self.assertEqual(na.get_list(date(1969, 7, 1)), ["Dominion Day"])
self.assertEqual(na.get_list(date(1969, 1, 3)), [])

def test_radd(self):
Expand Down Expand Up @@ -333,6 +334,11 @@ def test_observed(self):
self.holidays = holidays.US(years=[2022], observed=False)
self.assertNotIn(date(2021, 12, 31), self.holidays.keys())

self.holidays = holidays.CA(observed=False)
self.assertNotIn(date(1878, 7, 3), self.holidays)
self.holidays.observed = True
self.assertIn(date(2018, 7, 2), self.holidays)


class TestKeyTransforms(unittest.TestCase):

Expand Down Expand Up @@ -2457,13 +2463,9 @@ def test_ostern(self):
(2017, 4, 16), (2018, 4, 1), (2019, 4, 21),
(2020, 4, 12), (2021, 4, 4), (2022, 4, 17),
(2023, 4, 9), (2024, 3, 31)]
provinces_that_have = {'BB'}
provinces_that_dont = set(holidays.DE.PROVINCES) - provinces_that_have

for province, (y, m, d) in product(provinces_that_have, known_good):
for province, (y, m, d) in product(holidays.DE.PROVINCES, known_good):
self.assertIn(date(y, m, d), self.prov_hols[province])
for province, (y, m, d) in product(provinces_that_dont, known_good):
self.assertNotIn(date(y, m, d), self.prov_hols[province])

def test_ostermontag(self):
known_good = [(2014, 4, 21), (2015, 4, 6), (2016, 3, 28),
Expand All @@ -2488,13 +2490,9 @@ def test_pfingsten(self):
(2017, 6, 4), (2018, 5, 20), (2019, 6, 9),
(2020, 5, 31), (2021, 5, 23), (2022, 6, 5),
(2023, 5, 28), (2024, 5, 19)]
provinces_that_have = {'BB'}
provinces_that_dont = set(holidays.DE.PROVINCES) - provinces_that_have

for province, (y, m, d) in product(provinces_that_have, known_good):
for province, (y, m, d) in product(holidays.DE.PROVINCES, known_good):
self.assertIn(date(y, m, d), self.prov_hols[province])
for province, (y, m, d) in product(provinces_that_dont, known_good):
self.assertNotIn(date(y, m, d), self.prov_hols[province])

def test_pfingstmontag(self):
known_good = [(2014, 6, 9), (2015, 5, 25), (2016, 5, 16),
Expand Down

0 comments on commit eca5f11

Please sign in to comment.