获取中国节假日信息
Project description
ChinaHolidays
介绍
获取中国休息日,节假日安排来自官方渠道。 详情参考official_info.toml
安装与使用
- pip方式安装
pip install ChinaHolidays
- uv方式安装
uv pip install ChinaHolidays
uv add ChinaHolidays
- 使用
from ChinaHolidays import (
get_all_holidays,
filter_holidays,
date_range,
ChinaHolidays
)
功能
提供以下接口函数与类:
- date_range
获取日期范围
:param start_date: 开始日期
:type start_date: datetime
:param end_date: 结束日期(包含)
:type end_date: datetime
:return: 日期范围
:rtype: set[datetime]
- get_all_holidays
获取所有休息日(法定节假日+周末)
:param year: 年份。默认为当前年份
:type year: int
:param consider_compensatory_workdays: 是否考虑调休工作日,默认为False
:type consider_compensatory_workdays: bool
:return: 休息日列表
:rtype: set[datetime]
- filter_holidays
筛掉休息日(法定节假日+周末)
:param start_date: 开始日期
:type start_date: datetime
:param end_date: 结束日期(包含)
:type end_date: datetime
:param consider_compensatory_workdays: 是否考虑调休工作日,默认为False
:type consider_compensatory_workdays: bool
:return: 指定时间范围非休息日列表
:rtype: set[datetime]
- ChinaHolidays
class ChinaHolidays:
"""中国节假日"""
def __init__(self, year: int):
"""初始化
:param year: 年份
:type year: int"""
@property
def festivals(self):
"""节假日
:return: 节假日字典,键为节假日名称,值为日期集合
:rtype: dict[str, set[datetime]]"""
@property
def festival_days(self):
"""节假日日期
:return: 节假日日期集合
:rtype: set[datetime]"""
@property
def compensatory_workdays(self):
"""调休工作日
:return: 调休工作日集合
:rtype: set[datetime]"""
@property
def weekends(self):
"""周末
:return: 周末日期集合
:rtype: set[datetime]"""
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file chinaholidays-2026.2.16.tar.gz.
File metadata
- Download URL: chinaholidays-2026.2.16.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dbe46d05a610a6e2d6e3a4fc354897cd3ae39d077b380ee56afd3d91b8463d5e
|
|
| MD5 |
b336f10d5ad386b178581afbf7e001b3
|
|
| BLAKE2b-256 |
f26c857abc013fd0898df22bb5879eada8cc01947d81ee78f51cfc2c3ebfb685
|
File details
Details for the file chinaholidays-2026.2.16-py3-none-any.whl.
File metadata
- Download URL: chinaholidays-2026.2.16-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3176325ba31b971c6b4db973eda6911c0843ad1fafbea606580cf069dabda15a
|
|
| MD5 |
2abb693e60db926756f22b9989e2fb86
|
|
| BLAKE2b-256 |
6d28628dd892d0cd13fd6ed2deeadfcae2e139177d5e2590dbce4a95e6ebed85
|