← 返回列表
D

dsh-when

v0.1.0 · 2 天前发布

DSH 插件:自然语言相对时间 → ISO 解析工具(when),零依赖。

dsh-plugintimeschedulingdatetime

README

dsh-when

DSH 插件:把中文自然语言相对时间短语解析成 ISO 时间戳,注册一个 when 工具。纯 ESM、零依赖、无构建。

安装

sh
dsh plugin --profile <name> add file:./plugins/dsh-when

或 npm 发布后:dsh plugin --profile <name> add dsh-when


安装后组合层挂载 when 工具(when 层 id)。

工具:when

参数:

| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| text | string | 是 | 自然语言时间短语,如 明天 9 点2 小时后下周一 9 点18:30 或 ISO 8601 |
| tz | string | 否 | IANA 时区名(如 Asia/ShanghaiUTC),默认本地时区;无效时区返回规范错误 |
| now | string | 否 | ISO 8601 基准时间,默认当前时间 |

返回规范值:{ ok, text, iso, local, relativeSeconds, matchedPattern, errors }

  • iso:UTC ISO 8601 字符串(带 Z)。

  • local:目标时区本地 ISO 字符串(带 ±HH:MM 偏移)。

  • relativeSeconds:目标时刻相对 now 的秒数(目标 − now,可为负)。

  • matchedPattern:命中的模式名(day-offset / duration / weekday / clock-time / iso)。

  • -

    版本兼容矩阵

    DSH 版本状态说明
    dsh@0.1.0-rc.6 ✅ 兼容 cordis patch ✅
    dsh@0.1.0 ✅ 兼容 标准 patch ✅
    dsh@0.2.0 ⚠️ 待验证 待实测(API 可能在变)
    dsh@0.3.0+ ❓ 未知 尚未发布

    💡 兼容矩阵每周末自动跑实测,欢迎 PR 修正

    元数据

    License
    MIT
    npm
    dsh-when
    Repo
    Engines
    {}
    Weekly DL
    0
    Monthly DL
    0
    dsh.bundle
    {"bundle":{"patch":"./cordis.patch.yml"}}