sinceMs
A duration as people type it ("30m", "24h", "7d") in ms.
import { UsageError } from "#codebase/tcmts/cli/ui"; export function sinceMs(spec: string): number { const m = /^(\d+)(s|m|h|d)$/.exec(spec.trim()); if (!m) throw new UsageError(`'${spec}' isn't a duration: say 30m, 24h or 7d`); return ( Number(m[1]) * { s: 1000, m: 60_000, h: 3_600_000, d: 86_400_000 }[m[2] as "s" | "m" | "h" | "d"] ); }