From 1250037cfd6ac559fa14690a1bfdaf4bac547896 Mon Sep 17 00:00:00 2001 From: Leo Vasanko Date: Sun, 5 Nov 2023 17:14:10 +0000 Subject: [PATCH] Always the same date formatting by fixing a suitable locale --- cista-front/src/utils/index.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cista-front/src/utils/index.ts b/cista-front/src/utils/index.ts index dd0bb36..384eb27 100644 --- a/cista-front/src/utils/index.ts +++ b/cista-front/src/utils/index.ts @@ -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 }