[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
This commit is contained in:
Christophe Simonis
2013-10-31 08:39:20 -05:00
parent 13ac26bba5
commit 8214e291a9
+5 -2
View File
@@ -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]));