Open DeveloperWilco opened 6 years ago
Hi @DeveloperWilco, thanks for the detailed information. Do you think you can combine this in a running example, for example using https://jsfiddle.net
It appears all contributors are very busy / do not have this project as a priority. So making it as easy as possible for them to dive into this might help getting this resolved.
Done!
Also figured out the problem only occurs when the maxDays setting is set on 29 or higher. Also described in the fiddle.
Thanks in advance!
Thanks, so you think we should analyse what happens here https://github.com/longbill/jquery-date-range-picker/blob/79f6e9149b0a120b3de3bbb508dc2711a0ca33ed/src/jquery.daterangepicker.js#L1723
My observations:
+1
the days
var will always have at least a value of 2I currently do not have time to dive into this, but maybe someone else has. I always have a bit the feeling the "current time" is used when selecting the days, but have never studied this in detail.
I can't reproduce this error.
// after
var days = Math.ceil((opt.end - opt.start) / 86400000) + 1; `
// added
console.log(days, opt.maxDays);
It's always show as expected. ("30, 30" when chooses 30 days and maxDays is 30). Where I'm wrong ?
When setting the maxDays option you can't select the actual max value.
For example: maxDays: 30
Selecting exactly 30 days will give you the less-then error.
I checked the daterangepicker code and put a
console.log( days + ' > ' + opt.maxDays );
right where thecheckSelectionValid()
function created the day variable. The console shows 31 > 30 So I selected 30 but it adds a day.I removed the
+1
from the variable days (var days = Math.ceil((opt.end - opt.start) / 86400000) + 1;
) and its working.Now i'm wondering what the purpose would be of that +1 anyway. It's working for me now, but if you can manage to fix that for the future, that would be awesome.
also, this is my configuration for the daterangepicker.