Integrating Hong-Kong holidays for 2021

refs #496
This commit is contained in:
Bruno Bord 2020-05-22 12:06:59 +02:00
parent f9593d3da5
commit d5403b563c
No known key found for this signature in database
GPG Key ID: 9499EA6788BF80A1
3 changed files with 35 additions and 1 deletions

View File

@ -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)

View File

@ -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

View File

@ -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)