Skip to content
Snippets Groups Projects
Commit b20bb5b6 authored by Nicolas Lempereur's avatar Nicolas Lempereur
Browse files

[FIX] web: no safari issue with DST at midnight

On safari with apple device in belgium timezone, this code:

```
x = new Date(2020, 2, 28, 2)
x.setDate(29)
```

returns:

> Sat Mar 28 2020 02:00:00 GMT+0100 (CET)
> Sun Mar 29 2020 01:00:00 GMT+0100 (CET)

This is not consistent with any other combination of OS and browser
tested, where this code would return eg. for chrome on macOS:

> Sat Mar 28 2020 02:00:00 GMT+0100 (Central European Standard Time)
> Sun Mar 29 2020 03:00:00 GMT+0200 (Central European Summer Time)

In most instance, this is not an issue, but for country with midnight as
Daylight Saving Time (DST) change, this is an issue, because the Tempus
Dominus calendar widget will have a duplicated day which might eg. make
a month totally not usable.

This issue can eg. be reproduced in Lebanon timezone at this address:

https://tempusdominus.github.io/bootstrap-4/Usage/

Going to the month of April 2020, an error happen  because to get the
first day of the week of 1st April, we do:

```
this._viewDate.clone().startOf('M').startOf('w').startOf('d');
// .startOf('M') => Apr 01 00:00:00
// .startOf('w') => Mar 28 23:00:00 (safari bug)
// .startOf('d') => Mar 28 00:00:00
```

which gives us the wrong day (28 instead of 29) which causes an error.

Other report of the issue:

- https://www.donedone.com/timezone-specific-browser-specific-datetime-bug-2014/
- https://github.com/date-fns/date-fns : issue 571
- https://forum.mobiscroll.com/t/issue-with-invalid-dates-range-script/108



opw-2271482
closes #59786

closes odoo/odoo#59901

X-original-commit: 112267d6
Signed-off-by: default avatarNicolas Lempereur (nle) <nle@odoo.com>
parent ee966998
Branches
Tags
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment