← 返回
未分类

Chinese Workdays

Calculate legal working days in China according to official government holiday schedules. Uses State Council-published arrangements to exclude weekends, publ...
根据中国政府官方节假日安排计算法定工作日,依据国务院发布的安排剔除周末、公共假期及调休。
manucode2000-max
未分类 clawhub v2.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 376
下载
💾 4
安装
1
版本
#21years#authoritative#calendar#china#complete#comprehensive#historic#holidays#latest#milestone#official#production#utility#v2#working-days

概述

Chinese Workdays Calculator

Calculate the number of working days between two dates according to Chinese government holiday schedules.

Features

  • 📅 Uses official Chinese holiday schedules published by the State Council
  • 🔢 Calculates法定工作日 (legal working days) excluding weekends and public holidays
  • 📊 Supports holiday makeup workdays (调休补班)
  • 🗂️ Stores yearly holiday schedules in simple YAML data files
  • 🔄 Can be updated when new annual holiday arrangements are released
  • 📊 Provides monthly and yearly statistics
  • 🤖 CLI tool for quick calculations

Quick Start

Basic calculation

from chinese_workdays import ChineseWorkdays

calc = ChineseWorkdays()
workdays = calc.count_workdays("2026-01-01", "2026-12-31")
print(f"2026年全年工作日: {workdays}天")

Monthly statistics

march_workdays = calc.get_workdays_in_month(2026, 3)  # 22天

Usage Examples

How many working days are there in March 2026?
Working days in Q1 2026?
Calculate workdays between 2026-02-10 and 2026-03-20
How many workdays in 2026?

Command Line

# Quick calculations
python workdays_cmd.py 2026-03          # March 2026
python workdays_cmd.py 2026-Q1          # Q1 2026
python workdays_cmd.py 2026             # Full year
python workdays_cmd.py 2026-01-01 2026-06-30  # Custom range

Data Format

Holiday schedules are stored in YAML format in the data/ directory:

year: 2026
country: "China"
holidays:
  - name: "元旦"
    start: "2026-01-01"
    end: "2026-01-03"
    days_off: ["2026-01-01", "2026-01-02"]  #放假日期
    makeup_workdays: ["2025-12-28", "2026-01-04"]  # 调休上班
    note: "官方通知原文"

Updating Schedules

The State Council releases next year's holiday arrangement in November. Update the YAML file accordingly:

  1. Locate the official notice at https://www.gov.cn/gongbao/
  2. Extract dates and makeup workdays
  3. Edit data/2027.yaml (or the relevant year)

Implementation Details

  • Uses Python's datetime for date arithmetic
  • Holiday data stored as YAML for easy editing
  • Supports makeup workdays that override weekend status
  • Handles holidays that span multiple days

Limitations

  • Requires holiday schedules to be defined for the years being calculated
  • Only works for dates after 2000 (easily extendable)
  • Does not automatically fetch new schedules (manual update needed)
  • Data accuracy depends on correct YAML configuration

Examples of Output

📅 工作日统计
📊 期间: 2026-01-01 至 2026-12-31
📏 总天数: 365
💼 法定工作日: 248 天

工作日占比: 68.0%

📋 期间包含的节假日:
  • 元旦: 2026-01-01 ~ 2026-01-03
  • 春节: 2026-02-15 ~ 2026-02-23
  ...

Technical Notes

Calculation Priority

  1. Makeup workdays (highest priority) → always counted as working days
  2. Public holidays → excluded from working days
  3. Weekends (Saturday/Sunday) → excluded unless makeup workday
  4. Regular weekdays → counted as working days

Algorithm

for each day in date_range:
    if day in makeup_workdays:
        count += 1
    elif day in public_holidays:
        skip
    elif day is weekend:
        skip
    else:
        count += 1

Files Structure

chinese-workdays/
├── SKILL.md              # This file
├── __init__.py           # Package entry point
├── chinese_workdays.py   # Core calculation engine
├── workdays_cmd.py       # CLI tool
├── README.md             # User documentation (optional)
└── data/
    ├── 2026.yaml         # 2026 holiday schedule (official)
    └── 2027.yaml         # 2027 holiday schedule (template)

License

MIT License - Free to use and modify.

版本历史

共 1 个版本

  • v2.0.0 当前
    2026-03-31 07:39 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

security-compliance

Skill Vetter

spclaudehome
AI智能体技能安全预审工具。安装ClawdHub、GitHub等来源技能前,检查风险信号、权限范围及可疑模式。
★ 1,218 📥 266,716
ai-intelligence

Self-Improving + Proactive Agent

ivangdavila
自我反思+自我批评+自我学习+自组织记忆。智能体评估自身工作、发现错误并持续改进。
★ 1,362 📥 318,826
developer-tools

Github

steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 672 📥 324,385