tempusdominus / bootstrap-4

Tempus Dominus Bootstrap 4 Datetime Picker
https://getdatepicker.com/5-4/
MIT License
611 stars 239 forks source link

No safari issue with DST change at midnight #357

Closed nle-odoo closed 4 years ago

nle-odoo commented 4 years ago

To reproduce the issue, you need to have safari (on current iOS/macOS) on a localization with DST at midnight that goes from 00:00 to 23:00 when an hour is removed (Chile, Cuba, Iran, Jordan, Lebanon, Palestine, Paraguay and Syria).

In these localization, depending on some heuristic the month view could have duplicated days or not work at all for a given month.

eg. with Lebanon localization, showing "April 2020" month view will throw an error "TypeError: undefined is not an object (evaluating 'row.append')" because with the current code:

this._viewDate.clone().startOf('M').startOf('w').startOf('d');
// .startOf('M') => Apr 01 00:00:00
// .startOf('w') => Mar 28 23:00:00 #(in other browsers Mar 29 00:00:00)
// .startOf('d') => Mar 28 00:00:00 #(in other browsers Mar 29 00:00:00)

=> we do not start with a first day of the week so doing:

https://github.com/tempusdominus/bootstrap-4/blob/bb8cd3cc4924d560f6e52155fa4229156f51337b/src/js/tempusdominus-bootstrap-4.js#L522

causes an error (because row is undefined since we are not on currentDate.weekday() === 0) that makes the month of April unusable.

2020-10-20-180352_1508x609_scrot

with the same setup, showing "March 2020", the month view works but there is two "28" days:

2020-10-20-180430_388x454_scrot

Other reports of the issue itself:

Reports of the issue in bootstrap-datetimepicker: