修复无法兑换bug

This commit is contained in:
yml2213
2026-05-29 17:28:19 +08:00
parent e8ba48d74f
commit bd0368f91e
4 changed files with 62 additions and 2 deletions
+15
View File
@@ -6,3 +6,18 @@ export function addHours(baseIso: string | null | undefined, hours: number): str
const baseTime = baseIso ? new Date(baseIso).getTime() : Date.now()
return new Date(baseTime + hours * 60 * 60 * 1000).toISOString()
}
export function normalizeTimestampIso(value: unknown, fallbackIso = nowIso()): string {
if (value instanceof Date) {
const timestamp = value.getTime()
return Number.isFinite(timestamp) ? value.toISOString() : fallbackIso
}
const normalized = String(value || '').trim()
if (!normalized) {
return fallbackIso
}
const timestamp = Date.parse(normalized)
return Number.isFinite(timestamp) ? new Date(timestamp).toISOString() : fallbackIso
}