Fixing duplicated holidays in Hong-Kong and Hong-Kong Bank holiday calendars
refs #496
This commit is contained in:
parent
3c6d7169b8
commit
d6536522a2
|
@ -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)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
||||
|
|
Loading…
Reference in New Issue