From 8214e291a9eafeb39b61dd923dce00b3cce1dccc Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Thu, 31 Oct 2013 08:39:20 -0500 Subject: [PATCH] [FIX] web: correct date and datetime parsing. When creating a new Date object at a specific date, this date is treated as a UTC datetime then normalized to the browser timezone. This can lead to a change of Year/Month/Day depending of the chosen date. Using a date of a leap year date for date parsing and forcing UTC date for datetime parsing correct the month-switch errors in all timezones bzr revid: chs@openerp.com-20131031133920-yl5z4oz939smwvz8 --- addons/web/static/src/js/openerpframework.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/web/static/src/js/openerpframework.js b/addons/web/static/src/js/openerpframework.js index 9f3a6352511..1704856886b 100644 --- a/addons/web/static/src/js/openerpframework.js +++ b/addons/web/static/src/js/openerpframework.js @@ -1264,7 +1264,10 @@ openerp.str_to_datetime = function(str) { if ( !res ) { throw new Error("'" + str + "' is not a valid datetime"); } - var tmp = new Date(0); + var tmp = new Date(2000,0,1); + tmp.setUTCMonth(1970); + tmp.setUTCMonth(0); + tmp.setUTCDate(1); tmp.setUTCFullYear(parseFloat(res[1])); tmp.setUTCMonth(parseFloat(res[2]) - 1); tmp.setUTCDate(parseFloat(res[3])); @@ -1296,7 +1299,7 @@ openerp.str_to_date = function(str) { if ( !res ) { throw new Error("'" + str + "' is not a valid date"); } - var tmp = new Date(0); + var tmp = new Date(2000,0,1); tmp.setFullYear(parseFloat(res[1])); tmp.setMonth(parseFloat(res[2]) - 1); tmp.setDate(parseFloat(res[3]));