diff --git a/src/relative-time-element.ts b/src/relative-time-element.ts index c943a2c..3c48216 100644 --- a/src/relative-time-element.ts +++ b/src/relative-time-element.ts @@ -4,10 +4,10 @@ import {RelativeTimeFormat as RelativeTimeFormatPonyfill} from './relative-time- import {isDuration, withinDuration} from './duration.js' import {strftime} from './strftime.js' -const supportsIntlDatetime = 'Intl' in window && 'DateTimeFormat' in Intl +const supportsIntlDatetime = typeof Intl !== 'undefined' && 'DateTimeFormat' in Intl const DateTimeFormat = supportsIntlDatetime ? Intl.DateTimeFormat : DateTimeFormatPonyFill -const supportsIntlRelativeTime = 'Intl' in window && 'RelativeTimeFormat' in Intl +const supportsIntlRelativeTime = typeof Intl !== 'undefined' && 'RelativeTimeFormat' in Intl const RelativeTimeFormat = supportsIntlRelativeTime ? Intl.RelativeTimeFormat : RelativeTimeFormatPonyfill export type Format = 'auto' | 'micro' | 'elapsed' | string diff --git a/src/strftime.ts b/src/strftime.ts index f5b6c14..0155586 100644 --- a/src/strftime.ts +++ b/src/strftime.ts @@ -1,4 +1,4 @@ -const supportsIntlDatetime = 'Intl' in window && 'DateTimeFormat' in Intl +const supportsIntlDatetime = typeof Intl !== 'undefined' && 'DateTimeFormat' in Intl const weekdays = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] const months = [