← 返回 Skills 市场
yting27

Global Holidays

作者 Yen Ting · GitHub ↗ · v1.0.2
cross-platform ✓ 安全检测通过
788
总下载
0
收藏
1
当前安装
3
版本数
在 OpenClaw 中安装
/install global-holidays
功能描述
Use this skill whenever a task involves checking, generating, or working with public holidays — for any country or subdivision (state, province, region). Tri...
使用说明 (SKILL.md)

holidays — Python Holiday Library

Overview

holidays is a Python library that generates country- and subdivision-specific sets of government-designated holidays on the fly. It covers 249 countries (ISO 3166-1) and supports subdivisions (states, provinces, regions) via ISO 3166-2 codes.

The central object is HolidayBase, which behaves like a Python dict mapping date → holiday name. All examples below can be run directly in the shell:

python \x3C\x3C'EOF'
# your code here
EOF
# OR (if the package is installed via uv)
uv run - \x3C\x3CEOF
# your code here
EOF

Installation

IMPORTANT: Always use a virtual environment or --break-system-packages flag.

pip install holidays --break-system-packages

For production use, pin to a specific version:

pip install holidays==0.58 --break-system-packages

Quick Reference

Task Method
All holidays for a country/year country_holidays('US', years=2024)
Holidays for a subdivision country_holidays('US', subdiv='CA', years=2024)
Holidays in a date range holidays_obj['2024-01-01':'2024-01-31']
Check if a date is a holiday holidays_obj.get('2024-12-25') → name or None
Add custom holidays holidays_obj.update({'2024-07-10': 'My Birthday!'})
List all supported countries list_supported_countries()
List countries with localization list_localized_countries()

Core API

country_holidays() — Main Function

country_holidays(
    country,          # ISO 3166-1 alpha-2 code, e.g. 'US', 'GB', 'DE'
    subdiv=None,      # ISO 3166-2 subdivision code, e.g. 'CA', 'TX', 'BY'
    years=None,       # int or list of ints, e.g. 2024 or [2023, 2024]
    expand=True,      # auto-expand years when checking dates outside current range
    observed=True,    # include observed holidays (e.g. holiday on weekend → Monday)
    language=None,    # ISO 639-1 language code for holiday names, e.g. 'en', 'de'
    categories=None,  # filter to specific holiday categories (country-dependent)
)

Returns a HolidayBase object (dict-like: {date: name}).


Common Tasks

1. Get All Holidays for a Country in a Year

from holidays import country_holidays

us_holidays = country_holidays('US', years=2024)
for date, name in sorted(us_holidays.items()):
    print(date, name)

2. Get Holidays for a Subdivision (State / Province)

Use the ISO 3166-2 subdivision code (e.g. 'CA' for California, 'BY' for Bavaria).

from holidays import country_holidays

ca_holidays = country_holidays('US', subdiv='CA', years=2024)
for date, name in sorted(ca_holidays.items()):
    print(date, name)

3. Get Holidays Within a Date Range

Slice the HolidayBase object with date strings ('YYYY-MM-DD'):

from holidays import country_holidays

ca_holidays = country_holidays('US', subdiv='CA', years=2024)
for day in ca_holidays['2024-01-01':'2024-01-31']:
    print(f"{day}: {ca_holidays.get(day)}")

4. Check if a Specific Date is a Holiday

.get() returns the holiday name if the date is a holiday, or None if it is not.

from holidays import country_holidays

ca_holidays = country_holidays('US', subdiv='CA')

# Is December 25 a holiday?
name = ca_holidays.get('2024-12-25')
print(name)   # → 'Christmas Day'

# Is December 26 a holiday?
name = ca_holidays.get('2024-12-26')
print(name)   # → None

Tip: Use if date in holidays_obj: for a boolean check (faster than .get()).

5. Working with Custom Holidays

SECURITY NOTE: Only use custom holidays if the user explicitly provides or requests them. Never assume a file location exists.

ALWAYS ask the user for the file path rather than using a default location. If they don't have a custom holidays file, skip this feature.

Example workflow:

  1. Ask user: "Do you have a custom holidays JSON file you'd like to include?"
  2. If yes, ask: "What's the full path to your custom holidays file?"
  3. Only then load and merge:
import json
from pathlib import Path
from holidays import country_holidays

# ONLY use this if user explicitly provided the path
custom_file = Path("/path/user/provided/custom-holidays.json")

# Verify file exists before reading
if custom_file.exists():
    with open(custom_file) as f:
        custom_data = json.load(f)

    holidays_2024 = country_holidays('US', years=2024)
    holidays_2024.update(custom_data)

    print(holidays_2024.get('2024-07-10'))  # → 'My Birthday!' (if defined)
else:
    print(f"File not found: {custom_file}")

Custom holidays file format:

{
  "2024-07-10": "My Birthday!",
  "2024-10-01": "Family Celebration"
}

6. List All Supported Countries and Subdivisions

from holidays import list_supported_countries

# include_aliases=True also returns common aliases (e.g. 'UK' for 'GB')
supported = list_supported_countries(include_aliases=True)
print(supported['US'])   # → list of supported US subdivision codes

7. Use Localized (Translated) Holiday Names

Language codes:

  • Use ISO 639-1 codes (e.g., en, de, fr)
  • Some countries use locale-specific codes (e.g., en_US, zh_CN)
  • If an unsupported language is requested, the library falls back to the default language

Step 1: Find countries with localization support

from holidays import list_localized_countries

# Get all countries that support multiple languages
localized = list_localized_countries(include_aliases=True)

