iamkun / iamkun/dayjs

Add support for non-canonical timezones

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

Description

**Describe the bug**
"Invalid time zone specified" error received for "US/Pacific" timezone (as well as US/Central, US/Eastern, US/Mountain).

**Expected behavior**
The code should not crash.

**Information**
- Day.js Version [e.g. v1.10.6]
- OS: Linux / MacOS (NodeJS project)
- Time zone: US timezones, but any other deprecated / non-canonical timezone.

**Details**
iOS allows a user to choose timezones which are deprecated / non-canonical (e.g. "Pacifica, U.S.A." which is sent as "US/Pacific").
Those are sent from a mobile device onto the server, which crashes on `Date.toLocaleString`.

It would be preferred to fix this on the dayjs timezone plugin level.
The question is whether this will require writing a new plugin, which will be installed on top of the 'timezone' plugin and will convert non-canonical timezones to canonical ones - OR - if this should be a new flag introduced on the exiting timezone plugin.

Either way, this will probably require installing a timezone conversion package (e.g. US/Pacific -> America/Los_Angeles), so it would be interesting to understand how that would be integrated as well.

Note: A different, better (and easier?) way to solve this would be warmly welcome.

Contributor guide

Open the contributing guide

Research direction

Start at the Day.js timezone plugin and reproduce the failure with a non-canonical value such as "US/Pacific" reaching Date.toLocaleString. Done means these deprecated or non-canonical timezone inputs no longer crash and resolve to the appropriate canonical timezone; the issue leaves the plugin-versus-new-plugin approach open.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
internationalization
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.