Skip to content

Commit

Permalink
Merge pull request #208 from github/use-intl-without-window-prefix
Browse files Browse the repository at this point in the history
use `Intl` without window prefix
  • Loading branch information
keithamus authored Nov 22, 2022
2 parents 82f9512 + 6a60b84 commit 265a9db
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/relative-time-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/strftime.ts
Original file line number Diff line number Diff line change
@@ -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 = [
Expand Down

0 comments on commit 265a9db

Please sign in to comment.