From 9b2c01fb02f303b80720f8ac8baa829bdff445f2 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Thu, 22 Aug 2024 19:24:45 +0800 Subject: [PATCH] Fix locale matching --- src/components/relative-time.jsx | 2 +- src/utils/nice-date-time.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/relative-time.jsx b/src/components/relative-time.jsx index af3b669c..9c62c771 100644 --- a/src/components/relative-time.jsx +++ b/src/components/relative-time.jsx @@ -16,7 +16,7 @@ function isValidDate(value) { const resolvedLocale = new Intl.DateTimeFormat().resolvedOptions().locale; const DTF = mem((locale, opts = {}) => { - const lang = localeMatch([locale], [resolvedLocale]); + const lang = localeMatch([locale], [resolvedLocale], locale); try { return new Intl.DateTimeFormat(lang, opts); } catch (e) {} diff --git a/src/utils/nice-date-time.js b/src/utils/nice-date-time.js index dde3f7a0..29019360 100644 --- a/src/utils/nice-date-time.js +++ b/src/utils/nice-date-time.js @@ -9,7 +9,7 @@ const _DateTimeFormat = (opts) => { const { locale, dateYear, hideTime, formatOpts } = opts || {}; const loc = locale && !/pseudo/i.test(locale) - ? localeMatch([locale], [defaultLocale]) + ? localeMatch([locale], [defaultLocale], locale) : defaultLocale; const currentYear = new Date().getFullYear(); const options = {