fcalendar
Use fcalendar to identify time expressions in text and query Chinese public holiday schedules.
All commands output single-line JSON to stdout; errors go to stderr.
[!IMPORTANT]
Always invoke fcalendar as python3 -m fcalendar ... — this bypasses all PATH issues and works
regardless of virtual environments, system Python, or installation prefix. Never rely on the bare
fcalendar command being on PATH.
Quick Start
- 1. Check if already installed (do this first — skip install if it succeeds):
python3 -c "import fcalendar; print('fcalendar installed, version:', fcalendar.__version__)"
If this prints a version number, skip to step 3.
- 2. Install (only if step 1 failed):
> [!NOTE]
> Package Source: The fcalendar package is available on PyPI at https://pypi.org/project/fcalendar/
>
> Source Code: You can review the source code at https://github.com/youngfreefjs/fcalendar
>
> Security: This package only performs local date/time parsing and does not access network resources or collect user data.
CODEBLOCK1
For enhanced security, consider installing in a virtual environment:
CODEBLOCK2
- 3. Verify:
python3 -m fcalendar --help
Confirm help output is shown. If this fails but step 1 succeeded, the package is installed but
may not support
-m invocation — fall back to the full binary path:
CODEBLOCK4
- 4. Get current date when needed: INLINECODE7
[!NOTE]
Invocation rule: In all commands below, replace fcalendar with python3 -m fcalendar.
Example: fcalendar query "明天" → INLINECODE11
Core Capabilities
1. Time Expression Recognition — query
Identifies and annotates time expressions in natural language, resolving them to exact dates.
Command:
CODEBLOCK5
Arguments:
| Argument | Required | Description |
|---|
| INLINECODE13 | yes | Natural language text containing time expressions |
| INLINECODE14 |
no | Reference date (YYYY-MM-DD). Defaults to system date |
|
--lang | no | Language:
zh or
en. Defaults to auto-detect |
Output:
CODEBLOCK6
Examples:
CODEBLOCK7
Supported time expression types:
For a comprehensive list of all supported time expression types with detailed examples, see references/time-expressions.md.
Key categories include:
- - Relative days (明天、后天、tomorrow)
- Relative weeks (本周一、下周五、next Monday)
- Chinese holidays (春节、国庆节、清明节)
- Lunar festivals (元宵节、七夕、除夕)
- Western festivals (Christmas、Halloween、Valentine's Day)
- 24 solar terms (春分、冬至、立春)
- And many more...
2. Holiday Query — holiday
Queries public holidays and normal weekends within a specified time range. Excludes workdays-on-weekends (调休上班) to avoid confusion.
For detailed information about Chinese public holidays and solar terms, see references/holidays.md.
Command:
CODEBLOCK8
Arguments:
| Argument | Required | Default | Description |
|---|
| INLINECODE19 | no | INLINECODE20 | Time range (see below) |
| INLINECODE21 |
no | system date | Reference date (YYYY-MM-DD) |
Supported scope values (Chinese and English both accepted):
| Scope | Alias | Description |
|---|
| INLINECODE22 | INLINECODE23 , INLINECODE24 | Next 180 days (default) |
| INLINECODE25 |
本周,
这周 | Mon–Sun of current week |
|
next_week |
下周,
下一周 | Mon–Sun of next week |
|
next_month |
下个月,
下一个月,
下月 | Full next calendar month |
|
weeks=N |
N周,
未来N周 | Next N weeks from today |
|
months=N |
N个月,
未来N个月 | Next N months from today |
N supports Chinese numerals: 一、两、三、四...十二, and Arabic numerals.
Output: JSON array, sorted by start date ascending.
CODEBLOCK9
Output fields:
| Field | Type | Description |
|---|
| INLINECODE42 | string | INLINECODE43 = Chinese public holiday; "weekend" = normal restful weekend |
| INLINECODE45 |
string | Holiday name (e.g.
"春节",
"周末") |
|
start | string | Start date, ISO format (YYYY-MM-DD) |
|
end | string | End date, ISO format (YYYY-MM-DD) |
|
days | int | Number of days |
Note: Workdays-on-weekends (调休上班) are NOT included in the output. The list only shows days off.
Examples:
fcalendar holiday # next 180 days (default)
fcalendar holiday --scope this_week # this week
fcalendar holiday --scope 本周 # same as above (Chinese)
fcalendar holiday --scope next_week # next week
fcalendar holiday --scope next_month # next full month
fcalendar holiday --scope weeks=3 # next 3 weeks
fcalendar holiday --scope 三周 # same as weeks=3 (Chinese numeral)
fcalendar holiday --scope months=2 # next 2 months
fcalendar holiday --scope 未来两个月 # same as months=2
fcalendar holiday --scope half_year --today 2026-09-01 # 180 days from Sep 1
Friendly Display Requirements
[!IMPORTANT]
Strict Output Rule: Always use the exact content returned by the fcalendar CLI.
Do NOT paraphrase, rewrite, supplement, or infer beyond what the CLI returns.
The result field (for query) and the JSON array (for holiday) are the single
source of truth. Present them as-is after formatting; never modify their semantic content.
- - General principle: output must be valid Markdown with clear structure.
- For
query: display the result field directly as the annotated response. Do not display raw JSON to the user. - For
holiday:
- Group results by
type: list
holiday entries first, then
weekend entries.
- Use a Markdown table or bullet list to present each item.
- Highlight key facts: name, date range, number of days.
- If the result is empty, tell the user there are no holidays in that period.
Recommended output structure for holiday
CODEBLOCK11
Error handling
- - If the
--scope value is invalid, the CLI exits with a non-zero code and prints an error to stderr. Inform the user of valid scope formats. - Always get the current date with
date +%Y-%m-%d before calling if real-time accuracy is required.
fcalendar
使用 fcalendar 识别文本中的时间表达并查询中国公共假期安排。
所有命令输出单行 JSON 到 stdout;错误信息输出到 stderr。
[!IMPORTANT]
始终以 python3 -m fcalendar ... 方式调用 fcalendar — 这可以绕过所有 PATH 问题,无论虚拟环境、系统 Python 或安装前缀如何都能正常工作。切勿依赖裸 fcalendar 命令在 PATH 上。
快速开始
- 1. 检查是否已安装(先执行此步骤 — 如果成功则跳过安装):
bash
python3 -c import fcalendar; print(fcalendar installed, version:, fcalendar.
version)
如果输出版本号,请跳至步骤 3。
- 2. 安装(仅当步骤 1 失败时):
> [!NOTE]
> 包来源:fcalendar 包可在 PyPI 上获取,地址为 https://pypi.org/project/fcalendar/
>
> 源代码:您可以在 https://github.com/youngfreefjs/fcalendar 查看源代码
>
> 安全性:此包仅执行本地日期/时间解析,不访问网络资源或收集用户数据。
bash
python3 -m pip install fcalendar
为增强安全性,可考虑在虚拟环境中安装:
bash
python3 -m venv venv
source venv/bin/activate # 在 Windows 上:venv\Scripts\activate
python3 -m pip install fcalendar
- 3. 验证:
bash
python3 -m fcalendar --help
确认显示帮助输出。如果此步骤失败但步骤 1 成功,说明包已安装但可能不支持 -m 调用 — 回退到完整二进制路径:
bash
$(python3 -c import sys, os; print(os.path.join(sys.prefix, bin, fcalendar))) --help
- 4. 获取当前日期(需要时):date +%Y-%m-%d
[!NOTE]
调用规则:在以下所有命令中,将 fcalendar 替换为 python3 -m fcalendar。
示例:fcalendar query 明天 → python3 -m fcalendar query 明天
核心功能
1. 时间表达识别 — query
识别并标注自然语言中的时间表达,将其解析为具体日期。
命令:
fcalendar query [--today YYYY-MM-DD] [--lang zh|en]
参数:
| 参数 | 必需 | 描述 |
|---|
| <text> | 是 | 包含时间表达的自然语言文本 |
| --today |
否 | 参考日期(YYYY-MM-DD)。默认为系统日期 |
| --lang | 否 | 语言:zh 或 en。默认为自动检测 |
输出:
json
{input: 下周开会, result: 下周开会(今天是2026年3月31日,下周是2026年4月6日至12日)}
示例:
bash
fcalendar query 明天下午三点开会
fcalendar query 国庆节去旅游 --today 2026-09-01
fcalendar query meeting next Monday --lang en
fcalendar query 春节回家 --today 2026-01-15
支持的时间表达类型:
有关所有支持的时间表达类型及其详细示例的完整列表,请参见 references/time-expressions.md。
主要类别包括:
- - 相对日期(明天、后天、tomorrow)
- 相对周(本周一、下周五、next Monday)
- 中国节日(春节、国庆节、清明节)
- 农历节日(元宵节、七夕、除夕)
- 西方节日(Christmas、Halloween、Valentines Day)
- 二十四节气(春分、冬至、立春)
- 以及更多...
2. 假期查询 — holiday
查询指定时间范围内的公共假期和普通周末。排除调休上班日以避免混淆。
有关中国公共假期和节气的详细信息,请参见 references/holidays.md。
命令:
fcalendar holiday [--scope ] [--today YYYY-MM-DD]
参数:
| 参数 | 必需 | 默认值 | 描述 |
|---|
| --scope | 否 | half_year | 时间范围(见下文) |
| --today |
否 | 系统日期 | 参考日期(YYYY-MM-DD) |
支持的 scope 值(中英文均可):
| 范围 | 别名 | 描述 |
|---|
| halfyear | 半年, 未来半年 | 未来 180 天(默认) |
| thisweek |
本周, 这周 | 当前周的周一至周日 |
| next_week | 下周, 下一周 | 下周的周一至周日 |
| next_month | 下个月, 下一个月, 下月 | 下一个完整日历月 |
| weeks=N | N周, 未来N周 | 从今天起未来 N 周 |
| months=N | N个月, 未来N个月 | 从今天起未来 N 个月 |
N 支持中文数字:一、两、三、四...十二,以及阿拉伯数字。
输出: JSON 数组,按 start 日期升序排列。
json
[
{type: holiday, name: 劳动节, start: 2026-05-01, end: 2026-05-05, days: 5},
{type: weekend, name: 周末, start: 2026-05-09, end: 2026-05-10, days: 2}
]
输出字段:
| 字段 | 类型 | 描述 |
|---|
| type | 字符串 | holiday = 中国公共假期;weekend = 普通休息周末 |
| name |
字符串 | 假期名称(例如 春节、周末) |
| start | 字符串 | 开始日期,ISO 格式(YYYY-MM-DD) |
| end | 字符串 | 结束日期,ISO 格式(YYYY-MM-DD) |
| days | 整数 | 天数 |
注意:调休上班日不包含在输出中。列表仅显示休息日。
示例:
bash
fcalendar holiday # 未来 180 天(默认)
fcalendar holiday --scope this_week # 本周
fcalendar holiday --scope 本周 # 同上(中文)
fcalendar holiday --scope next_week # 下周
fcalendar holiday --scope next_month # 下个月
fcalendar holiday --scope weeks=3 # 未来 3 周
fcalendar holiday --scope 三周 # 同 weeks=3(中文数字)
fcalendar holiday --scope months=2 # 未来 2 个月
fcalendar holiday --scope 未来两个月 # 同 months=2
fcalendar holiday --scope half_year --today 2026-09-01 # 从 9 月 1 日起 180 天
友好显示要求
[!IMPORTANT]
严格输出规则:始终使用 fcalendar CLI 返回的确切内容。
不要对 CLI 返回的内容进行释义、重写、补充或推断。
result 字段(对于 query)和 JSON 数组(对于 holiday)是唯一
的事实来源。格式化后按原样呈现;切勿修改其语义内容。
- - 通用原则:输出必须是结构清晰的合法 Markdown。
- 对于 query:直接显示 result 字段作为标注后的响应。不要向用户显示原始 JSON。
- 对于 holiday:
- 按 type 分组结果:先列出 holiday 条目,然后是 weekend 条目。
- 使用 Markdown 表格或项目符号列表呈现每个项目。
- 突出关键信息:名称、日期范围、天数。
- 如果结果为空,告知用户该时间段内没有假期。
holiday 的推荐输出结构
放假安排([scope描述])
法定节假日
2026-05-