Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update China's public holidays for 2023. #728

Merged
merged 1 commit into from Jan 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions Changelog.md
Expand Up @@ -9,6 +9,7 @@
- Added support for Python 3.11 (#732).
- New calendar: Added Tunisia calendar by @macharmi (#702)
- New calendar: Added El Salvador calendar by @hersoncruz (#708).
- Update China's public holidays for 2023 (#728).

## v16.4.0 (2022-09-16)

Expand Down
26 changes: 21 additions & 5 deletions workalendar/asia/china.py
Expand Up @@ -42,6 +42,14 @@
'Dragon Boat Festival': [(6, 3), (6, 4), (6, 5)],
'Mid-Autumn Festival': [(9, 10), (9, 11), (9, 12)]
},
2023:
{
'Ching Ming Festival': [(4, 5)],
'Labour Day Holiday': [(4, 29), (4, 30), (5, 1), (5, 2), (5, 3)],
'Dragon Boat Festival': [(6, 22), (6, 23), (6, 24)],
'Mid-Autumn Festival': [(9, 29)],
'National Day': [(9, 30)]
},
}

workdays = {
Expand Down Expand Up @@ -80,18 +88,21 @@
'Labour Day Holiday Shift': [(4, 24), (5, 7)],
'National Day Shift': [(10, 8), (10, 9)]
},
2023:
{
'Spring Festival Shift': [(1, 28), (1, 29)],
'Labour Day Holiday Shift': [(4, 23), (5, 6)],
'Dragon Boat Festival Shift': [(6, 25)],
'National Day Shift': [(10, 7), (10, 8)]
},
}


@iso_register('CN')
class China(ChineseNewYearCalendar):
"China"
# WARNING: Support 2018-2022 currently, need update every year.
# WARNING: Support 2018-2023 currently, need update every year.
shift_new_years_day = True
# National Days, 10.1 - 10.7
national_days = [(10, i, "National Day") for i in range(1, 8)]
FIXED_HOLIDAYS = tuple(national_days)

include_chinese_new_year_eve = True

def __init__(self, *args, **kwargs):
Expand Down Expand Up @@ -119,6 +130,11 @@ def get_variable_days(self, year):
for i in range(2, 7):
days.append((ChineseNewYearCalendar.lunar(year, 1, i),
"Spring Festival"))
# National Days, 10.1 - 10.7 in general
for i in range(1, 8):
if date(year, 10, i) not in self.extra_working_days:
days.append((date(year, 10, i), "National Day"))

# other holidays
for holiday_name, day_list in holidays[year].items():
for v in day_list:
Expand Down
23 changes: 22 additions & 1 deletion workalendar/tests/test_asia.py
Expand Up @@ -113,6 +113,27 @@ def test_year_2022(self):
self.assertNotIn(date(2022, 10, 8), holidays) # National Day Shift
self.assertNotIn(date(2022, 10, 9), holidays) # National Day Shift

def test_year_2023(self):
holidays = self.cal.holidays_set(2023)
self.assertIn(date(2023, 1, 2), holidays) # New Year
self.assertIn(date(2023, 1, 21), holidays) # Spring Festival
self.assertIn(date(2023, 1, 27), holidays) # Spring Festival
self.assertIn(date(2023, 4, 5), holidays) # Ching Ming Festival
self.assertIn(date(2023, 4, 29), holidays) # Labour Day Holiday
self.assertIn(date(2023, 5, 3), holidays) # Labour Day Holiday
self.assertIn(date(2023, 6, 22), holidays) # Dragon Boat Festival
self.assertIn(date(2023, 6, 24), holidays) # Dragon Boat Festival
self.assertIn(date(2023, 9, 29), holidays) # Mid-Autumn Festival
self.assertIn(date(2023, 9, 30), holidays) # National Day
self.assertIn(date(2023, 10, 6), holidays) # National Day

self.assertNotIn(date(2023, 1, 28), holidays) # Spring Festival Shift
self.assertNotIn(date(2023, 1, 29), holidays) # Spring Festival Shift
self.assertNotIn(date(2023, 4, 23), holidays) # Labour Day Shift
self.assertNotIn(date(2023, 5, 6), holidays) # Labour Day Shift
self.assertNotIn(date(2023, 10, 7), holidays) # National Day Shift
self.assertNotIn(date(2023, 10, 8), holidays) # National Day Shift

def test_missing_holiday_year(self):
save_2018 = china_holidays[2018]
del china_holidays[2018]
Expand All @@ -125,7 +146,7 @@ def test_warning(self):
with patch('warnings.warn') as patched:
self.cal.get_calendar_holidays(year)
patched.assert_called_with(
'Support years 2018-2022 currently, need update every year.'
'Support years 2018-2023 currently, need update every year.'
)

def test_is_working_day(self):
Expand Down