From 85959aac22fc829bbae865f23d2d8a1db9e591c8 Mon Sep 17 00:00:00 2001 From: Zhen <80612068+DEYLNN@users.noreply.github.com> Date: Tue, 28 Apr 2026 10:05:54 +0700 Subject: [PATCH] Fix quota reset timestamp parsing (#768) Co-authored-by: Delynn Assistant --- open-sse/services/usage.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/open-sse/services/usage.js b/open-sse/services/usage.js index a6882d7c..3fcb0e42 100644 --- a/open-sse/services/usage.js +++ b/open-sse/services/usage.js @@ -78,13 +78,17 @@ function parseResetTime(resetValue) { return resetValue.toISOString(); } - // If it's a number (Unix timestamp in milliseconds) + // Unix timestamps from provider APIs may be seconds or milliseconds. if (typeof resetValue === 'number') { - return new Date(resetValue).toISOString(); + return new Date(resetValue < 1e12 ? resetValue * 1000 : resetValue).toISOString(); } - // If it's a string (ISO date or any parseable date string) + // If it's a numeric string, treat it like a Unix timestamp too. if (typeof resetValue === 'string') { + if (/^\d+$/.test(resetValue)) { + const timestamp = Number(resetValue); + return new Date(timestamp < 1e12 ? timestamp * 1000 : timestamp).toISOString(); + } return new Date(resetValue).toISOString(); }