diff options
| author | Christophe Simonis <chs@openerp.com> | 2013-10-31 08:39:20 -0500 |
|---|---|---|
| committer | Christophe Simonis <chs@openerp.com> | 2013-10-31 08:39:20 -0500 |
| commit | 8214e291a9eafeb39b61dd923dce00b3cce1dccc (patch) | |
| tree | 0d8d93b0a24df5edd4faf0f91ec1147dba7b2db0 /addons/web/static/src/js/openerpframework.js | |
| parent | 13ac26bba5e8cb402c83b4ada581679f592f003d (diff) | |
[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
Diffstat (limited to 'addons/web/static/src/js/openerpframework.js')
| -rw-r--r-- | addons/web/static/src/js/openerpframework.js | 7 |
1 files 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])); |
