iamkun / iamkun/dayjs

Incorrect behavior with dayjs.tz and add method

Open
#2,099 3 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

**Describe the bug**
So, if you generate array of dates with timezone and you meet date with changing hours (winter to summer or summer to winter), you can get incorrect dates.

For example:
```
const timezoneSydney = 'Australia/Sydney';
const date1 = dayjs('2022-09-25T00:00:00+10:00').tz(timezoneSydney);
for (let i = 0; i < 10; i++) {
console.log(date1.add(i, 'day').format());
}
```
![image](https://user-images.githubusercontent.com/32958181/198202084-c2442f27-d6a5-4a5b-aef4-dc8f396d698f.png)

Sydney have changing hours on 2 October in 02:00 (to 03:00)

**Expected behavior**
I think, if dayjs works with timezones it should change time hours automatically.

**Information**
- Day.js Version: 1.11.6
- Time zone: GMT+07:00

Contributor guide

Open the contributing guide

Research direction

Start by running the provided dayjs.tz and add reproduction for Australia/Sydney across the 2022-10-02 daylight-saving transition. Trace the timezone handling used by add and compare each formatted result with the expected offset and local time. Done means dates generated across the transition adjust their time hours correctly without breaking other timezone behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
web-dev
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.