fix(cron): bound relative at timestamps · openclaw/openclaw@e0248fc
steipete
·
2026-05-31
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -255,6 +255,13 @@ describe("parseAt", () => {
|
255 | 255 | |
256 | 256 | expect(parseAt("+999999999999999999d")).toBeNull(); |
257 | 257 | }); |
| 258 | + |
| 259 | +it("rejects relative durations when the current clock is at the Date boundary", () => { |
| 260 | +vi.useFakeTimers(); |
| 261 | +vi.setSystemTime(new Date(8_640_000_000_000_000)); |
| 262 | + |
| 263 | +expect(parseAt("+1m")).toBeNull(); |
| 264 | +}); |
258 | 265 | }); |
259 | 266 | |
260 | 267 | describe("getCronChannelOptions", () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -10,7 +10,10 @@ import {
|
10 | 10 | parseOffsetlessIsoDateTimeInTimeZone, |
11 | 11 | } from "../../infra/format-time/parse-offsetless-zoned-datetime.js"; |
12 | 12 | import { defaultRuntime, type RuntimeEnv } from "../../runtime.js"; |
13 | | -import { timestampMsToIsoString } from "../../shared/number-coercion.js"; |
| 13 | +import { |
| 14 | +resolveExpiresAtMsFromDurationMs, |
| 15 | +timestampMsToIsoString, |
| 16 | +} from "../../shared/number-coercion.js"; |
14 | 17 | import { |
15 | 18 | normalizeLowercaseStringOrEmpty, |
16 | 19 | normalizeOptionalString, |
@@ -204,7 +207,8 @@ export function parseAt(input: string, tz?: string): string | null {
|
204 | 207 | const durationInput = raw.startsWith("+") ? raw.slice(1) : raw; |
205 | 208 | const dur = parseDurationMs(durationInput); |
206 | 209 | if (dur !== null) { |
207 | | -return timestampMsToIsoString(Date.now() + dur) ?? null; |
| 210 | +const expiresAt = resolveExpiresAtMsFromDurationMs(dur); |
| 211 | +return timestampMsToIsoString(expiresAt) ?? null; |
208 | 212 | } |
209 | 213 | return null; |
210 | 214 | } |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。