# Check if a specific country supports localization
if 'MY' in localized:
    print(f"Malaysia supports: {localized['MY']}")
    # Output: Malaysia supports: ['en_MY', 'ms_MY', 'zh_CN', ...]

Step 2: Generate holidays in a specific language

from holidays import country_holidays

# Malaysia holidays in Malay language
my_holidays_ms = country_holidays('MY', years=2025, language='ms_MY')
for date, name in sorted(my_holidays_ms.items())[:3]:
    print(f"{date}: {name}")

# Same holidays in English
my_holidays_en = country_holidays('MY', years=2025, language='en_MY')
for date, name in sorted(my_holidays_en.items())[:3]:
    print(f"{date}: {name}")

Key Behaviours to Know

  • observed=True (default): When a holiday falls on a weekend, the observed date (typically Monday) is included. Set observed=False to get only the statutory date.
  • expand=True (default): If you check a date outside the years range, the library automatically adds that year. Set expand=False to prevent this.
  • Multiple years: Pass a list to years to load several years at once: years=[2023, 2024, 2025].
  • Date keys: The HolidayBase dict accepts datetime.date, datetime.datetime, or 'YYYY-MM-DD' strings interchangeably as keys.
  • Country codes: Use ISO 3166-1 alpha-2 (e.g. 'US', 'GB', 'DE'). Aliases like 'UK' are supported when include_aliases=True.

Dependencies

  • Python: 3.10+
  • Package: holidays (PyPI). Install with: pip install holidays --break-system-packages
  • No external system dependencies required

Security Considerations

  1. Package installation: Use --break-system-packages flag (required in this environment) and consider pinning to a specific version
  2. Custom holidays files: Only load custom holidays when explicitly requested by the user with a user-provided path
  3. File access: Verify file existence before reading to avoid exposing directory structure
安全使用建议
This skill appears coherent and limited to the Python 'holidays' library. Before installing/using it: (1) allow the agent to run pip/python only if you trust installing a PyPI package; prefer creating and using a virtual environment rather than --break-system-packages to avoid altering system Python; (2) pin to a specific version for production; (3) the skill will only read a custom holiday file if you explicitly supply the full path — never provide credentials or unrelated file paths; (4) note the SKILL.md mentions an alternate 'uv run' runner (documentation inconsistency) — confirm your runtime environment supports the documented commands if you plan to run examples.
功能分析
Type: OpenClaw Skill Name: global-holidays Version: 1.0.2 The skill provides functionality to work with public holidays using the `holidays` Python library. The `SKILL.md` clearly defines the skill's purpose and usage. While the skill includes a feature to load custom holidays from a user-provided JSON file, the instructions explicitly guide the AI agent to 'ALWAYS ask the user for the file path' and 'Verify file exists before reading,' actively mitigating potential arbitrary file read vulnerabilities. There is no evidence of malicious intent, data exfiltration, unauthorized execution, or prompt injection attempts against the agent. The instructions are defensive and promote safe interaction.
能力评估
Purpose & Capability
Name/description (global holidays) align with required binaries (python, pip) and the SKILL.md which documents using the Python 'holidays' package. The install step (pip install holidays) is appropriate for the declared functionality.
Instruction Scope
SKILL.md stays on-topic (fetching and merging holiday data, checking dates, handling user-provided custom holiday files). It explicitly instructs asking the user before reading any local file, which is good. Minor note: examples mention running via an alternate runner 'uv run' that is not declared as a required binary — this is a small documentation inconsistency, not a functional concern.
Install Mechanism
Installation is via pip (PyPI) which is expected for a Python library. The doc recommends using a virtual environment or pinning versions. This is a standard moderate-risk install mechanism and proportional to the skill's purpose.
Credentials
No credentials, config paths, or environment variables are requested. The skill only needs Python and pip to run example code; custom-holidays handling explicitly requires an explicit user-provided path before reading files.
Persistence & Privilege
Skill is not always-enabled and does not request elevated or persistent privileges. It does not instruct modifying other skills or system-wide configs.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install global-holidays
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /global-holidays 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.2
- Renamed the skill from "holidays" to "global-holidays". - Added `metadata` field with requirements and install instructions for improved integration and discoverability. - Enhanced language localization documentation for holiday names, including more explicit country and language code examples. - Added instructions and examples for running Python code with `uv` as an alternative to plain Python. - No functional changes to skill usage or API.
v1.0.1
- Installation instructions updated: always use a virtual environment or the `--break-system-packages` flag; production use should pin a specific version. - Python version requirement raised to 3.10+. - Security guidance added for handling custom holiday files: only use files if the user explicitly provides a path, and check file existence before loading. - Custom holidays workflow updated: do not assume a default file location, always prompt user for the path, and skip if not provided. - Security section added, summarizing safe installation practices and custom file handling. - No changes to the skill’s functional capabilities or API usage.
v1.0.0
Initial version
元数据
Slug global-holidays
版本 1.0.2
许可证
累计安装 1
当前安装数 1
历史版本数 3
常见问题

Global Holidays 是什么?

Use this skill whenever a task involves checking, generating, or working with public holidays — for any country or subdivision (state, province, region). Tri... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 788 次。

如何安装 Global Holidays?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install global-holidays」即可一键安装,无需额外配置。

Global Holidays 是免费的吗?

是的,Global Holidays 完全免费(开源免费),可自由下载、安装和使用。

Global Holidays 支持哪些平台?

Global Holidays 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Global Holidays?

由 Yen Ting(@yting27)开发并维护,当前版本 v1.0.2。

💬 留言讨论