omdsh-dev/dsh-tool-time

DSH 时间工具插件:严格 ISO 8601 解析、IANA 时区转换、UTC 日历运算、固定时长差,零依赖

Project Overview项目介绍

This is a native time utility plugin built exclusively for DeepSeek Harness (DSH). It provides strict ISO 8601 time parsing, IANA timezone conversion, UTC-based calendar arithmetic, and fixed duration difference calculation. As a zero-dependency, zero-extra-process pure function implementation, it eliminates common issues that plague alternative approaches: LLM calculation errors for timezone offsets, leap years, and daylight saving time boundaries, plus cross-platform inconsistencies with the system date command. You can install it directly via the DSH CLI for version 0.1.5-rc.1 and above with a single command.

The plugin supports four core actions: get current time, convert between timezones, add or subtract a fixed duration from a given time, and calculate the difference between two timestamps. All inputs undergo strict validation, which rejects unrecognized formats like natural language dates, invalid calendar dates such as February 30, and illegal timezone names, preventing silent processing errors. Output is standardized as structured JSON that includes the canonical ISO timestamp, Unix milliseconds timestamp, localized formatted string, and relevant timezone metadata.

The plugin is distributed as a DSH profile bundle, and can also be installed from a locally generated tarball file for offline use. It has been fully validated against DSH 0.1.5-rc.1, with 63 test cases covering core functionality, edge cases, and malicious inputs. It is released under the open source MIT license, with documented limitations including a supported input year range of 1000–9999, no support for natural language date parsing, and UTC-only calendar arithmetic for the current version.

这是一个面向 DeepSeek Harness(DSH)开发的原生时间工具插件,提供严格的ISO 8601时间解析、IANA时区转换、UTC日历运算和固定时长差计算功能。它是零依赖、零额外进程的纯函数实现,解决了LLM心算时区偏移、闰年夏时制边界容易出错,以及系统date命令跨平台语法不一致的问题。

插件支持四种核心操作:获取当前时间、时区转换、时间加减、计算固定时长差,对所有输入都做了严格安全校验,仅接受规范的ISO格式输入,拒绝非法日期和非标准格式,避免静默错误产生。所有运算基于UTC执行,月份日期会自动钳制到合法范围,输出包含结构化的ISO格式、Unix时间戳和本地化格式化展示。

插件兼容DSH 0.1.5-rc.1及以上版本,支持通过DSH的profile bundle命令直接从GitHub在线安装,也支持本地生成的tarball包离线安装。遵循MIT开源许可,共有63个测试用例覆盖各类功能和边界场景,输入年份限制在1000到9999之间,当前版本不支持自然语言日期解析。

Pre-install check安装前体检Compatibility · Security兼容性 · 安全性 1 warning1 项注意
  • Only 4 stars - very few users, little community feedback星标只有 4,几乎没人在用,遇到问题缺少社区反馈
DSH walks through these 9 checksDSH 会逐条核对这 9 项

Compatibility兼容性

  • DSH, Node, OS and profile requirementsDSH 版本 / Node 版本 / 操作系统 / profile 是否满足要求
  • External dependencies and runtimes (Electron / Python / Docker, ...)外部依赖与运行时(Electron / Python / Docker 等)是否齐备
  • Conflicts with installed plugins: command names, skill / tool names, ports, duplicate MCP registration与已装插件是否冲突:命令名、skill / tool 重名、端口占用、重复 MCP 注册

Security安全性

  • Repo matches the facts registered here; archived or abandoned?仓库是否与页面登记一致,是否归档或长期停更
  • Safety of preinstall / install / postinstall and install.sh / setup.ps1preinstall / install / postinstall 与 install.sh、setup.ps1 是否安全
  • curl|bash, download-then-execute, obfuscation, unrelated domains → stop immediatelycurl|bash、下载即执行、混淆代码、无关域名 → 立刻停止
  • Typosquatting or unmaintained packages among the new dependencies新增依赖里有没有 typosquatting 或无人维护的包
  • Requested permissions vs. what the feature actually needs申请了哪些权限、是否超出功能所需(filesystem / network / shell / clipboard)
  • Any sudo / admin requirement, plus uninstall and rollback是否要求 sudo / 管理员权限,以及卸载与回滚方式

