Skip to content

Commit

Permalink
Intl.DateTimeFormat add timeZone data
Browse files Browse the repository at this point in the history
  • Loading branch information
romainmenke authored and JakeChampion committed Jun 10, 2021
1 parent f902678 commit f44fbe2
Show file tree
Hide file tree
Showing 6 changed files with 8,442 additions and 0 deletions.
40 changes: 40 additions & 0 deletions polyfills/Intl/DateTimeFormat/~timeZone/all/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#### Dependencies
dependencies = [
"Intl.DateTimeFormat"
]

#### Specification Link
spec = "https://tc39.es/ecma402/#sec-initializedatetimeformat"

#### Documentation Link
docs = "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat#using_options"

#### License
license = "MIT"

#### Notes
notes = [
"See formatjs documentation for more info on 'golden' vs 'all' timezones. https://formatjs.io/docs/polyfills/intl-datetimeformat"
]

#### Browser compatibility
[browsers]
android = "*"
ie = "9 - *"
ie_mob = "9 - *"
edge = "<79"
edge_mob = "<79"
firefox = "*"
opera = "*"
chrome = "<76"
safari = "*"
ios_saf = "*"
firefox_mob = "*"
samsung_mob = "*"

[install]
module = "@formatjs/intl-datetimeformat"
paths = [ "/add-all-tz.js" ]
clean = [
"polyfill.js",
]
14 changes: 14 additions & 0 deletions polyfills/Intl/DateTimeFormat/~timeZone/all/detect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
(function (global) {
if ('Intl' in global && 'DateTimeFormat' in global.Intl && 'format' in global.Intl.DateTimeFormat.prototype) {
try {
return (new Intl.DateTimeFormat('en', {
timeZone: 'Africa/Dakar',
timeZoneName: 'short'
}).format(new Date(Date.UTC(2012, 11, 20, 3, 0, 0, 200))).slice(-3) === 'GMT');
} catch(e) {
return false;
}
}

return false;
}(self))

0 comments on commit f44fbe2

Please sign in to comment.