Make sure nice-date-time also match the more local locale

This commit is contained in:
Lim Chee Aun 2024-08-22 00:10:48 +08:00
parent c54228627c
commit cea06f32fc

View file

@ -1,12 +1,16 @@
import { i18n } from '@lingui/core'; import { i18n } from '@lingui/core';
import localeMatch from './locale-match';
import mem from './mem'; import mem from './mem';
const defaultLocale = new Intl.DateTimeFormat().resolvedOptions().locale; const defaultLocale = new Intl.DateTimeFormat().resolvedOptions().locale;
const _DateTimeFormat = (opts) => { const _DateTimeFormat = (opts) => {
const { locale, dateYear, hideTime, formatOpts } = 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 currentYear = new Date().getFullYear();
const options = { const options = {
// Show year if not current year // Show year if not current year