summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
authorniv-openerp <nicolas.vanhoren@openerp.com>2012-01-26 16:28:22 +0100
committerniv-openerp <nicolas.vanhoren@openerp.com>2012-01-26 16:28:22 +0100
commit7760df3d443a06bd304b7c2b3bebb03fab691948 (patch)
treeb01f09c37cf951b95a8e69e4275df1bdbd4de58e /addons/web/static/src
parent901ed2bf1a2fd74015129c245956607bacbdc263 (diff)
[fix] problem with date and time parsing
bzr revid: nicolas.vanhoren@openerp.com-20120126152822-z98udmqoj1qc9cx6
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/dates.js22
1 files changed, 17 insertions, 5 deletions
diff --git a/addons/web/static/src/js/dates.js b/addons/web/static/src/js/dates.js
index 907eaa39fcd..fe57f1b614c 100644
--- a/addons/web/static/src/js/dates.js
+++ b/addons/web/static/src/js/dates.js
@@ -5,8 +5,8 @@ openerp.web.dates = function(openerp) {
* Converts a string to a Date javascript object using OpenERP's
* datetime string format (exemple: '2011-12-01 15:12:35').
*
- * The timezone is assumed to be UTC (standard for OpenERP 6.1)
- * and will be converted to the browser's timezone.
+ * The time zone is assumed to be UTC (standard for OpenERP 6.1)
+ * and will be converted to the browser's time zone.
*
* @param {String} str A string representing a datetime.
* @returns {Date}
@@ -31,6 +31,10 @@ openerp.web.str_to_datetime = function(str) {
* Converts a string to a Date javascript object using OpenERP's
* date string format (exemple: '2011-12-01').
*
+ * As a date is not subject to time zones, we assume it should be
+ * represented as a Date javascript object at 00:00:00 in the
+ * time zone of the browser.
+ *
* @param {String} str A string representing a date.
* @returns {Date}
*/
@@ -43,7 +47,7 @@ openerp.web.str_to_date = function(str) {
if ( !res ) {
throw new Error("'" + str + "' is not a valid date");
}
- var obj = Date.parseExact(str + ' UTC', 'yyyy-MM-dd zzz');
+ var obj = Date.parseExact(str, 'yyyy-MM-dd');
if (! obj) {
throw new Error("'" + str + "' is not a valid date");
}
@@ -54,6 +58,10 @@ openerp.web.str_to_date = function(str) {
* Converts a string to a Date javascript object using OpenERP's
* time string format (exemple: '15:12:35').
*
+ * The OpenERP times are supposed to always be naive times. We assume it is
+ * represented using a javascript Date with a date 1 of January 1970 and a
+ * time corresponding to the meant time in the browser's time zone.
+ *
* @param {String} str A string representing a time.
* @returns {Date}
*/
@@ -66,7 +74,7 @@ openerp.web.str_to_time = function(str) {
if ( !res ) {
throw new Error("'" + str + "' is not a valid time");
}
- var obj = Date.parseExact(res[1] + ' UTC', 'HH:mm:ss zzz');
+ var obj = Date.parseExact("1970-01-01 " + res[1], 'yyyy-MM-dd HH:mm:ss');
if (! obj) {
throw new Error("'" + str + "' is not a valid time");
}
@@ -90,7 +98,7 @@ var zpad = function(str, size) {
* Converts a Date javascript object to a string using OpenERP's
* datetime string format (exemple: '2011-12-01 15:12:35').
*
- * The timezone of the Date object is assumed to be the one of the
+ * The time zone of the Date object is assumed to be the one of the
* browser and it will be converted to UTC (standard for OpenERP 6.1).
*
* @param {Date} obj
@@ -109,6 +117,10 @@ openerp.web.datetime_to_str = function(obj) {
* Converts a Date javascript object to a string using OpenERP's
* date string format (exemple: '2011-12-01').
*
+ * As a date is not subject to time zones, we assume it should be
+ * represented as a Date javascript object at 00:00:00 in the
+ * time zone of the browser.
+ *
* @param {Date} obj
* @returns {String} A string representing a date.
*/