From 9a0a02060fa048ce92ee0dab1bfbdcff63573237 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Tue, 21 Jan 2014 11:27:25 -0200 Subject: [PATCH 1/3] [FIX] format_value: when formating to date, make sure not converting from a datetime string as would make timezones apply and lead to a possible day change bzr revid: mat@openerp.com-20140121132725-k9f8hna3lg7nq7g8 --- addons/web/static/src/js/formats.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/web/static/src/js/formats.js b/addons/web/static/src/js/formats.js index dd0a9040b6b..640d919f4c1 100644 --- a/addons/web/static/src/js/formats.js +++ b/addons/web/static/src/js/formats.js @@ -191,6 +191,9 @@ instance.web.format_value = function (value, descriptor, value_if_empty) { + ' ' + normalize_format(l10n.time_format)); case 'date': if (typeof(value) == "string") + if (value.length > 10) + // in case value is a datetime, strip to avoid time manipulation + value = value.substring(0,10); value = instance.web.auto_str_to_date(value); return value.toString(normalize_format(l10n.date_format)); case 'time': From 36048a8442c89cf4f5811850c3e2c91d6eb862c7 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Tue, 21 Jan 2014 11:50:58 -0200 Subject: [PATCH 2/3] [IMP] always apply substring and call directly str_to_date bzr revid: mat@openerp.com-20140121135058-cr3ivak97rqm6npo --- addons/web/static/src/js/formats.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/addons/web/static/src/js/formats.js b/addons/web/static/src/js/formats.js index 640d919f4c1..58a785b6083 100644 --- a/addons/web/static/src/js/formats.js +++ b/addons/web/static/src/js/formats.js @@ -191,10 +191,9 @@ instance.web.format_value = function (value, descriptor, value_if_empty) { + ' ' + normalize_format(l10n.time_format)); case 'date': if (typeof(value) == "string") - if (value.length > 10) - // in case value is a datetime, strip to avoid time manipulation - value = value.substring(0,10); - value = instance.web.auto_str_to_date(value); + // in case value is a datetime, strip to avoid time manipulation + value = value.substring(0,10); + value = instance.web.str_to_date(value); return value.toString(normalize_format(l10n.date_format)); case 'time': if (typeof(value) == "string") From 3c3ab07e2fefdff743faf8ecffaf58e90c813c95 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Tue, 21 Jan 2014 15:26:25 +0100 Subject: [PATCH 3/3] [FIX] format_value: correctly compose if block, we are doing python here... bzr revid: mat@openerp.com-20140121142625-fy8zkafcvb9wwz88 --- addons/web/static/src/js/formats.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/addons/web/static/src/js/formats.js b/addons/web/static/src/js/formats.js index 58a785b6083..3280b9f4f75 100644 --- a/addons/web/static/src/js/formats.js +++ b/addons/web/static/src/js/formats.js @@ -191,9 +191,7 @@ instance.web.format_value = function (value, descriptor, value_if_empty) { + ' ' + normalize_format(l10n.time_format)); case 'date': if (typeof(value) == "string") - // in case value is a datetime, strip to avoid time manipulation - value = value.substring(0,10); - value = instance.web.str_to_date(value); + value = instance.web.str_to_date(value.substring(0,10)); return value.toString(normalize_format(l10n.date_format)); case 'time': if (typeof(value) == "string")