diff options
| author | Christophe Simonis <chs@odoo.com> | 2017-08-23 16:44:58 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2017-08-23 16:44:58 +0200 |
| commit | 30bd5ac0e904906d90f4767bbbf178bf940c0c66 (patch) | |
| tree | ea271d0f46ed35c8af460aa71890c1dce474d2a4 /addons/web/static/src/js/fields/field_utils.js | |
| parent | 7f2bd086087f73878f62933ecd2e7c2bed32142e (diff) | |
| parent | aec6248bb379c1ece02f5d4f718566c770fc2c6f (diff) | |
[MERGE] forward port branch saas-16 up to aec6248bb37
Diffstat (limited to 'addons/web/static/src/js/fields/field_utils.js')
| -rw-r--r-- | addons/web/static/src/js/fields/field_utils.js | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/addons/web/static/src/js/fields/field_utils.js b/addons/web/static/src/js/fields/field_utils.js index 0a44a52e315..db5cd34d8b9 100644 --- a/addons/web/static/src/js/fields/field_utils.js +++ b/addons/web/static/src/js/fields/field_utils.js @@ -95,8 +95,10 @@ function formatDate(value, field, options) { if (value === false) { return ""; } - if (!options || !('timezone' in options) || options.timezone) { - value = value.clone().add(session.tzOffset < 0 ? -1 : 0, 'days'); + if (field && field.type === 'datetime') { + if (!options || !('timezone' in options) || options.timezone) { + value = value.clone().add(session.getTZOffset(value), 'minutes'); + } } var l10n = core._t.database.parameters; var date_format = time.strftime_to_moment_format(l10n.date_format); @@ -121,7 +123,7 @@ function formatDateTime(value, field, options) { return ""; } if (!options || !('timezone' in options) || options.timezone) { - value = value.clone().add(session.tzOffset, 'minutes'); + value = value.clone().add(session.getTZOffset(value), 'minutes'); } var l10n = core._t.database.parameters; var date_format = time.strftime_to_moment_format(l10n.date_format); @@ -357,11 +359,8 @@ function parseDate(value, field, options) { date = moment.utc(value); } else { date = moment.utc(value, [datePattern, datePatternWoZero, moment.ISO_8601], true); - if (options && options.timezone) { - date.add(session.tzOffset > 0 ? -1 : 0, 'days'); - } } - if (date.isValid() && date.year() >= 1900) { + if (date.isValid()) { if (date.year() === 0) { date.year(moment.utc().year()); } @@ -405,7 +404,7 @@ function parseDateTime(value, field, options) { } else { datetime = moment.utc(value, [pattern1, pattern2, moment.ISO_8601], true); if (options && options.timezone) { - datetime.add(-session.tzOffset, 'minutes'); + datetime.add(-session.getTZOffset(datetime), 'minutes'); } } if (datetime.isValid()) { |
