Skip to content

Commit

Permalink
feat: support 2025's holiday
Browse files Browse the repository at this point in the history
  • Loading branch information
LKI committed Nov 13, 2024
1 parent 8b36cda commit 5037cc5
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 4 deletions.
38 changes: 38 additions & 0 deletions chinese_calendar/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,34 @@ def __new__(cls, english, chinese, days):
datetime.date(year=2024, month=10, day=5): Holiday.national_day.value,
datetime.date(year=2024, month=10, day=6): Holiday.national_day.value,
datetime.date(year=2024, month=10, day=7): Holiday.national_day.value,
datetime.date(year=2025, month=1, day=1): Holiday.new_years_day.value,
datetime.date(year=2025, month=1, day=28): Holiday.spring_festival.value,
datetime.date(year=2025, month=1, day=29): Holiday.spring_festival.value,
datetime.date(year=2025, month=1, day=30): Holiday.spring_festival.value,
datetime.date(year=2025, month=1, day=31): Holiday.spring_festival.value,
datetime.date(year=2025, month=2, day=1): Holiday.spring_festival.value,
datetime.date(year=2025, month=2, day=2): Holiday.spring_festival.value,
datetime.date(year=2025, month=2, day=3): Holiday.spring_festival.value,
datetime.date(year=2025, month=2, day=4): Holiday.spring_festival.value,
datetime.date(year=2025, month=4, day=4): Holiday.tomb_sweeping_day.value,
datetime.date(year=2025, month=4, day=5): Holiday.tomb_sweeping_day.value,
datetime.date(year=2025, month=4, day=6): Holiday.tomb_sweeping_day.value,
datetime.date(year=2025, month=5, day=1): Holiday.labour_day.value,
datetime.date(year=2025, month=5, day=2): Holiday.labour_day.value,
datetime.date(year=2025, month=5, day=3): Holiday.labour_day.value,
datetime.date(year=2025, month=5, day=4): Holiday.labour_day.value,
datetime.date(year=2025, month=5, day=5): Holiday.labour_day.value,
datetime.date(year=2025, month=5, day=31): Holiday.dragon_boat_festival.value,
datetime.date(year=2025, month=6, day=1): Holiday.dragon_boat_festival.value,
datetime.date(year=2025, month=6, day=2): Holiday.dragon_boat_festival.value,
datetime.date(year=2025, month=10, day=1): Holiday.national_day.value,
datetime.date(year=2025, month=10, day=2): Holiday.national_day.value,
datetime.date(year=2025, month=10, day=3): Holiday.national_day.value,
datetime.date(year=2025, month=10, day=4): Holiday.national_day.value,
datetime.date(year=2025, month=10, day=5): Holiday.national_day.value,
datetime.date(year=2025, month=10, day=6): Holiday.mid_autumn_festival.value,
datetime.date(year=2025, month=10, day=7): Holiday.national_day.value,
datetime.date(year=2025, month=10, day=8): Holiday.national_day.value,
}

workdays = {
Expand Down Expand Up @@ -730,6 +758,11 @@ def __new__(cls, english, chinese, days):
datetime.date(year=2024, month=9, day=14): Holiday.mid_autumn_festival.value,
datetime.date(year=2024, month=9, day=29): Holiday.national_day.value,
datetime.date(year=2024, month=10, day=12): Holiday.national_day.value,
datetime.date(year=2025, month=1, day=26): Holiday.spring_festival.value,
datetime.date(year=2025, month=2, day=8): Holiday.spring_festival.value,
datetime.date(year=2025, month=4, day=27): Holiday.labour_day.value,
datetime.date(year=2025, month=9, day=28): Holiday.national_day.value,
datetime.date(year=2025, month=10, day=11): Holiday.national_day.value,
}

