npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

cn-time-parser

v1.1.1

Published

智能识别中文时间关键词并转换为具体日期和时间戳

Readme

cn-time-parser

智能识别中文自然语言中的时间关键词,转换为具体公历日期和时间戳。

支持基础时间词(今天、明天、昨天等)、传统农历日期(二月二十五、闰二月等)、节日名称(春节、国庆、清明、元宵等),以及工作日/节假日判断。

功能

  • 基础日期 — 今天、明天、昨天、前天、后天、大前天、大后天
  • 年份偏移 — 今年、去年、明年
  • 农历日期解析农历二月二十五明年农历八月十五农历2024年正月十五闰二月
  • 节日匹配 — 春节、五一、国庆、元旦、清明、元宵,支持 今年/去年/明年 前缀
  • 输出信息 — 公历日期、Unix 毫秒时间戳、农历信息、生肖、节气、工作日/节假日判断

快速开始

# 安装依赖
npm install -g cn-time-parser

# CLI 模式
cn-time-parser "今天"
cn-time-parser "农历二月二十五"

# MCP 模式(AI 助手集成)
cn-time-parser-mcp

MCP 模式

支持作为 MCP (Model Context Protocol) Server 使用,可集成到支持 MCP 的 AI 助手中。

安装 MCP Server

# 全局安装
npm install -g cn-time-parser

AI 助手配置

在 AI 助手的 MCP 配置中添加:

{
  "mcpServers": {
    "cn-time-parser": {
      "command": "cn-time-parser-mcp"
    }
  }
}

MCP 工具

工具名称: parse_chinese_time

输入参数:

| 参数 | 类型 | 必填 | 说明 | |------|------|------|------| | query | string | 是 | 时间关键词查询,如"今天"、"农历二月二十五" | | year | number | 否 | 指定年份,默认为当前年份 |

使用示例:

用户:明天是什么日子?
AI 调用:parse_chinese_time({ query: "明天" })
AI 返回:{
  "success": true,
  "originalQuery": "明天",
  "parsedDate": "2026-05-09",
  "timestamp": 1778294400000,
  "festivalInfo": "周末",
  "isWorkday": false,
  "isHoliday": false,
  "matchedKeyword": "明天"
}

CLI 用法

cn-time-parser [选项] [查询...]

传入查询

方式 | 示例 ---|--- --query / -q | --query "今天" / -q "明天" 位置参数 | "农历二月二十五" / "今年五一"

选项

选项 | 说明 ---|--- --format <type> | 输出格式:json(默认)、textsimple --year <int> | 指定年份(用于农历转换) --verbose / -v | 显示详细信息 --examples | 显示使用示例 --version | 显示版本号 --help | 显示帮助

输出格式

# JSON(默认)
cn-time-parser "今年五一"

# 文本
cn-time-parser "明天" --format text

# 仅日期
cn-time-parser "后天" --format simple

支持的时间表达式

基础时间词

今天 昨天 明天 前天 后天 大前天 大后天

年份偏移

今年 去年 明年

农历日期

  • 农历二月二十五 — 默认为当前年份
  • 明年农历八月十五 — 支持年份偏移
  • 农历2025年正月十五 — 指定公历年份
  • 农历闰二月初五 — 支持闰月

节日名称

以下节日可直接查询,不带年份前缀时默认今年:

节日 | 可用的输入关键词 ---|--- 春节 | 春节 过年 今年春节 去年春节 明年春节 元宵节 | 元宵 元宵节 今年元宵 去年元宵 明年元宵 清明节 | 清明 清明节 今年清明 去年清明 明年清明 劳动节 | 五一 劳动节 今年五一 去年五一 明年五一 国庆节 | 十一 国庆 国庆节 今年国庆 去年国庆 明年国庆 元旦 | 元旦 今年元旦 去年元旦 明年元旦

输出字段

{
  "success": true,
  "originalQuery": "今年五一",
  "parsedDate": "2026-05-01",
  "timestamp": 1777564800000,
  "lunarInfo": {
    "year": 2026,
    "month": 3,
    "day": 14,
    "isLeapMonth": false,
    "zodiac": "马",
    "term": null
  },
  "festivalInfo": "劳动节",
  "isWorkday": false,
  "isHoliday": true,
  "matchedKeyword": "今年五一"
}

字段 | 说明 ---|--- success | 是否解析成功 originalQuery | 原始输入 parsedDate | 公历日期 YYYY-MM-DD timestamp | Unix 毫秒时间戳 lunarInfo.* | 农历年/月/日/是否闰月/生肖/节气 festivalInfo | 节日名称(可能为 "工作日" "周末" 等) isWorkday | 是否工作日 isHoliday | 是否法定节假日 matchedKeyword | 匹配到的关键词

示例

# 基础日期
cn-time-parser "今天"
cn-time-parser "明天" --format simple

# 农历
cn-time-parser "农历正月十五"
cn-time-parser "明年农历八月十五" --format text

# 节日
cn-time-parser "春节"
cn-time-parser "去年五一"
cn-time-parser "清明节"
cn-time-parser "元宵节"

# 指定年份
cn-time-parser "农历二月二十五" --year 2025

依赖

许可证

MIT