Timezone conversion is broken when not using DST Time
- Dominant language
- JavaScript
- Stars
- 48.7k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
DST not working in dayjs
**Expected behavior**
It seems that DST has some problem converting times with dayjs :
```
dayjs("2021-10-30").set("hour", 18).set("minute", 42).tz("Europe/Paris").toISOString()
'2021-10-30T16:42:00.000Z'
```
It's correct, the 30th of october 2021, we are now on daylight saving time ( DST ) at Paris timezone ( UTC+1 ) we substract 2 hours to get the UTC TIME, 16:42 is correct.
```
dayjs("2021-10-31").set("hour", 18).set("minute", 42).tz("Europe/Paris").toISOString()
'2021-10-31T18:42:00.000Z'
```
Is incorrect, the 31th of october 2021, DST will be over, but we should still substract 1 hour to get the UTC Time ( 17:42 )
Seems that no matter which timezone we use, when we are not in DST, the offset is not done in reference with UTC.
```
dayjs("2021-10-31").set("hour", 18).set("minute", 42).tz("Asia/Tel_Aviv").toISOString()
'2021-10-31T18:42:00.000Z'
dayjs("2021-10-30").set("hour", 18).set("minute", 42).tz("Asia/Tel_Aviv").toISOString()
'2021-10-30T16:42:00.000Z'
```
Seems to be kind of the same problem referenced here : https://github.com/iamkun/dayjs/issues/1622
**Information**
- Day.js Version 1.10.7
- OS: MacOS
- Browser : Chrome 93.0.4577.63 (Build officiel) (x86_64)
- Time zone: UTC+1 ( Europe/Paris )
Contributor guide
Research direction
Start by running the reported dayjs(...).tz("Europe/Paris") and dayjs(...).tz("Asia/Tel_Aviv") examples against the timezone conversion entry point. Compare the October 30 and 31 UTC offsets with the expected values in the report. Done means non-DST conversions apply the correct timezone offset without regressing DST behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- localization
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100