From 4c69f52cef560f4b69cb0673145621b1f33ca00a Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Wed, 6 Apr 2022 11:33:02 +0000 Subject: [PATCH] [FIX] web: get timezone offset from local time Currently, the timezone offset is taken from the date with reverse timezone offset applied. So if there is a change of timezone offset between the wrong date and the local date, we apply the wrong timezone. Example: - be in "Australia/Sydney" timezone - select date in datetime field 2021-04-03 16:12:34 (at UTC+11) - save => time becomes 17:12:34 - change time to 17:12:35 and save => time becomes 18:12:35 - change time to 18:12:36 and save => time becomes 19:12:36 - ... - this issue is happening until 01:59:59 of the following day Fix: When we are selecting "2021-04-03 16:01:23" we will get the timezone offset from the date "Sun Apr 04 2021 02:01:23 GMT+1000" (at UTC+10) but the DST change was at "2021-04-04 03:00:00 (UTC+11)" with time becoming "2021-04-04 02:00:00 (UTC+10)". With this changeset, we are getting the timezone from the local time, not from local time with reverse timezone offset applied. opw-2735369 closes odoo/odoo#89619 X-original-commit: 84eb850af614887f7040bffa71cbb7fd239ba857 Signed-off-by: Nicolas Lempereur (nle) --- addons/web/static/src/legacy/js/core/session.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/web/static/src/legacy/js/core/session.js b/addons/web/static/src/legacy/js/core/session.js index 0ba3b5160a3..76e062a6798 100644 --- a/addons/web/static/src/legacy/js/core/session.js +++ b/addons/web/static/src/legacy/js/core/session.js @@ -305,7 +305,7 @@ var Session = core.Class.extend(mixins.EventDispatcherMixin, { * @returns {integer} */ getTZOffset: function (date) { - return -new Date(date).getTimezoneOffset(); + return -new Date(new Date(date).toISOString().replace('Z', '')).getTimezoneOffset(); }, //-------------------------------------------------------------------------- // Public