From f8221777887c30d40f4e90f0b4729a87e2216bec Mon Sep 17 00:00:00 2001 From: Alex van Andel Date: Mon, 14 Nov 2022 19:46:58 +0000 Subject: [PATCH] Use Intl.DateTimeFormat logic to determine locale. (#5519) --- packages/lib/timeFormat.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/packages/lib/timeFormat.ts b/packages/lib/timeFormat.ts index 6c66e8f575..ee6c71b1ea 100644 --- a/packages/lib/timeFormat.ts +++ b/packages/lib/timeFormat.ts @@ -31,13 +31,8 @@ export const isBrowserLocale24h = () => { } else if (localStorageTimeFormat === false) { return false; } - - let locale = "en-US"; - if (typeof window !== "undefined" && navigator) { - locale = window.navigator?.language; - } - - if (!!new Intl.DateTimeFormat(locale, { hour: "numeric" }).format(0).match(/M/i)) { + // Intl.DateTimeFormat with value=undefined uses local browser settings. + if (!!new Intl.DateTimeFormat(undefined, { hour: "numeric" }).format(0).match(/M/i)) { setIs24hClockInLocalStorage(false); return false; } else {