Incorrect UTC offset when manipulating dayJS object (DST/STD change)
- Dominant language
- JavaScript
- Stars
- 48.7k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
In the code-snipped below, a new dayjs object is initialized and set to `Asia/Tel_Aviv`. This timezone is different from my own one, which is `Europe/Berlin`.
The object is set to the 31st of October 2021. On that day, Israel (and the majority of the remaining world, which is observing DST) will change back from Daylight Savings Time to Standard Time.
2 am correctly appears twice. However, the UTC offset incorrectly does not change. Instead of printing `02:00+03:00` twice, it should print `02:00+03:00` once, followed by `02:00+02:00`
```
let day = dayjs('2021-10-31').tz('Asia/Tel_Aviv').startOf('day');
console.log(day.format('HH:mmZ'));
day = day.add(1, 'hour');
console.log(day.format('HH:mmZ'));
day = day.add(1, 'hour');
console.log(day.format('HH:mmZ'));
day = day.add(1, 'hour');
console.log(day.format('HH:mmZ'));
day = day.add(1, 'hour');
console.log(day.format('HH:mmZ'));
```
**Expected behavior**
| Actual | Expected |
|:---------:|:------:|
| 00:00+03:00 | 00:00+03:00 |
| 01:00+03:00 | 01:00+03:00 |
| 02:00+03:00 | 02:00+03:00 |
| 02:00+03:00 | 02:00+02:00 |
| 03:00+03:00 | 03:00+02:00 |
**Information**
- Day.js v1.10.6
- OS: macOS Big Sur (11.5.2)
- Browser: Google Chrome 92.0.4515.159 (Official Build) (x86_64)
- Time zone: Europe/Berlin (we are currently on UTC+02:00)
Contributor guide
Research direction
Reproduce the issue using the provided dayjs timezone example with Asia/Tel_Aviv and the DST transition date. Start by tracing the timezone plugin path used by .tz() and add(), then verify that the repeated 02:00 output changes from +03:00 to +02:00 and that the following 03:00 retains +02:00.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100