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') return formatter.format(Math.round(diff / 86400000), 'day')
} }
let d = date.toLocaleDateString(undefined, { let d = date.toLocaleDateString('en-ie', {
weekday: 'short', weekday: 'short',
year: 'numeric', year: 'numeric',
month: 'short', month: 'short',
day: 'numeric' day: 'numeric'
}).replace("Sept", "Sep").replaceAll(',', '') }).replace("Sept", "Sep")
d = (d.length === 15 ? d : d.replace(' ', ' \u2007')).replaceAll(' ', '\u202F').replace('\u202F', '\u00A0') 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 d = d.slice(0, -4) + d.slice(-2) // Two digit year is enough
return d return d
} }