Bugfix: improved the way of checking if browser supports Intl.DateTimeFormat (#28086)

This commit is contained in:
Marcus Andersson 2020-10-08 09:47:08 +02:00 committed by GitHub
parent c064c16e83
commit ab33e46789
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -88,7 +88,7 @@ export function localTimeFormat(
locale?: string | string[] | null, locale?: string | string[] | null,
fallback?: string fallback?: string
): string { ): string {
if (!window.Intl) { if (missingIntlDateTimeFormatSupport()) {
return fallback ?? DEFAULT_SYSTEM_DATE_FORMAT; return fallback ?? DEFAULT_SYSTEM_DATE_FORMAT;
} }
@ -115,3 +115,7 @@ export function localTimeFormat(
} }
export const systemDateFormats = new SystemDateFormatsState(); export const systemDateFormats = new SystemDateFormatsState();
const missingIntlDateTimeFormatSupport = (): boolean => {
return !('DateTimeFormat' in Intl) || !('formatToParts' in Intl.DateTimeFormat.prototype);
};