Always the same date formatting by fixing a suitable locale

This commit is contained in:
Leo Vasanko 2023-11-05 17:14:10 +00:00
parent cdc936d2d5
commit 1250037cfd

View File

@ -42,13 +42,14 @@ export function formatUnixDate(t: number) {
return formatter.format(Math.round(diff / 86400000), 'day')
}
let d = date.toLocaleDateString(undefined, {
let d = date.toLocaleDateString('en-ie', {
weekday: 'short',
year: 'numeric',
month: 'short',
day: 'numeric'
}).replace("Sept", "Sep").replaceAll(',', '')
d = (d.length === 15 ? d : d.replace(' ', ' \u2007')).replaceAll(' ', '\u202F').replace('\u202F', '\u00A0')
}).replace("Sept", "Sep")
if (d.length === 14) d = d.replace(' ', '\u202F\u2007') // dom < 10 alignment (thin and figure spaces)
d = d.replaceAll(' ', '\u202F').replace('\u202F', '\u00A0') // nobr spaces, thin w/ date but not weekday
d = d.slice(0, -4) + d.slice(-2) // Two digit year is enough
return d
}