Use Intl.DateTimeFormat logic to determine locale. (#5519)

pull/5374/head
Alex van Andel 2022-11-14 19:46:58 +00:00 committed by GitHub
parent 1edc9c50d5
commit f822177788
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 7 deletions

View File

@ -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 {