fix: ignore unsafe timestamp values · openclaw/openclaw@41366d3
steipete
·
2026-05-29
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +import { describe, expect, it } from "vitest"; |
| 2 | +import { normalizeTimestamp } from "./date-time.js"; |
| 3 | + |
| 4 | +describe("normalizeTimestamp", () => { |
| 5 | +it("normalizes numeric second and millisecond timestamps", () => { |
| 6 | +expect(normalizeTimestamp("1700000000")).toEqual({ |
| 7 | +timestampMs: 1_700_000_000_000, |
| 8 | +timestampUtc: "2023-11-14T22:13:20.000Z", |
| 9 | +}); |
| 10 | +expect(normalizeTimestamp("1700000000000")).toEqual({ |
| 11 | +timestampMs: 1_700_000_000_000, |
| 12 | +timestampUtc: "2023-11-14T22:13:20.000Z", |
| 13 | +}); |
| 14 | +}); |
| 15 | + |
| 16 | +it("ignores unsafe or out-of-range numeric timestamp strings", () => { |
| 17 | +expect(normalizeTimestamp("9007199254740993")).toBeUndefined(); |
| 18 | +expect(normalizeTimestamp("999999999999999999999999")).toBeUndefined(); |
| 19 | +}); |
| 20 | +}); |
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。