Files
SkinbaseNova/resources/js/lib/profileFormatters.js
T

20 lines
561 B
JavaScript

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)
}