Projects
View on GitHub
liriansu-opus/chinese-calendar
About
Determines whether a day is a statutory holiday or statutory workday (view holiday schedules).
Productivity & AutomationMeasured star growth
- in 24h
- 0
- in 7 days
- +1
- in 15 days
- +1
- in 1 month
- +4
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.en.md
OriginalChinese Calendar
Check if some date is workday or holiday in China. Support 2004 ~ 2027.
Installation
pip install chinesecalendar
Upgrade
pip install -U chinesecalendar
Chinese government announces holiday arrangement usually during November. This project will release new version after official announcement.
Sample
import datetime
# Check if 2018-04-30 is holiday in China
from chinese_calendar import is_holiday, is_workday
april_last = datetime.date(2018, 4, 30)
assert is_workday(april_last) is False
assert is_holiday(april_last) is True
# or check and get the holiday name
import chinese_calendar as calendar # 也可以这样 import
on_holiday, holiday_name = calendar.get_holiday_detail(april_last)
assert on_holiday is True
assert holiday_name == calendar.Holiday.labour_day.value
# even check if a holiday is in lieu
import chinese_calendar
assert chinese_calendar.is_in_lieu(datetime.date(2006, 2, 1)) is False
assert chinese_calendar.is_in_lieu(datetime.date(2006, 2, 2)) is True
Other Languages
If you fail to use Python directly, you can translate the constants file to get the complete chinese holiday arrangement.
Contributing
- Fork & Clone this project, install uv, then run
make install - Modify calendar definition file
- Run
make fmt, which runs the script to generate the constants file and formats the code - Run
make testto make sure lint and tests pass - Create a PR
Explore related projects
Loading…