Make profile SSR formatting deterministic
This commit is contained in:
@@ -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)
|
||||
}
|
||||
Reference in New Issue
Block a user