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.

Fix days difference in checkSelectionValid()

See original GitHub issue

In function checkSelectionValid() (jquery.daterangepicker.js:1722) the days difference is counted as follows:

var days = Math.ceil((opt.end - opt.start) / 86400000) + 1;

which does not factor daylight saving time. Instead, it should be:

var days = countDays(opt.end, opt.start);

or using moment.js:

var days = moment(opt.end).diff(moment(opt.start), 'days');

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
niutechcommented, Sep 25, 2017

Yes, I refer to this line. I think it is a good idea to use moment.js for date diffing, since it it well tested.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Incorrect day range counting · Issue #310 · longbill/jquery-date ...
The number of days are being counted incorrectly in some cases. (See Images) ... Fix days difference in checkSelectionValid() #378.
Read more >
Calculate the difference between two dates - Microsoft Support
How to calculate the number of days, months, or years between two dates using the DATEIF function in Excel.
Read more >
Flutter: Find the number of days between two dates
You can use the difference method provide by DateTime class //the birthday's date final birthday = DateTime(1967, 10, 12); final date2 ...
Read more >
Calculate the dates difference in days in Scoped Application
Solved: Hi All, we have a requirement to calculate the difference between two dates in days in scoped application.
Read more >
Calculate the number of days between today and another date
So, the formula is: =TODAY() – B2. This, unfortunately, only gives you the number of days between today and the project start date....
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