question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Intl.DateTimeFormat is missing timezone data

See original GitHub issue

Hello everyone,

Bug/feature

I am not sure if it’s a bug or an intended behavior

What

Intl polyfill is missing timezone data.

The full polyfill could include timezone data or there could be an extra polyfill to add this data

Details

The polyfill in question is here : https://formatjs.io/docs/polyfills/intl-datetimeformat/

for the moment, if we want to have timezone support, for example for Safari, we have to add

import "@formatjs/intl-datetimeformat/add-all-tz" to our code

Example : User Agent : Mozilla/5.0 (iPhone; CPU iPhone OS 14_4_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Mobile/15E148 Safari/604.1 Polyfill: https://polyfill.io/v3/polyfill.js?features=Intl

Results :

* Features requested: Intl
 * 
 * - Intl.Locale, License: MIT (required by "Intl.PluralRules.~locale.en", "Intl.PluralRules", "Intl")
 * - Intl.PluralRules, License: MIT (required by "Intl.PluralRules.~locale.en", "Intl")
 * - Intl.NumberFormat, License: MIT (required by "Intl.NumberFormat.~locale.en", "Intl")
 * - Intl.DateTimeFormat, License: MIT (required by "Intl.DateTimeFormat.~locale.en", "Intl")
 * - Intl.DateTimeFormat.~locale.en, License: MIT (required by "Intl")
 * - Intl.NumberFormat.~locale.en, License: MIT (required by "Intl")
 * - Intl.PluralRules.~locale.en, License: MIT (required by "Intl") */

But InitializeDateTimeFormat fails if used with a timezone (any timezone)

I digged a bit in the repo but did not find anything related to this

Not sure how to contribute, but if needed, I’d be glad to help 😃

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
tgandee79commented, May 3, 2021

I’ll see if I can tackle it.

Separate featuring meaning a new addition to the Polyfill for consumption:

https://polyfill.com/v3/polyfill.min.js?features=Intl.DateTimeFormat,Intl.DateTimeFormat.prototype.formatToParts,Intl.DateTimeFormat.~locale.en-GB,Intl.DateTimeFormat.timeZone

??

1reaction
eltonio450commented, Apr 30, 2021

Hello 😃

yes data is indeed included if you use the localized polyfills, but there might be a bug because __addTzData is never called

Read more comments on GitHub >

github_iconTop Results From Across the Web

Keep timezone information when formatting a date with `Intl`
I'm currently located in timezone GMT+1. So that makes sense, it's displaying the time in my local timezone. Is there a way to...
Read more >
Intl.DateTimeFormat.prototype.resolvedOptions() - JavaScript
The Intl.DateTimeFormat.prototype.resolvedOptions() method returns a new object with properties reflecting the locale and date and time formatting options ...
Read more >
intl-dateformat - npm Package Health Analysis - Snyk
Looks like intl-dateformat is missing a security policy. ... Intl.DateTimeFormat , there is no need to bundle additional locales or a timezones database....
Read more >
Converting and Formatting Dates and Time Zones with ... - Twilio
It's important to note that the time and time zone displayed are ... It's extremely powerful, and in particular, Intl.DateTimeFormat is ...
Read more >
formatDate - Angular
A locale code for the locale format rules to use. timezone, string. The time zone. A time zone offset from GMT (such as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found