check if some day is holiday in China
Project description
中国节假日
判断某年某月某一天是不是工作日/节假日。 支持 2004年 至 2021年,包括 2020年 的春节延长。
安装
pip install chinesecalendar
样例
import datetime
# 判断 2018年4月30号 是不是节假日
from chinese_calendar import is_workday, is_holiday
april_last = datetime.date(2018, 4, 30)
self.assertFalse(is_workday(april_last))
self.assertTrue(is_holiday(april_last))
# 或者在判断的同时,获取节日名
import chinese_calendar as calendar # 也可以这样 import
on_holiday, holiday_name = calendar.get_holiday_detail(april_last)
self.assertTrue(on_holiday)
self.assertEqual(calendar.Holiday.labour_day.value, holiday_name)
# 还能判断法定节假日是不是调休
import chinese_calendar
self.assertFalse(chinese_calendar.is_in_lieu(datetime.date(2006, 1, 1)))
self.assertTrue(chinese_calendar.is_in_lieu(datetime.date(2006, 1, 2)))
其它语言
假如你没法使用Python, 你也可以转译现成的常量文件来获取最全的节假日安排表。
贡献代码
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
chinesecalendar-1.5.0.tar.gz
(8.7 kB
view details)
Built Distribution
File details
Details for the file chinesecalendar-1.5.0.tar.gz
.
File metadata
- Download URL: chinesecalendar-1.5.0.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9adbe781556c2961680bec7c555bfdaef761d5cf269943ed7a69c18fb0a23af5 |
|
MD5 | 899185675518ff0b4dfe2dcf6a3e0091 |
|
BLAKE2b-256 | 332ace21bc4bf787b24eb7c3c5b9b9c079df3e124ef23bf86bae51b6bdf56d31 |
File details
Details for the file chinesecalendar-1.5.0-py2.py3-none-any.whl
.
File metadata
- Download URL: chinesecalendar-1.5.0-py2.py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 497fdd7857840e90e1672fb6b4e4cba15e1f6c5a03a8daa593718ef8baaf517d |
|
MD5 | 11deba9e591ec44a614d734d0d2729a9 |
|
BLAKE2b-256 | 81386d6c50c5f75f82a9314e73c52a924542afc85db14286c64c15ca37f5caac |