Make profile SSR formatting deterministic

This commit is contained in:
2026-08-29 20:24:38 +02:00
parent 872f420190
commit 99d94c9333
5 changed files with 86 additions and 4 deletions
+19
View File
@@ -0,0 +1,19 @@
const PROFILE_LOCALE = 'en-US'
const PROFILE_TIME_ZONE = 'UTC'
export function formatProfileNumber(value) {
const numeric = Number(value ?? 0)
return Number.isFinite(numeric) ? new Intl.NumberFormat(PROFILE_LOCALE).format(numeric) : '0'
}
export function formatProfileDate(value, options = {}) {
if (!value) return null
const date = value instanceof Date ? value : new Date(value)
if (Number.isNaN(date.getTime())) return null
return new Intl.DateTimeFormat(PROFILE_LOCALE, {
...options,
timeZone: PROFILE_TIME_ZONE,
}).format(date)
}