iamkun / iamkun/dayjs

toLocaleString call in timezone throws error "Invalid date" on IE11

Open
#1,497 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
48.7k
Forks
2.5k
PR merge metrics
No merged PRs in 30d

Description

I was trying ot use dayjs in IE11 with this polyfill https://www.npmjs.com/package/date-time-format-timezone and I got an error on this line:
https://github.com/iamkun/dayjs/blob/9c20e77caf7b1b5eccf418175203b198d4e29535/src/plugin/timezone/index.js#L98

trying it out in the browser console:
![image (18)](https://user-images.githubusercontent.com/1305378/119128404-e997ba00-ba35-11eb-8b2a-d5fc4f053463.png)

The polyfill it does seem to work fine-
![image](https://user-images.githubusercontent.com/1305378/119130437-83606680-ba38-11eb-8af5-199252eb6cab.png)

Without the polyfill dayjs timezone can never work correctly.
Maybe it would be a good idea to add some spec or remove this
![image](https://user-images.githubusercontent.com/1305378/119137571-39c84980-ba41-11eb-9d8d-b56a83fea6fe.png)
because this just creates false impression that you can use dayjs on IE without any issues.

Maybe with this polyfill: https://formatjs.io/docs/polyfills/intl-datetimeformat

It would work better, but it doesn bundle correctly with Vite, so I cannot try that out.

Contributor guide

Open the contributing guide

Research direction

Read src/plugin/timezone/index.js at the reported line and reproduce the Invalid date error in IE11 with the date-time-format-timezone polyfill. Compare the browser-console behavior with the polyfill examples; done means reaching a maintainer-confirmed resolution for IE11 support, such as a tested compatibility change or clear documentation of the limitation.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
localization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.