From dacd89061eb3bb2fb8dda3287e49fce49df793f4 Mon Sep 17 00:00:00 2001 From: ~Jhellico Date: Fri, 27 Sep 2024 19:44:49 +0300 Subject: [PATCH] Update Taiwan holidays --- holidays/countries/taiwan.py | 40 ++++++++++++++++++++++-------- snapshots/countries/TW_COMMON.json | 21 +++++++++++----- tests/countries/test_taiwan.py | 28 ++++++++++++++++++--- 3 files changed, 70 insertions(+), 19 deletions(-) diff --git a/holidays/countries/taiwan.py b/holidays/countries/taiwan.py index a2d9f51ae..bb520a01e 100644 --- a/holidays/countries/taiwan.py +++ b/holidays/countries/taiwan.py @@ -14,7 +14,24 @@ from gettext import gettext as tr from typing import Set -from holidays.calendars.gregorian import JAN, FEB, MAR, APR, MAY, JUN, SEP, OCT, DEC +from holidays.calendars.gregorian import ( + JAN, + FEB, + MAR, + APR, + MAY, + JUN, + SEP, + OCT, + DEC, + MON, + TUE, + WED, + THU, + FRI, + SAT, + SUN, +) from holidays.groups import ChineseCalendarHolidays, InternationalHolidays, StaticHolidays from holidays.observed_holiday_base import ( ObservedHolidayBase, @@ -24,12 +41,14 @@ SAT_SUN_TO_NEXT_WORKDAY, ) +CHILDRENS_DAY_RULE = ObservedRule({MON: +1, TUE: -1, WED: -1, THU: +1, FRI: -1, SAT: -1, SUN: -2}) + class Taiwan(ObservedHolidayBase, ChineseCalendarHolidays, InternationalHolidays, StaticHolidays): """ References: - https://en.wikipedia.org/wiki/Public_holidays_in_Taiwan - - https://www.officeholidays.com/countries/taiwan + - `2025 `_ - `2024 `_ - `2023 `_ - `2022 `_ @@ -65,9 +84,15 @@ def _populate_observed( ) -> None: if self._year < since: return None + + childrens_day = self.tr("兒童節") for dt in sorted(dts): for name in self.get_list(dt): - self._add_observed(dt, name, rule) + if name == childrens_day and len(self.get_list(dt)) > 1: + # Children’s Day falls on the same day as Tomb Sweeping Day. + self._add_observed(dt, name, CHILDRENS_DAY_RULE) + else: + self._add_observed(dt, name, rule) def _populate_public_holidays(self): if self._year <= 1911: @@ -97,9 +122,7 @@ def _populate_public_holidays(self): if 1990 <= self._year <= 1999 or self._year >= 2011: # Children's Day. - apr_4 = self._add_holiday_apr_4(tr("兒童節")) - if self._year != 2021: - dts_observed.add(apr_4) + dts_observed.add(self._add_holiday_apr_4(tr("兒童節"))) if self._year >= 1972: # Tomb Sweeping Day. @@ -185,12 +208,9 @@ class TaiwanStaticHolidays: (OCT, 9, SEP, 23), ), 2024: (FEB, 8, FEB, 17), + 2025: (JAN, 27, FEB, 8), } special_public_holidays_observed = { 2013: (APR, 5, childrens_day), - 2016: (APR, 5, childrens_day), - 2017: (APR, 3, childrens_day), - 2021: (APR, 2, childrens_day), - 2024: (APR, 5, childrens_day), } diff --git a/snapshots/countries/TW_COMMON.json b/snapshots/countries/TW_COMMON.json index b203e0bd4..ad0158545 100644 --- a/snapshots/countries/TW_COMMON.json +++ b/snapshots/countries/TW_COMMON.json @@ -716,8 +716,7 @@ "2021-03-01": "Peace Memorial Day (observed)", "2021-04-02": "Children's Day (observed)", "2021-04-04": "Children's Day; Tomb Sweeping Day", - "2021-04-05": "Children's Day (observed)", - "2021-04-06": "Tomb Sweeping Day (observed)", + "2021-04-05": "Tomb Sweeping Day (observed)", "2021-06-14": "Dragon Boat Festival", "2021-09-20": "Day off (substituted from 09/11/2021)", "2021-09-21": "Mid-Autumn Festival", @@ -772,11 +771,13 @@ "2024-09-17": "Mid-Autumn Festival", "2024-10-10": "National Day", "2025-01-01": "Founding Day of the Republic of China", + "2025-01-27": "Day off (substituted from 02/08/2025)", "2025-01-28": "Chinese New Year's Eve", "2025-01-29": "Chinese New Year", "2025-01-30": "Chinese New Year", "2025-01-31": "Chinese New Year", "2025-02-28": "Peace Memorial Day", + "2025-04-03": "Children's Day (observed)", "2025-04-04": "Children's Day; Tomb Sweeping Day", "2025-05-30": "Dragon Boat Festival (observed)", "2025-05-31": "Dragon Boat Festival", @@ -820,6 +821,7 @@ "2028-01-27": "Chinese New Year", "2028-01-28": "Chinese New Year", "2028-02-28": "Peace Memorial Day", + "2028-04-03": "Children's Day (observed)", "2028-04-04": "Children's Day; Tomb Sweeping Day", "2028-05-28": "Dragon Boat Festival", "2028-05-29": "Dragon Boat Festival (observed)", @@ -831,6 +833,7 @@ "2029-02-14": "Chinese New Year", "2029-02-15": "Chinese New Year", "2029-02-28": "Peace Memorial Day", + "2029-04-03": "Children's Day (observed)", "2029-04-04": "Children's Day; Tomb Sweeping Day", "2029-06-15": "Dragon Boat Festival (observed)", "2029-06-16": "Dragon Boat Festival", @@ -870,9 +873,9 @@ "2032-02-13": "Chinese New Year", "2032-02-27": "Peace Memorial Day (observed)", "2032-02-28": "Peace Memorial Day", + "2032-04-02": "Children's Day (observed)", "2032-04-04": "Children's Day; Tomb Sweeping Day", - "2032-04-05": "Children's Day (observed)", - "2032-04-06": "Tomb Sweeping Day (observed)", + "2032-04-05": "Tomb Sweeping Day (observed)", "2032-06-11": "Dragon Boat Festival (observed)", "2032-06-12": "Dragon Boat Festival", "2032-09-19": "Mid-Autumn Festival", @@ -888,6 +891,7 @@ "2033-02-03": "Chinese New Year's Eve (observed)", "2033-02-28": "Peace Memorial Day", "2033-04-04": "Children's Day; Tomb Sweeping Day", + "2033-04-05": "Children's Day (observed)", "2033-06-01": "Dragon Boat Festival", "2033-09-08": "Mid-Autumn Festival", "2033-10-10": "National Day", @@ -926,6 +930,7 @@ "2036-01-30": "Chinese New Year", "2036-01-31": "Chinese New Year's Eve (observed)", "2036-02-28": "Peace Memorial Day", + "2036-04-03": "Children's Day (observed)", "2036-04-04": "Children's Day; Tomb Sweeping Day", "2036-05-30": "Dragon Boat Festival", "2036-10-03": "Mid-Autumn Festival (observed)", @@ -985,6 +990,7 @@ "2040-02-15": "Chinese New Year's Eve (observed)", "2040-02-16": "Chinese New Year (observed)", "2040-02-28": "Peace Memorial Day", + "2040-04-03": "Children's Day (observed)", "2040-04-04": "Children's Day; Tomb Sweeping Day", "2040-06-14": "Dragon Boat Festival", "2040-09-20": "Mid-Autumn Festival", @@ -998,6 +1004,7 @@ "2041-02-05": "Chinese New Year (observed)", "2041-02-28": "Peace Memorial Day", "2041-04-04": "Children's Day; Tomb Sweeping Day", + "2041-04-05": "Children's Day (observed)", "2041-06-03": "Dragon Boat Festival", "2041-09-10": "Mid-Autumn Festival", "2041-10-10": "National Day", @@ -1040,6 +1047,7 @@ "2044-02-28": "Peace Memorial Day", "2044-02-29": "Peace Memorial Day (observed)", "2044-04-04": "Children's Day; Tomb Sweeping Day", + "2044-04-05": "Children's Day (observed)", "2044-05-31": "Dragon Boat Festival", "2044-10-05": "Mid-Autumn Festival", "2044-10-10": "National Day", @@ -1052,6 +1060,7 @@ "2045-02-20": "Chinese New Year (observed)", "2045-02-21": "Chinese New Year (observed)", "2045-02-28": "Peace Memorial Day", + "2045-04-03": "Children's Day (observed)", "2045-04-04": "Children's Day; Tomb Sweeping Day", "2045-06-19": "Dragon Boat Festival", "2045-09-25": "Mid-Autumn Festival", @@ -1103,9 +1112,9 @@ "2049-02-04": "Chinese New Year", "2049-02-28": "Peace Memorial Day", "2049-03-01": "Peace Memorial Day (observed)", + "2049-04-02": "Children's Day (observed)", "2049-04-04": "Children's Day; Tomb Sweeping Day", - "2049-04-05": "Children's Day (observed)", - "2049-04-06": "Tomb Sweeping Day (observed)", + "2049-04-05": "Tomb Sweeping Day (observed)", "2049-06-04": "Dragon Boat Festival", "2049-09-10": "Mid-Autumn Festival (observed)", "2049-09-11": "Mid-Autumn Festival", diff --git a/tests/countries/test_taiwan.py b/tests/countries/test_taiwan.py index 8ffb08490..5e0fdfef1 100644 --- a/tests/countries/test_taiwan.py +++ b/tests/countries/test_taiwan.py @@ -146,9 +146,14 @@ def test_childrens_day(self): self.assertNoHolidayName(name, Taiwan(years=1989)) obs_dt = ( + "2013-04-05", "2015-04-03", + "2016-04-05", + "2017-04-03", "2020-04-03", - "2021-04-05", + "2021-04-02", + "2024-04-05", + "2025-04-03", ) self.assertHolidayName(f"{name}(慶祝)", obs_dt) self.assertNoNonObservedHoliday(obs_dt) @@ -176,7 +181,7 @@ def test_tomb_sweeping_day(self): obs_dt = ( "2015-04-06", "2020-04-02", - "2021-04-06", + "2021-04-05", ) self.assertHolidayName(f"{name}(慶祝)", obs_dt) self.assertNoNonObservedHoliday(obs_dt) @@ -482,7 +487,6 @@ def test_2021(self): "2021-04-02", "2021-04-04", "2021-04-05", - "2021-04-06", "2021-06-14", "2021-09-20", "2021-09-21", @@ -553,6 +557,24 @@ def test_2024(self): ("2024-10-10", "中華民國國慶日"), ) + def test_2025(self): + self.assertHolidays( + Taiwan(years=2025), + ("2025-01-01", "中華民國開國紀念日"), + ("2025-01-27", "休息日(2025-02-08日起取代)"), + ("2025-01-28", "農曆除夕"), + ("2025-01-29", "春節"), + ("2025-01-30", "春節"), + ("2025-01-31", "春節"), + ("2025-02-28", "和平紀念日"), + ("2025-04-03", "兒童節(慶祝)"), + ("2025-04-04", "兒童節; 清明節"), + ("2025-05-30", "端午節(慶祝)"), + ("2025-05-31", "端午節"), + ("2025-10-06", "中秋節"), + ("2025-10-10", "中華民國國慶日"), + ) + def test_l10n_default(self): self.assertLocalizedHolidays( ("2022-01-01", "中華民國開國紀念日"),