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