Add an option to configure how the number of days is calculated
See original GitHub issueSuppose we have the range 15.06.2016 23:59 ~ 16.06.2016 00:00
. The length of time between the start and the end is only 1 second, however this library displays “2 days” because it spans across 2 separate calendar dates. I suggest adding a way to configure this.
Configuration option: daysMode(‘span’ / ‘nights’ / ‘period’)
if (daysMode === 'span') {
// Use the current behavior (default)
}
if (daysMode === 'nights') {
// Should be the same as the current behavior minus 1. This is the number of
// times the boundary between 23:59 and 00:00 is crossed
}
if (daysMode === 'period') {
// The actual number of complete 24 hour periods between one datetime and
// another.
// If we have Monday at 23:59 until Tuesday at 23:58 this should be 0, even
// though it crosses from one day to another.
}
I haven’t looked at the code, but I can’t see this being overly difficult to achieve. If you are interested let me know and I’ll code it and submit a pull request.
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
How to Calculate the Number of Days Between Two Dates in ...
You need to specify the 'Start Date' and the 'End Date' in the Days function, and it will give you the total number...
Read more >DAYS function - Microsoft Support
This article describes the formula syntax and usage of the DAYS function in Microsoft Excel. ... Description. Returns the number of days between...
Read more >Calculate number of days between two dates in Excel - Ablebits
Click the Insert formula button and have the formula inserted in the selected cell. Done! Build a formula to calculate days between two...
Read more >How to calculate the days between two dates? - Formfacade
1. You can subtract the start date from end date to calculate the number of days between the dates. By default, the answer...
Read more >Add calculated fields to a form - Adobe Support
Formatting Calculated Fields as Dates ; hh. The hour of the day with leading zero if required. "01" to "12" ; H ·...
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
@holtkamp For example in the “Typical usage, hotel booking” example on http://longbill.github.io/jquery-date-range-picker/, you typically select the check in and check out dates, so if I check in on the 3rd and check out the 4th I would expect it to say
1
instead of2
. I can edit the locale to say “nights” instead of “days”. Having it display “2 days” to me is confusing. Anyway, this is how I’m currently doing it:As for the
"period"
example, I can’t really think of a use case, but if we’re going to allow it to be configured, we might as well as there could be somebody who wants to do it like that.@barryvdh Could be as easy as setting a custom language, like https://github.com/longbill/jquery-date-range-picker/blob/31d1eafe296816b7639fd2e91e8ca23c8775e187/demo.js.