Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/LKI/chinese-calendar
判断一天是不是法定节假日/法定工作日(查看节假日安排)
https://github.com/LKI/chinese-calendar
calendar chinese-calendar chinese-holiday holidays public-holidays python workdays
Last synced: about 2 months ago
JSON representation
判断一天是不是法定节假日/法定工作日(查看节假日安排)
- Host: GitHub
- URL: https://github.com/LKI/chinese-calendar
- Owner: LKI
- License: mit
- Created: 2017-06-04T08:41:18.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-09-16T11:59:08.000Z (3 months ago)
- Last Synced: 2024-10-15T08:41:08.845Z (2 months ago)
- Topics: calendar, chinese-calendar, chinese-holiday, holidays, public-holidays, python, workdays
- Language: Python
- Homepage: https://pypi.org/project/chinesecalendar/
- Size: 196 KB
- Stars: 1,053
- Watchers: 25
- Forks: 184
- Open Issues: 20
-
Metadata Files:
- Readme: README.en.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Chinese Calendar
[![Package](https://img.shields.io/pypi/v/chinesecalendar.svg)](https://pypi.python.org/pypi/chinesecalendar)
[![Travis](https://img.shields.io/travis/LKI/chinese-calendar.svg)](https://travis-ci.org/LKI/chinese-calendar)
[![License](https://img.shields.io/github/license/LKI/chinese-calendar.svg)](https://github.com/LKI/chinese-calendar/blob/master/LICENSE)
[![README](https://img.shields.io/badge/简介-中文-brightgreen.svg)](https://github.com/LKI/chinese-calendar/blob/master/README.md)Check if some date is workday or holiday in China.
Support 2004 ~ 2024.## 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
``` python
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][constants.py] to get the complete chinese holiday arrangement.## Contributing
1. Fork & Clone this project
2. Modify [calendar definition file][scripts/data.py]
3. Run [script][scripts/__init__.py] to generate the [constants file][constants.py]
4. Create a PR[constants.py]: https://github.com/LKI/chinese-calendar/blob/master/chinese_calendar/constants.py
[scripts/data.py]: https://github.com/LKI/chinese-calendar/blob/master/chinese_calendar/scripts/data.py
[scripts/__init__.py]: https://github.com/LKI/chinese-calendar/blob/master/chinese_calendar/scripts/__init__.py