iamkun / iamkun/dayjs

Impossible to set time that don't exist in browser timezone in another timezone (during daylight saving change)

Open
#2,304 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**

During a daylight saving change, there will be an hour missing in the browser timezone.
Say the browser goes from utc+1 to utc+2 on a given day,
There will be an unexisting hour on the given day (23h day).
Now lets say you want to set the time in another timzeone that correspond to this unexisiting hour from the browser, it won't work!

Exemple:
```dayjs('2023-03-26T02:00:00').format('hh:mm A')```
will print `03:00` in Central European Summer Time (UTC+2) because `02:00` doesn't exists.
If you try to change timezone to a timezone that doesn't have daylight saving change (let's say utc+3)
it will be impossible to set time to `03:00` (it will gives `04:00`)

This is because dayjs always use the local as a reference

**Expected behavior**
the time should exist and et right

**Information**
- Day.js Version: latest
- OS: all
- Browser all
- Time zone: all

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the provided Day.js example on the reported DST transition, then trace the timezone conversion path that uses the browser's local time as a reference. Compare the result when converting the missing 02:00 local time to UTC+3. Done means the requested wall-clock time is preserved in the target timezone without shifting to 04:00.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.