mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-05 14:52:09 +03:00
`parseResetTime` in `open-sse/services/usage.ts` and `codexUsageQuotas.ts` already handled `number` reset values with the `< 1e12 ? * 1000 : value` seconds-vs-ms heuristic, but for `string` inputs it always called `new Date(str)`. When a provider returned the reset timestamp as a numeric string (e.g. `"1700000000"`), `new Date(str)` returned Invalid Date, the try/catch swallowed it, and the function returned `null` — the reset window was silently dropped from quota snapshots. Numeric strings (`/^\d+$/`) are now detected and treated as Unix timestamps with the same seconds-vs-ms heuristic. ISO/parseable strings are untouched. Applied symmetrically in both parsers. TDD: 2 failing tests added in `tests/unit/usage-utils.test.ts` for the seconds-string and ms-string cases; both green after the fix (47/47 in file, 27/27 in adjacent usage/quota tests). Inspired-by: https://github.com/decolua/9router/pull/768 Co-authored-by: Zhen <zhen@dkzhen.org>