From 8d5bc95d3389c1c005fe55ec70ef146bc6198a56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 3 Nov 2013 20:48:26 +0100 Subject: [PATCH] Fix Date creation for timezone with change at midnight Fixing https://bugs.launchpad.net/openerp-web/+bug/1068105 review1281002 --- src/sao.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/sao.js b/src/sao.js index a9457c83e7..2ad6248a58 100644 --- a/src/sao.js +++ b/src/sao.js @@ -76,7 +76,14 @@ var Sao = {}; date = new Date(year, month, day); } date.isDate = true; + var previous_day = date.getDate(); + var previous_hour = date.getHours(); date.setHours(0); + // Setting hours could change the day due to local timezone + if (previous_day != date.getDate()) { + date.setDate(previous_day); + date.setHours(previous_hour); + } date.setMinutes(0); date.setSeconds(0); date.setMilliseconds(0);