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.

timezone plugin broken in IE11 (unsupported method)

See original GitHub issue

Describe the bug Intl.DateTimeFormat.formatToParts is not supported in IE11. This method is used by the timezone plugin here. Using the plugin in IE11 results in a runtime error.

Expected behavior IE11 support. Documentation states “Currently the following browsers are used for the ci system: Chrome on Windows XP, IE 8, 9, and 10 on Windows 7, IE 11 on Windows 10, latest Firefox on Linux, and latest Safari on OSX 10.8 and 10.11.”

Information

  • Day.js Version 1…10.4
  • OS: Windows 10
  • Browser IE11
  • Time zone: GMT-07:00 DST (Pacific Daylight Time)

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:5
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
MattStaudingercommented, Jul 6, 2021

I now found a way to make this work. There were 2 things that I had to change:

  1. I used the syntax dayjs.tz("2014-06-01 12:00", "America/New_York") which is using formatToParts under the hood. When I used dayjs("2014-06-01 12:00").tz("America/New_York") IE 11 doesn’t complain anymore.

  2. After that change IE 11 then output Invalid Date for any kind of timezone. This had to do with an issue explained in here. I implemented the polyfill suggested there and it worked.

It obviously feels a little hacky, but solves the problem. So I think it would be good if the documentation was updated and going a little more into detail how timezones can be made to work in IE 11.

0reactions
javier-garcia-meteologicacommented, Dec 10, 2021

@MattStaudinger

I used the syntax dayjs.tz("2014-06-01 12:00", "America/New_York") which is using formatToParts under the hood. When I used dayjs("2014-06-01 12:00").tz("America/New_York") IE 11 doesn’t complain anymore

These expressions have different meanings and produce different results, they should not be used interchangeably.

$ dayjs.tz("2014-06-01 12:00", "America/New_York").toISOString();
"2014-06-01T16:00:00.000Z"
$ dayjs("2014-06-01 12:00").tz("America/New_York").toISOString();
"2014-06-01T09:00:00.000Z"

This comment https://github.com/formatjs/formatjs/issues/2529#issuecomment-767387923 explains how to polyfill Intl.DateTimeFormat properly.

import '@formatjs/intl-getcanonicallocales/polyfill';
import '@formatjs/intl-locale/polyfill';

import '@formatjs/intl-pluralrules/polyfill'
import '@formatjs/intl-pluralrules/locale-data/en' // locale-data for en

import '@formatjs/intl-numberformat/polyfill'
import '@formatjs/intl-numberformat/locale-data/en' // locale-data for en

import '@formatjs/intl-datetimeformat/polyfill'
import '@formatjs/intl-datetimeformat/locale-data/en' // locale-data for en
import '@formatjs/intl-datetimeformat/add-all-tz' // Add ALL tz data
Read more comments on GitHub >

github_iconTop Results From Across the Web

timezone plugin broken in IE11 (unsupported method) #1489
Describe the bug Intl.DateTimeFormat.formatToParts is not supported in IE11. This method is used by the timezone plugin here. Using the plugin in IE11 ......
Read more >
Internet Explorer 11 computed timezone bug - Stack Overflow
Indeed, this isn't supported on IE 11. See the Intl Compatibility Chart, under "DateTimeFormat" then "resolvedOptions().timeZone defaults to ...
Read more >
Discussion: Dropping support for IE11 – Make WordPress Core
The proposed policy for WordPress is to end Internet Explorer 11 ... be broken in order to help identify development and testing needs....
Read more >
Fix web compatibility issues using document modes and the ...
The Internet Explorer 11 Enterprise Mode site list lets you specify ... To see if this fix might help you, run through this...
Read more >
Docs - Moment.js
If one needs internationalization or time zone support, Moment can get quite ... Some libraries are split into modules, plugins, or companion libraries....
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