Twipped / Kalendae

A javascript date picker that just works.
MIT License
1.99k stars 285 forks source link

Patch yearDay() moment ext to use a UTC date. #229

Closed willdud closed 4 years ago

willdud commented 4 years ago

To address https://github.com/Twipped/Kalendae/issues/125

In the UK, in late March the clocks go forward 1 hour GMT to BST for what is known as daylight savings. The function yearDay() uses the constant 86400000 for the number of ms in a day, however, March 29th 2020 will have only 82800000ms. This difference causes March 29th to have a yearDay() of 18350 and the 30th to have a yearDay() of 18350.95833333. This being the case, the function isSelected in main.js will indicate both dates as the 'range start' if the 30th is clicked.

Replication: https://jsfiddle.net/sn4a3r6o/2/ Fix: https://jsfiddle.net/sn4a3r6o/3/

Twipped commented 4 years ago

Doesn't appear to cause any issues in other timezones, so I'm merging. Thank you so much for finding this, it's been a problem for years.