From cea06f32fcd6d503942032ca98445714e0cd6ace Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Thu, 22 Aug 2024 00:10:48 +0800 Subject: [PATCH] Make sure nice-date-time also match the more local locale --- src/utils/nice-date-time.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils/nice-date-time.js b/src/utils/nice-date-time.js index a1d5baff..dde3f7a0 100644 --- a/src/utils/nice-date-time.js +++ b/src/utils/nice-date-time.js @@ -1,12 +1,16 @@ import { i18n } from '@lingui/core'; +import localeMatch from './locale-match'; import mem from './mem'; const defaultLocale = new Intl.DateTimeFormat().resolvedOptions().locale; const _DateTimeFormat = (opts) => { const { locale, dateYear, hideTime, formatOpts } = opts || {}; - const loc = locale && !/pseudo/i.test(locale) ? locale : defaultLocale; + const loc = + locale && !/pseudo/i.test(locale) + ? localeMatch([locale], [defaultLocale]) + : defaultLocale; const currentYear = new Date().getFullYear(); const options = { // Show year if not current year