in_lieu_days = {
Expand Down Expand Up @@ -873,4 +906,9 @@ def __new__(cls, english, chinese, days):
datetime.date(year=2024, month=9, day=16): Holiday.mid_autumn_festival.value,
datetime.date(year=2024, month=10, day=4): Holiday.national_day.value,
datetime.date(year=2024, month=10, day=7): Holiday.national_day.value,
datetime.date(year=2025, month=2, day=3): Holiday.spring_festival.value,
datetime.date(year=2025, month=2, day=4): Holiday.spring_festival.value,
datetime.date(year=2025, month=5, day=5): Holiday.labour_day.value,
datetime.date(year=2025, month=10, day=7): Holiday.national_day.value,
datetime.date(year=2025, month=10, day=8): Holiday.national_day.value,
}
20 changes: 19 additions & 1 deletion chinese_calendar/scripts/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,24 @@ def __init__(self):
pass

# fmt: off
def _2025(self):
"""https://www.gov.cn/zhengce/content/202411/content_6986382.htm
一、元旦:1月1日(周三)放假1天,不调休。
二、春节:1月28日(农历除夕、周二)至2月4日(农历正月初七、周二)放假调休,共8天。1月26日(周日)、2月8日(周六)上班。
三、清明节:4月4日(周五)至6日(周日)放假,共3天。
四、劳动节:5月1日(周四)至5日(周一)放假调休,共5天。4月27日(周日)上班。
五、端午节:5月31日(周六)至6月2日(周一)放假,共3天。
六、国庆节、中秋节:10月1日(周三)至8日(周三)放假调休,共8天。9月28日(周日)、10月11日(周六)上班。
"""
self.year_at(2025) \
.nyd().rest(1, 1) \
.sf().rest(1, 28).to(2, 4).work(1, 26).work(2, 8).in_lieu(2, 3).to(2, 4) \
.tsd().rest(4, 4).to(4, 6) \
.ld().rest(5, 1).to(5, 5).work(4, 27).in_lieu(5, 5) \
.dbf().rest(5, 31).to(6, 2) \
.nd().rest(10, 1).to(10, 8).work(9, 28).work(10, 11).in_lieu(10, 7).to(10, 8) \
.maf().rest(10, 6)

def _2024(self):
"""https://www.gov.cn/zhengce/content/202310/content_6911527.htm
一、元旦:1月1日放假,与周末连休。
Expand Down Expand Up @@ -101,7 +119,7 @@ def _2023(self):
.ld().rest(4, 29).to(5, 3).work(4, 23).work(5, 6).in_lieu(5, 2).to(5, 3) \
.dbf().rest(6, 22).to(6, 24).work(6, 25).in_lieu(6, 23) \
.maf().rest(9, 29) \
.nd().rest(9, 30).to(10, 6).work(10, 7).to(10, 8).in_lieu(10, 5).to(10, 6)\
.nd().rest(9, 30).to(10, 6).work(10, 7).to(10, 8).in_lieu(10, 5).to(10, 6) \
.nyd().rest(12, 30).to(12, 31)

def _2022(self):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
long_description = f.read()

setup(
name="chinesecalendar",
name="chinese_calendar",
version=chinese_calendar.__version__,
description="check if some day is holiday in China",
long_description=long_description,
Expand Down
9 changes: 7 additions & 2 deletions tests/test_holiday_amount.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ def test_holiday_amount(self):
holiday_amounts[2012] -= 1 # 12年可以享受11年补班的假
holiday_amounts[2015] -= 1 # 15年是中国人民抗日战争暨世界反法西斯战争胜利70周年,多放1天
holiday_amounts[2020] -= 2 # 20年春节因为新型冠状病毒疫情防控,延长假期2天
for year in range(2007, 2023 + 1): # 06年数据少,不测了
self.assertEqual(11, holiday_amounts[year], "Holiday amount of year {}".format(year))
max_supported_year = max([_.year for _ in holidays])
for year in range(2007, max_supported_year + 1): # 06年数据少,不测了
if year <= 2024:
expected_holidays = 11
else:
expected_holidays = 13
self.assertEqual(expected_holidays, holiday_amounts[year], "Holiday amount of year {}".format(year))
self.assertEqual(1, 1)

0 comments on commit 5037cc5

Please sign in to comment.