longbill/jquery-date-range-picker

Number of days is wrong when it spans daylight savings time

Opened this issue · 0 comments

We discovered today that when trying to select a 5 day period spanning Nov. 3rd, it shows an error of "Date range should not be more than 5 days". The data at the time of calculation on line 1755 is:
opt.end = 1572809294319
opt.start = 1572460094319

The calculation on line 1755 then gives:
(opt.end - opt.start) /86400000 = 4.041666666666667

This is then rounded up, 1 is added to it, resulting in 6 days rather than 5. The problem is due to the fact that Nov 4 is the day after daylight savings time change, so we get 0.041666666666667 extra days (or one hour).

This error can be recreated on the demo page with the config that allows a selection between 3 and 7 days and the range spans a day when we advance clocks by one hour.
image