`dayjs.tz` is not idempotent with dates in DST when it's not currently DST
See original GitHub issueDescribe the bug Given:
- it is currently Standard Time (i.e. not Daylight Saving Time)
- the date being manipulated is in Daylight Saving Time
When Dayjs#tz is called more than once on a Dayjs object, the time moves back 1 hour each time Dayjs#tz is called.
> dayjs('2020-08-08T00:00:00.000Z').toString()
//=> 'Sat, 08 Aug 2020 00:00:00 GMT'
> dayjs('2020-08-08T00:00:00.000Z').tz('America/Chicago').toString()
//=> 'Fri, 07 Aug 2020 23:00:00 GMT'
> dayjs('2020-08-08T00:00:00.000Z').tz('America/Chicago').tz('America/Chicago').toString()
//=> 'Fri, 07 Aug 2020 22:00:00 GMT'
> dayjs('2020-08-08T00:00:00.000Z').tz('America/Chicago').tz('America/Chicago').tz('America/Chicago').toString()
//=> 'Fri, 07 Aug 2020 21:00:00 GMT'
The result is the same regardless of what timezones are used, or whether a timezone arg is passed in at all:
> dayjs('2020-08-08T00:00:00.001Z').tz('UTC').tz().tz('UTC').toString()
//=> 'Fri, 07 Aug 2020 21:00:00 GMT'
> dayjs('2020-08-08T00:00:00.001Z').tz('America/Chicago').tz('UTC').tz().toString()
//=> 'Fri, 07 Aug 2020 21:00:00 GMT'
> dayjs('2020-08-08T00:00:00.001Z').tz().tz().tz().toString()
//=> 'Fri, 07 Aug 2020 21:00:00 GMT'
It’s February and I’m in Chicago, so I’ve only been able to confirm this issue occurs during CST with a date in CDT. I suspect that the opposite will be true in a few weeks (that calling Dayjs#tz on a CST time during CDT will result in a one-hour shift the other way).
And I saw several open issue tickets that are likely related or the result of the same underlying problem:
Expected behavior Applying a timezone should not change the underlying time.
Information
- Day.js v1.10.7
- OS: iOS 12.1
- Time zone: GMT-06:00 (Central Standard Time)
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:10
Top Results From Across the Web
dayjs() is in the wrong timezone - javascript - Stack Overflow
Calling dayjs() results in a date that is correct except it is off by two hours. For some reason, dayjs() seems to be...
Read more >Workflows | Temporal Documentation
This guide provides a comprehensive overview of Temporal Workflows.
Read more >Ebury API: Introduction
URIs do not descend more that one i.e. /quotes, /trades, etc.;; We use links where it makes sense to convey information to our...
Read more >Things I learnt the hard way in thirty years of software ...
You also need to be aware that timezones change; even now there are discussions about eliminating daylight saving time in various regions. If ......
Read more >CronScheduler: a reliable Java scheduler for external ...
When using Timer (but not ScheduledThreadPoolExecutor ), it's ... initial trigger time and taking into account daylight saving time changes.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@iamkun can you confirm is the library is still being maintained? Based on the commit history you’ve touched dayjs logic last time 7 months ago and there doesn’t seem to be another developer on board maintaining dayjs, resulting in a long backlog of pull requests and issues. If you’ve burned out or don’t have time for this library, let’s find a solution to getting the development back on track.
+1 to what @sulkaharo said
@iamkun if all of the PRs and issues and noise around this project is too much, we should find a way to keep the development of this project going, since there are a lot of capable and willing people and it’s a widely used (and awesome) library.