question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Adding days across daylight savings does not work as expected

See original GitHub issue

Issuehunt badges

Describe 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 iamkun has been rewarded.

Backers (Total: $100.00)

Submitted pull Requests


Tips


IssueHunt has been backed by the following sponsors. Become a sponsor

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
iamkuncommented, May 7, 2019

🎉 This issue has been resolved in version 1.8.14 🎉

The release is available on:

Your semantic-release bot 📦🚀

0reactions
issuehunt-app[bot]commented, Aug 12, 2019

@iamkun has rewarded $90.00 to @iamkun. See it on IssueHunt

  • 💰 Total deposit: $100.00
  • 🎉 Repository reward(0%): $0.00
  • 🔧 Service fee(10%): $10.00
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found