From 5b6e6fe352bc63f9cf7c284ac6bc5f79736a5d75 Mon Sep 17 00:00:00 2001 From: Richard Barran Date: Sun, 10 Mar 2019 17:00:52 +0100 Subject: [PATCH] Added several one-off public holidays to UK calendar. --- Changelog.md | 1 + workalendar/europe/united_kingdom.py | 7 +++++ workalendar/tests/test_europe.py | 43 +++++++++++++++++++++------- 3 files changed, 40 insertions(+), 11 deletions(-) diff --git a/Changelog.md b/Changelog.md index 1537de9e..f3039c9b 100644 --- a/Changelog.md +++ b/Changelog.md @@ -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) diff --git a/workalendar/europe/united_kingdom.py b/workalendar/europe/united_kingdom.py index f90d62c7..da7e7ebb 100644 --- a/workalendar/europe/united_kingdom.py +++ b/workalendar/europe/united_kingdom.py @@ -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"), ], } @@ -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: diff --git a/workalendar/tests/test_europe.py b/workalendar/tests/test_europe.py index d7a3d6b5..6dc73a67 100644 --- a/workalendar/tests/test_europe.py +++ b/workalendar/tests/test_europe.py @@ -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) @@ -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 @@ -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