Fix quota reset timestamp parsing (#768)

Co-authored-by: Delynn Assistant <zhen@dkzhen.org>
This commit is contained in:
Zhen
2026-04-28 10:05:54 +07:00
committed by GitHub
parent 296e21c8ad
commit 85959aac22

View File

@@ -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();
}