From 222625a7d415752b57b0a527d11ecd728a3365b3 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Thu, 19 Dec 2024 15:26:12 -0600 Subject: [PATCH 1/2] 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 */ From aafa64ca139208595fc49ddce8ac0bff41e92987 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Thu, 19 Dec 2024 15:27:06 -0600 Subject: [PATCH 2/2] Actual fix --- src/locale/i18n.ts | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/locale/i18n.ts b/src/locale/i18n.ts index dca8d01a7c..43187a8859 100644 --- a/src/locale/i18n.ts +++ b/src/locale/i18n.ts @@ -1,7 +1,6 @@ // Don't remove -force from these because detection is VERY slow on low-end Android. // https://github.com/formatjs/formatjs/issues/4463#issuecomment-2176070577 import '@formatjs/intl-locale/polyfill-force' -import '@formatjs/intl-datetimeformat/polyfill-force' import '@formatjs/intl-pluralrules/polyfill-force' import '@formatjs/intl-numberformat/polyfill-force' import '@formatjs/intl-datetimeformat/locale-data/en' @@ -9,7 +8,6 @@ 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' @@ -47,20 +45,6 @@ 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 */