Skip to main content

获取中国节假日信息

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

chinaholidays-2026.2.15.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chinaholidays-2026.2.15-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file chinaholidays-2026.2.15.tar.gz.

File metadata

  • Download URL: chinaholidays-2026.2.15.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for chinaholidays-2026.2.15.tar.gz
Algorithm Hash digest
SHA256 e2fdeae00a96bc36d97d904646308712a1941109c46ed5c28f09b412cbe151a1
MD5 750ce258039ed192eeded43ac221e322
BLAKE2b-256 705c303d9bec5205f856cf708d6721bde77d29b723b76242519934eb8f829041

See more details on using hashes here.

File details

Details for the file chinaholidays-2026.2.15-py3-none-any.whl.

File metadata

File hashes

Hashes for chinaholidays-2026.2.15-py3-none-any.whl
Algorithm Hash digest
SHA256 cf9eafc60054468f7d2ecf847954e4eec11f746e9ec9857377149f3ff010ac10
MD5 f7b6d20e100792c1f473440dd964b0f6
BLAKE2b-256 0980b10423b4aac42d1463713c9751ea92ccab44feb5b4fc34d3cc0195f31eb8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page