From fd8ba9f955ef361d32a0509bc2e4f86626848ea5 Mon Sep 17 00:00:00 2001 From: Lirian Su Date: Wed, 25 Oct 2023 10:58:07 +0800 Subject: [PATCH] feat: support holidays for 2024 --- CHANGELOG.md | 7 ++++- chinese_calendar/constants.py | 44 ++++++++++++++++++++++++++++++++ chinese_calendar/scripts/data.py | 19 ++++++++++++++ 3 files changed, 69 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee355c8..83a9467 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## Latest Version 1.9.0 +> on 2023-10-25 + +* **FEAT**: 支持 2024年 的节假日 + ## Version 1.8.1 > on 2023-07-03 @@ -5,7 +10,7 @@ * **FEAT**: `get_workdays` 函数新增 `include_weekends` 筛选,该筛选关闭后会过滤掉调休的周末,thanks @Dragon-GCS #104 * **CHORE**: 更新项目开发依赖 -## Latest Version 1.8.0 +## Version 1.8.0 > on 2022-12-09 * **FEAT**: 支持 2023年 的节假日 diff --git a/chinese_calendar/constants.py b/chinese_calendar/constants.py index daa6460..b27b37a 100644 --- a/chinese_calendar/constants.py +++ b/chinese_calendar/constants.py @@ -558,6 +558,34 @@ def __new__(cls, english, chinese, days): datetime.date(year=2023, month=10, day=4): Holiday.national_day.value, datetime.date(year=2023, month=10, day=5): Holiday.national_day.value, datetime.date(year=2023, month=10, day=6): Holiday.national_day.value, + datetime.date(year=2024, month=1, day=1): Holiday.new_years_day.value, + datetime.date(year=2024, month=2, day=10): Holiday.spring_festival.value, + datetime.date(year=2024, month=2, day=11): Holiday.spring_festival.value, + datetime.date(year=2024, month=2, day=12): Holiday.spring_festival.value, + datetime.date(year=2024, month=2, day=13): Holiday.spring_festival.value, + datetime.date(year=2024, month=2, day=14): Holiday.spring_festival.value, + datetime.date(year=2024, month=2, day=15): Holiday.spring_festival.value, + datetime.date(year=2024, month=2, day=16): Holiday.spring_festival.value, + datetime.date(year=2024, month=2, day=17): Holiday.spring_festival.value, + datetime.date(year=2024, month=4, day=4): Holiday.tomb_sweeping_day.value, + datetime.date(year=2024, month=4, day=5): Holiday.tomb_sweeping_day.value, + datetime.date(year=2024, month=4, day=6): Holiday.tomb_sweeping_day.value, + datetime.date(year=2024, month=5, day=1): Holiday.labour_day.value, + datetime.date(year=2024, month=5, day=2): Holiday.labour_day.value, + datetime.date(year=2024, month=5, day=3): Holiday.labour_day.value, + datetime.date(year=2024, month=5, day=4): Holiday.labour_day.value, + datetime.date(year=2024, month=5, day=5): Holiday.labour_day.value, + datetime.date(year=2024, month=6, day=10): Holiday.dragon_boat_festival.value, + datetime.date(year=2024, month=9, day=15): Holiday.mid_autumn_festival.value, + datetime.date(year=2024, month=9, day=16): Holiday.mid_autumn_festival.value, + datetime.date(year=2024, month=9, day=17): Holiday.mid_autumn_festival.value, + datetime.date(year=2024, month=10, day=1): Holiday.national_day.value, + datetime.date(year=2024, month=10, day=2): Holiday.national_day.value, + datetime.date(year=2024, month=10, day=3): Holiday.national_day.value, + datetime.date(year=2024, month=10, day=4): Holiday.national_day.value, + 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, } workdays = { @@ -692,6 +720,14 @@ def __new__(cls, english, chinese, days): datetime.date(year=2023, month=6, day=25): Holiday.dragon_boat_festival.value, datetime.date(year=2023, month=10, day=7): Holiday.national_day.value, datetime.date(year=2023, month=10, day=8): Holiday.national_day.value, + datetime.date(year=2024, month=2, day=4): Holiday.spring_festival.value, + datetime.date(year=2024, month=2, day=18): Holiday.spring_festival.value, + datetime.date(year=2024, month=4, day=7): Holiday.tomb_sweeping_day.value, + datetime.date(year=2024, month=4, day=28): Holiday.labour_day.value, + datetime.date(year=2024, month=5, day=11): Holiday.labour_day.value, + 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, } in_lieu_days = { @@ -827,4 +863,12 @@ def __new__(cls, english, chinese, days): datetime.date(year=2023, month=6, day=23): Holiday.dragon_boat_festival.value, datetime.date(year=2023, month=10, day=5): Holiday.national_day.value, datetime.date(year=2023, month=10, day=6): Holiday.national_day.value, + datetime.date(year=2024, month=2, day=15): Holiday.spring_festival.value, + datetime.date(year=2024, month=2, day=16): Holiday.spring_festival.value, + datetime.date(year=2024, month=4, day=5): Holiday.tomb_sweeping_day.value, + datetime.date(year=2024, month=5, day=2): Holiday.labour_day.value, + datetime.date(year=2024, month=5, day=3): Holiday.labour_day.value, + datetime.date(year=2024, month=9, day=17): 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, } diff --git a/chinese_calendar/scripts/data.py b/chinese_calendar/scripts/data.py index b5a2b5c..0720ff9 100644 --- a/chinese_calendar/scripts/data.py +++ b/chinese_calendar/scripts/data.py @@ -66,6 +66,25 @@ def __init__(self): pass # fmt: off + def _2024(self): + """https://www.gov.cn/zhengce/content/202310/content_6911527.htm + 一、元旦:1月1日放假,与周末连休。 + 二、春节:2月10日至17日放假调休,共8天。2月4日(星期日)、2月18日(星期日)上班。 + 三、清明节:4月4日至6日放假调休,共3天。4月7日(星期日)上班。 + 四、劳动节:5月1日至5日放假调休,共5天。4月28日(星期日)、5月11日(星期六)上班。 + 五、端午节:6月10日放假,与周末连休。 + 六、中秋节:9月15日至17日放假调休,共3天。9月14日(星期六)上班。 + 七、国庆节:10月1日至7日放假调休,共7天。9月29日(星期日)、10月12日(星期六)上班。 + """ + self.year_at(2024) \ + .nyd().rest(1, 1) \ + .sf().rest(2, 10).to(2, 17).work(2, 4).work(2, 18).in_lieu(2, 15).to(2, 16) \ + .tsd().rest(4, 4).to(4, 6).work(4, 7).in_lieu(4, 5) \ + .ld().rest(5, 1).to(5, 5).work(4, 28).work(5, 11).in_lieu(5, 2).to(5, 3) \ + .dbf().rest(6, 10) \ + .maf().rest(9, 15).to(9, 17).work(9, 14).in_lieu(9, 17) \ + .nd().rest(10, 1).to(10, 7).work(9, 29).work(10, 12).in_lieu(10, 4).in_lieu(10, 7) + def _2023(self): """ http://www.gov.cn/zhengce/content/2022-12/08/content_5730844.htm 一、元旦:2022年12月31日至2023年1月2日放假调休,共3天。