Skip to content

Commit

Permalink
Added several one-off public holidays to UK calendar.
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Barran authored and brunobord committed Mar 15, 2019
1 parent 3b0f712 commit 5b6e6fe
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 11 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Expand Up @@ -5,6 +5,7 @@
- Added isolated tests for shifting mechanics in USA calendars - previously untested (#335).
- Added Barbados by @ludsoft.
- Added Berlin specific holidays (#340).
- Added several one-off public holidays to UK calendar (#366).

## v4.2.0 (2019-02-21)

Expand Down
7 changes: 7 additions & 0 deletions workalendar/europe/united_kingdom.py
Expand Up @@ -16,7 +16,12 @@ class UnitedKingdom(WesternCalendar, ChristianMixin):
include_boxing_day = True
shift_new_years_day = True
non_computable_holiday_dict = {
1973: [(date(1973, 11, 14), "Royal wedding"), ],
1977: [(date(1977, 6, 7), "Queen’s Silver Jubilee"), ],
1981: [(date(1981, 7, 29), "Royal wedding"), ],
1999: [(date(1999, 12, 31), "New Year's Eve"), ],
2002: [(date(2002, 6, 3), "Queen’s Golden Jubilee"), ],
2011: [(date(2011, 4, 29), "Royal Wedding"), ],
2012: [(date(2012, 6, 5), "Queen’s Diamond Jubilee"), ],
}

Expand All @@ -29,6 +34,8 @@ def get_early_may_bank_holiday(self, year):
def get_spring_bank_holiday(self, year):
if year == 2012:
spring_bank_holiday = date(2012, 6, 4)
elif year == 1977:
spring_bank_holiday = date(1977, 6, 6)
elif year == 2002:
spring_bank_holiday = date(2002, 6, 4)
else:
Expand Down
43 changes: 32 additions & 11 deletions workalendar/tests/test_europe.py
Expand Up @@ -815,17 +815,22 @@ def test_year_2018(self):
class UnitedKingdomTest(GenericCalendarTest):
cal_class = UnitedKingdom

def test_year_2013(self):
holidays = self.cal.holidays_set(2013)
self.assertIn(date(2013, 1, 1), holidays) # new year day
self.assertIn(date(2013, 3, 29), holidays) # good friday
self.assertIn(date(2013, 3, 31), holidays) # easter sunday
self.assertIn(date(2013, 4, 1), holidays) # easter monday
self.assertIn(date(2013, 5, 6), holidays) # Early May Bank Holiday
self.assertIn(date(2013, 5, 27), holidays) # Spring Bank Holiday
self.assertIn(date(2013, 8, 26), holidays) # Late Summer Bank Holiday
self.assertIn(date(2013, 12, 25), holidays) # Christmas
self.assertIn(date(2013, 12, 26), holidays) # Boxing Day
def test_year_1973(self):
holidays = self.cal.holidays_set(1973)
self.assertIn(date(1973, 11, 14), holidays) # royal wedding

def test_year_1977(self):
holidays = self.cal.holidays_set(1977)
self.assertIn(date(1977, 6, 6), holidays) # Early May Bank Holiday
self.assertIn(date(1977, 6, 7), holidays) # queen's silver jubilee

def test_year_1981(self):
holidays = self.cal.holidays_set(1981)
self.assertIn(date(1981, 7, 29), holidays) # royal wedding

def test_year_1999(self):
holidays = self.cal.holidays_set(1999)
self.assertIn(date(1999, 12, 31), holidays) # new year's eve

def test_year_2002(self):
holidays = self.cal.holidays_set(2002)
Expand All @@ -840,6 +845,10 @@ def test_year_2002(self):
self.assertIn(date(2002, 12, 25), holidays) # Christmas
self.assertIn(date(2002, 12, 26), holidays) # Boxing Day

def test_year_2011(self):
holidays = self.cal.holidays_set(2011)
self.assertIn(date(2011, 4, 29), holidays) # royal wedding

def test_year_2012(self):
holidays = self.cal.holidays_set(2012)
self.assertIn(date(2012, 1, 1), holidays) # new year day
Expand All @@ -854,6 +863,18 @@ def test_year_2012(self):
self.assertIn(date(2012, 12, 25), holidays) # Christmas
self.assertIn(date(2012, 12, 26), holidays) # Boxing Day

def test_year_2013(self):
holidays = self.cal.holidays_set(2013)
self.assertIn(date(2013, 1, 1), holidays) # new year day
self.assertIn(date(2013, 3, 29), holidays) # good friday
self.assertIn(date(2013, 3, 31), holidays) # easter sunday
self.assertIn(date(2013, 4, 1), holidays) # easter monday
self.assertIn(date(2013, 5, 6), holidays) # Early May Bank Holiday
self.assertIn(date(2013, 5, 27), holidays) # Spring Bank Holiday
self.assertIn(date(2013, 8, 26), holidays) # Late Summer Bank Holiday
self.assertIn(date(2013, 12, 25), holidays) # Christmas
self.assertIn(date(2013, 12, 26), holidays) # Boxing Day

def test_shift_2012(self):
holidays = self.cal.holidays_set(2012)
self.assertIn(date(2012, 1, 1), holidays) # new year day
Expand Down

0 comments on commit 5b6e6fe

Please sign in to comment.