Anything uncertain must be marked unknown with a note on how to confirm it. This site's signal screen is a static snapshot, not a security audit.拿不准的必须标「未知」并说明要我怎么确认。本站的信号筛查是静态快照,不能替代安全审计。

Or use CLI install (for developers)或使用命令行安装(适合开发者)

CLI Install命令行安装

dsh plugin --profile web add github:omdsh-dev/dsh-tool-time

把 omdsh-dev/dsh-tool-time 加入你的 DSH 配置(web profile)即可启用。

READMEREADME

dsh-tool-time

English

DSH 时间工具插件 —— 严格 ISO 解析、IANA 时区转换、UTC 日历运算、固定时长差。零依赖、零进程、纯函数。

License

动机

Agent 处理时间信息是最高频需求之一——"现在几点"、"3 天后是几号"、"把 UTC 转成北京时间"。当前做法 bash date 的问题:每次起进程、跨平台语法不一致(macOS 与 GNU date -d 完全不同)、时区转换靠 TZ=... 手动拼。模型心算时区偏移和闰年/DST 边界是错误高发区。

安全模型

无 eval、无 new Function。输入只经过严格校验:

  • 严格 ISO 8601 子集:仅接受 YYYY-MM-DD(UTC 零点)、YYYY-MM-DDTHH:mm:ssZ、YYYY-MM-DDTHH:mm:ss±HH:MM(±14:00 内,可选 .SSS 毫秒);不带时区的日期时间、RFC 2822、自然语言日期一律拒绝;2026-02-30 等日历溢出由查表校验拒绝(不依赖 Date 的静默归一化)
  • 时区名:IANA 名交给 Intl.DateTimeFormat 校验,非法即抛 time: unknown timezone
  • 数值:amount 必须是安全整数;unit 枚举白名单;所有字符串 ≤200 字符
  • Intl 环境固定:'en-CA' + hourCycle: 'h23'(避免午夜 24:00 与本地化数字)

架构

DSH Agent
    │ ctx.tools.register()
    ▼
src/index.ts(Cordis 插件入口 + action 分发 + 独立校验)
    │
    ▼
src/time.ts
    ├── parseStrictISO() — 严格 ISO 解析(正则 + 查表校验)
    ├── formatInTimezone() — Intl formatToParts 组装(时钟可注入)
    ├── addMonthsClamped() — 先置 1 日 → 目标年月 → 天数钳制
    └── diffBetween() — 固定时长(sign + absolute 分解)

工具声明

ctx.tools.register(defineTool({
  name: 'time',
  parameters: {
    action: { type: 'string', required: true, enum: ['now', 'convert', 'add', 'diff'] },
    value:  { type: 'string', description: 'Strict ISO 8601 timestamp' },
    timezone: { type: 'string', description: 'IANA timezone (default UTC; display only)' },
    from:   { type: 'string', description: 'diff start' },
    to:     { type: 'string', description: 'diff end' },
    amount: { type: 'integer', description: 'Signed safe integer' },
    unit:   { type: 'string', enum: ['seconds','minutes','hours','days','weeks','months','years'] },
  },
  output: { schema: { type: 'json' }, render: (_a, v) => [{ type: 'text', text: JSON.stringify(v, null, 2) }] },
  execute: (args) => Promise.resolve(executeAction(args.action, args) as JsonValue),
  timeoutMs: 1000,
}))

支持的操作

action 参数 返回
now timezone?(默认 UTC) 当前时间结构化表示
convert value + timezone(必填) 转换后的结构化时间
add value + amount + unit(timezone? 仅展示) 加减后的结构化时间
diff from + to 固定时长差(无月份/年份)

Showing the opening section of the README — the full document lives in the repository以上为 README 开头摘要,完整文档在仓库内 · View the full README on GitHub →在 GitHub 查看完整 README →

← 上一个 Prev dsh-tool-encoding 下一个 Next dsh-skin-toggle →