iamkun / iamkun/dayjs

DST inconsistency when changing UTC time to CST and back to UTC

Open
#2,268 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**
When I convert a UTC time to a timezone and back again, I get a different time. This is right around when DST starts.
```
dayjs.utc('2023-03-12T07:00:00Z').tz('America/Chicago').utc().format()
'2023-03-12T06:00:00+00:00'
```

Maybe this is a misunderstanding of the library but I don't get how the above statement could give me a different time than I started with.

Note that when I run this, I get -5 offset instead of -6; it seems like maybe it's changing DST over at 2AM EST instead of 2AM CST (like it seems like it should):
```
dayjs.utc('2023-03-12T07:00:00Z').tz('America/Chicago').format()
'2023-03-12T01:00:00-05:00'
```

**Expected behavior**
I would expect to be able to convert a time to a different timezone and back and get the same time I started with.

**Information**
- Day.js Version v1.11.7
- OS: MacOS arm
- Browser: Chrome 111
- Time zone: GMT-04:00 EDT (Eastern Daylight Time)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.