From c32724eae06c987e74a0600f1669696e499edc33 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Wed, 12 Apr 2017 11:53:42 +0200 Subject: [FIX] web: calendar timezone with user configuration The client must receive the tzOffset to apply this on all hours. To use the date picker we must change the date to apply the change in the user's tzOffset, without this change the result is wrong. For datetime widget we must change like it to avoid max stack error. The server send the tzOffset, if it's undefined, by default the client use the browser time offset. Every test are change to use tzOffset. A test is added in calendar to use the click by position for the fullcalendar lib. This test create and drag and drop an event to check timezone error and error when we use default value in the context. Use formating date like 2026-04-04T08:00:00Z instead of 2026-04-04 08:00:00 is important for phantomjs, because it's crash without information if the formating is not the standard format. For the parsing, when the client receive a server date the date is utc formating but when it's parsed from the client is in the user's timezone --- addons/web/static/src/js/views/basic/basic_model.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'addons/web/static/src/js/views/basic/basic_model.js') diff --git a/addons/web/static/src/js/views/basic/basic_model.js b/addons/web/static/src/js/views/basic/basic_model.js index 4de6ca25187..71d6d6fa1ad 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -1023,10 +1023,10 @@ var BasicModel = AbstractModel.extend({ }); } else if (field.type === 'date') { // process data: convert into a moment instance - record._changes[name] = fieldUtils.parse.date(val); + record._changes[name] = fieldUtils.parse.date(val, field, {isUTC: true}); } else if (field.type === 'datetime') { // process datetime: convert into a moment instance - record._changes[name] = fieldUtils.parse.datetime(val); + record._changes[name] = fieldUtils.parse.datetime(val, field, {isUTC: true}); } else { record._changes[name] = val; } @@ -2195,10 +2195,10 @@ var BasicModel = AbstractModel.extend({ }); } else if (field.type === 'date') { // process date: convert into a moment instance - record._changes[name] = fieldUtils.parse.date(result[name]); + record._changes[name] = fieldUtils.parse.date(result[name], field, {isUTC: true}); } else if (field.type === 'datetime') { // process datetime: convert into a moment instance - record._changes[name] = fieldUtils.parse.datetime(result[name]); + record._changes[name] = fieldUtils.parse.datetime(result[name], field, {isUTC: true}); } else { record._changes[name] = result[name]; } @@ -2268,10 +2268,10 @@ var BasicModel = AbstractModel.extend({ } } else if (field.type === 'date') { // process data: convert into a moment instance - record[fieldName] = fieldUtils.parse.date(val); + record[fieldName] = fieldUtils.parse.date(val, field, {isUTC: true}); } else if (field.type === 'datetime') { // process datetime: convert into a moment instance - record[fieldName] = fieldUtils.parse.datetime(val); + record[fieldName] = fieldUtils.parse.datetime(val, field, {isUTC: true}); } }); }, -- cgit v1.2.3