jtsage / jtsage-datebox

A multi-mode date and time picker for Bootstrap (3&4), jQueryMobile, Foundation, Bulma, FomanticUI, and UIKit (or others)
http://datebox.jtsage.dev/
Other
474 stars 166 forks source link

Bug in applyMinMax shows when linking date boxes #426

Closed carloguli closed 5 years ago

carloguli commented 6 years ago

When linking date boxes in the way suggested @ http://dev.jtsage.com/DateBox/doc/6-2-link/ the call to applyMinMax fails to apply the correct restriction when obby.date is not a daylight saving date and today is or vice versa. For instance if I initially select January 1st (GMT) and today is May 8th (BST) using the suggested code, i.e. adding 1 day, I should be able to select Jan 2nd on the linked box, but the first available date is instead Jan 3rd. I think this is because applyMinMax sets options.minDays to parseInt(daysRaw) instead of Math.round(daysRaw). I suspect options.maxDays is affected in a similar way

jtsage commented 6 years ago

Yeah. This does not surprise me. DST is a pain. It's due to when the DST switch takes place - and I suspect this problem doesn't crop up in the US, because we use the 2a / 3a barrier, and it looks like BST uses a 1a barrier for one of the switches. Maybe. I think.

At any rate, Math.round shouldn't break anything, and I'll do some more digging about how I can coerce my browser into believing odd things about today's date to try and track down a better / more robust fix.

jtsage commented 6 years ago

Re: 183feb2

jtsage commented 5 years ago

Fwiw, this is going to be fixed in v5, as I've changed how min/max works - it not corresponds to "minDate" and "maxDate", which makes a whole lot more sense, and coincidentally, is what is actually in the HTML5 spec.