Fixing duplicated holidays in Hong-Kong and Hong-Kong Bank holiday calendars

refs #496
This commit is contained in:
Bruno Bord 2020-05-22 11:27:52 +02:00
parent 3c6d7169b8
commit d6536522a2
No known key found for this signature in database
GPG Key ID: 9499EA6788BF80A1
3 changed files with 10 additions and 9 deletions

View File

@ -3,6 +3,7 @@
## master (unreleased)
- Making the Israel calendar more efficient (#498).
- Fixing duplicated holidays in Hong-Kong and Hong-Kong Bank holiday calendars (#496).
## v9.0.0 (2020-04-24)

View File

@ -59,20 +59,14 @@ class HongKong(WesternCalendar, ChineseNewYearCalendar, ChristianMixin):
(ChineseNewYearCalendar.lunar(year, 9, 9), "Chung Yeung Festival"),
])
# Shifting all potential holidays that fall on SUN.
shifts = []
for day, label in days:
if day.weekday() == SUN:
shifts.append((
day + timedelta(days=1), "{} (shift)".format(label)
))
# All holidays that fall on SUN are shifted in
# ``ChineseNewYearCalendar.get_calendar_holidays()``
# Special case for Boxing Day.
# If Christmas day is on SUN, the December 27th is also a holiday
if date(year, 12, 25).weekday() == SUN:
shifts.append(
days.append(
(date(year, 12, 27), "The second weekday after Christmas")
)
days.extend(shifts)
return days

View File

@ -257,6 +257,12 @@ class HongKongBankTest(HongKongTest):
date(2020, 2, 13)
)
def test_no_duplicate_days(self):
holidays = self.cal.holidays(2021)
labels = list(day[1] for day in holidays)
labels_dedup = list(set(labels))
assert sorted(labels) == sorted(labels_dedup)
class JapanTest(GenericCalendarTest):