33 lines
638 B
JavaScript
33 lines
638 B
JavaScript
const dateFormatter = new Intl.DateTimeFormat('en-US', {
|
|
year: 'numeric',
|
|
month: 'short',
|
|
day: '2-digit',
|
|
hour: '2-digit',
|
|
minute: '2-digit',
|
|
hour12: false,
|
|
timeZone: 'UTC',
|
|
})
|
|
|
|
const numberFormatter = new Intl.NumberFormat('en-US')
|
|
|
|
export function formatEnhanceDate(value) {
|
|
if (!value) return '—'
|
|
|
|
const parsed = new Date(value)
|
|
|
|
if (Number.isNaN(parsed.getTime())) {
|
|
return '—'
|
|
}
|
|
|
|
return `${dateFormatter.format(parsed)} UTC`
|
|
}
|
|
|
|
export function formatEnhanceInteger(value) {
|
|
const parsed = Number(value)
|
|
|
|
if (!Number.isFinite(parsed)) {
|
|
return '0'
|
|
}
|
|
|
|
return numberFormatter.format(parsed)
|
|
} |