From ab33e46789d178d16126b9306eedb1137f4a3243 Mon Sep 17 00:00:00 2001 From: Marcus Andersson Date: Thu, 8 Oct 2020 09:47:08 +0200 Subject: [PATCH] Bugfix: improved the way of checking if browser supports Intl.DateTimeFormat (#28086) --- packages/grafana-data/src/datetime/formats.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/grafana-data/src/datetime/formats.ts b/packages/grafana-data/src/datetime/formats.ts index 79344a77385..2c8ae0e3623 100644 --- a/packages/grafana-data/src/datetime/formats.ts +++ b/packages/grafana-data/src/datetime/formats.ts @@ -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); +};