From d5403b563c75f4c0d91d24f579e377d503107c01 Mon Sep 17 00:00:00 2001 From: Bruno Bord Date: Fri, 22 May 2020 12:06:59 +0200 Subject: [PATCH] Integrating Hong-Kong holidays for 2021 refs #496 --- Changelog.md | 1 + workalendar/asia/hong_kong.py | 10 ++++++++++ workalendar/tests/test_asia.py | 25 ++++++++++++++++++++++++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index cfca698..e728b77 100644 --- a/Changelog.md +++ b/Changelog.md @@ -4,6 +4,7 @@ - Making the Israel calendar more efficient (#498). - Fixing duplicated holidays in Hong-Kong and Hong-Kong Bank holiday calendars (#496). +- Integrating Hong-Kong holidays for 2021 (#496). ## v9.0.0 (2020-04-24) diff --git a/workalendar/asia/hong_kong.py b/workalendar/asia/hong_kong.py index ddaa4e9..158ddbe 100644 --- a/workalendar/asia/hong_kong.py +++ b/workalendar/asia/hong_kong.py @@ -46,6 +46,7 @@ class HongKong(WesternCalendar, ChineseNewYearCalendar, ChristianMixin): days = super().get_variable_days(year) chingming = solar_term(year, 15, 'Asia/Hong_Kong') + solar_term_chingming = chingming dupe_holiday = [chingming for day in days if chingming == day[0]] if dupe_holiday: # Roll Chingming forward a day as it clashes with another holiday @@ -68,6 +69,15 @@ class HongKong(WesternCalendar, ChineseNewYearCalendar, ChristianMixin): (date(year, 12, 27), "The second weekday after Christmas") ) + # Special case when Ching Ming and Easter overlap + # Ching Ming is shifted to easter monday (but it's handled elsewhere) + # Easter Monday is also shifted + easter_sunday = self.get_easter_sunday(year) + if easter_sunday == solar_term_chingming: + days.append(( + easter_sunday + timedelta(days=2), + "The day following Easter Monday" + )) return days diff --git a/workalendar/tests/test_asia.py b/workalendar/tests/test_asia.py index 2b5352f..f3acd30 100644 --- a/workalendar/tests/test_asia.py +++ b/workalendar/tests/test_asia.py @@ -215,7 +215,7 @@ class HongKongTest(GenericCalendarTest): def test_holidays_2020(self): # https://www.gov.hk/en/about/abouthk/holiday/2020.htm holidays = self.cal.holidays_set(2020) - self.assertIn(date(2020, 1, 1), holidays) # New Year (shifted) + self.assertIn(date(2020, 1, 1), holidays) # New Year self.assertIn(date(2020, 1, 25), holidays) # Chinese new year self.assertIn(date(2020, 1, 27), holidays) # Chinese new year self.assertIn(date(2020, 1, 28), holidays) # Chinese new year @@ -235,6 +235,29 @@ class HongKongTest(GenericCalendarTest): # Special: Boxing day is not shifted, because it's not a SUN self.assertNotIn(date(2020, 12, 28), holidays) + def test_holidays_2021(self): + # https://www.gov.hk/en/about/abouthk/holiday/2021.htm + holidays = self.cal.holidays_set(2021) + self.assertIn(date(2021, 1, 1), holidays) # New Year + self.assertIn(date(2021, 2, 12), holidays) # Chinese new year + self.assertIn(date(2021, 2, 13), holidays) # Chinese new year + self.assertIn(date(2021, 2, 14), holidays) # Chinese new year (SUN) + self.assertIn(date(2021, 2, 15), holidays) # Chinese new year + self.assertIn(date(2021, 4, 2), holidays) # Good Friday + self.assertIn(date(2021, 4, 3), holidays) # Day after Good Friday + self.assertIn(date(2021, 4, 4), holidays) # Ching Ming + self.assertIn(date(2021, 4, 5), holidays) # Ching Ming shift+Easter + self.assertIn(date(2021, 4, 6), holidays) # Day after Easter Monday + self.assertIn(date(2021, 5, 1), holidays) # Labour Day + self.assertIn(date(2021, 5, 19), holidays) # Buddha's Birthday + self.assertIn(date(2021, 6, 14), holidays) # Tuen Ng Festival + self.assertIn(date(2021, 7, 1), holidays) # HK SAR Establishment Day + self.assertIn(date(2021, 9, 22), holidays) # Day after Mid-Autumn + self.assertIn(date(2021, 10, 1), holidays) # National Day + self.assertIn(date(2021, 10, 14), holidays) # Chung Yeung Festival + self.assertIn(date(2021, 12, 25), holidays) # Christmas Day + self.assertIn(date(2021, 12, 27), holidays) # First weekday after Xmas + def test_are_saturdays_working_days(self): # Let's start with february 6th. start = date(2020, 2, 6)