From 222625a7d415752b57b0a527d11ecd728a3365b3 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Thu, 19 Dec 2024 15:26:12 -0600 Subject: [PATCH] Ideal fix, doesn't work --- src/locale/i18n.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/locale/i18n.ts b/src/locale/i18n.ts index a78288b901..dca8d01a7c 100644 --- a/src/locale/i18n.ts +++ b/src/locale/i18n.ts @@ -9,6 +9,7 @@ import '@formatjs/intl-pluralrules/locale-data/en' import '@formatjs/intl-numberformat/locale-data/en' import {useEffect} from 'react' +import {getCalendars} from 'expo-localization' import {i18n} from '@lingui/core' import {sanitizeAppLanguageSetting} from '#/locale/helpers' @@ -46,6 +47,20 @@ import {messages as messagesZh_HK} from '#/locale/locales/zh-HK/messages' import {messages as messagesZh_TW} from '#/locale/locales/zh-TW/messages' import {useLanguagePrefs} from '#/state/preferences' +/** + * Set default time zone for Intl.DateTimeFormat polyfill from formatjs + * {@link https://formatjs.github.io/docs/polyfills/intl-datetimeformat/#default-timezone} + * + * According to docs, `getCalendars` is guaranteed to have at least one + * calendar, and for now this ONLY returns one calendar. + * {@link https://docs.expo.dev/versions/latest/sdk/localization/#localizationgetcalendars} + */ +if ('__setDefaultTimeZone' in Intl.DateTimeFormat) { + console.log('Setting default time zone', getCalendars()[0].timeZone) + // @ts-ignore + Intl.DateTimeFormat.__setDefaultTimeZone(getCalendars()[0].timeZone) +} + /** * We do a dynamic import of just the catalog that we need */