Adding days across daylight savings does not work as expected
See original GitHub issueDescribe the bug
I’m seeing a weird issue with using add()
along with utc()
across a daylight savings boundary where it doesn’t add a full day.
Expected behavior Given the following code:
var dayjs = require('dayjs');
var utc = require('dayjs/plugin/utc');
dayjs.extend(utc);
let testDate = dayjs('2019-03-10')
.utc()
.startOf('day');
console.log('TESTDATE: ', testDate.format());
let testDate2 = testDate.add(1, 'day');
console.log('TESTDATE2:', testDate2.format());
I expect it to output the following:
TESTDATE: 2019-03-10T00:00:00Z
TESTDATE2: 2019-03-11T00:00:00Z
Instead I see this:
TESTDATE: 2019-03-10T00:00:00Z
TESTDATE2: 2019-03-10T23:00:00Z
Replication here: https://runkit.com/accelerate/runkit-dayjs-daylight-savings
NOTE: I tested the same code with MomentJS and do get the expected behavior.
Information
- Day.js: 1.8.13
- OS: MacOS 10.14.4
- Chrome: 74.0.3729.108
IssueHunt Summary
iamkun has been rewarded.
Backers (Total: $100.00)
- issuehunt ($100.00)
Submitted pull Requests
Tips
- Checkout the Issuehunt explorer to discover more funded issues.
- Need some help from other developers? Add your repositories on IssueHunt to raise funds.
IssueHunt has been backed by the following sponsors. Become a sponsor
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Adding a week to Date in JavaScript: rounding error or ...
Adding a week to Date in JavaScript: rounding error or daylight savings? · See stackoverflow.com/questions/4109641/… · @Crescent Fresh - daylight ...
Read more >How Does Daylight Saving Time Work? - Time and Date
When Daylight Saving Time (DST) begins, we lose an hour. When it ends, we gain an hour. So how exactly does the DST...
Read more >Daylight Saving Time 2023: When Does the Time Change?
The first Sunday in November is when Daylight Saving Time ends in most areas of the U.S., so in 2023 we “fall back”...
Read more >Daylight Saving Time 2022: When Does the Time Change?
Daylight Saving Time (DST) is the practice of moving the clocks forward one hour from Standard Time during the summer months and changing...
Read more >The U.S. Tried Permanent Daylight Saving Time Before
The Senate has passed a bill to make Daylight Saving Time ... So I would expect some of the same problems might happen...
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 FreeTop 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
Top GitHub Comments
🎉 This issue has been resolved in version 1.8.14 🎉
The release is available on:
Your semantic-release bot 📦🚀
@iamkun has rewarded $90.00 to @iamkun. See it on IssueHunt