diff options
| author | Alexandre Kühn <aku@odoo.com> | 2017-12-04 11:01:36 +0100 |
|---|---|---|
| committer | Alexandre Kühn <aku@odoo.com> | 2017-12-05 09:13:31 +0100 |
| commit | 6cc5a9963b3cce5d6ddf2cd038def5fe21f17af7 (patch) | |
| tree | 31ec78e726c4965485bfa875c7374678f8f548dc /addons/web/static/src/js/fields | |
| parent | 59729695680b33a1eec8e170777e07ee12cb3925 (diff) | |
[FIX] web,*: time format from user's language
Before this fix, the chatter always showed dates of messages in military time format.
This was not the expected behavior, as the user could have had customize
the date and time format in the settings of the current language.
Steps to reproduce the issue:
1. Set Odoo in English
2. Settings > Translations > Languages > English
2.1. Set Date Format to %m/%d/%Y
2.2. Set Time Format to %I:%M:%S %p
3. CRM > (Select any opportunity with at least one message) > Mouse hover on elapsed time (e.g. "an hour ago")
Expected:
- It shows the customized time format (e.g. 11/07/2017 5:33:36 PM)
Results:
- It shows the military time format (e.g. Tue Nov 07 2017 17:33:36 GMT+0100)
opw-781647
Diffstat (limited to 'addons/web/static/src/js/fields')
| -rw-r--r-- | addons/web/static/src/js/fields/field_utils.js | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/addons/web/static/src/js/fields/field_utils.js b/addons/web/static/src/js/fields/field_utils.js index 7ba4122cccb..bca74acc088 100644 --- a/addons/web/static/src/js/fields/field_utils.js +++ b/addons/web/static/src/js/fields/field_utils.js @@ -97,8 +97,7 @@ function formatDate(value, field, options) { 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); + var date_format = time.getLangDateFormat(); return value.format(date_format); } @@ -122,11 +121,7 @@ function formatDateTime(value, field, options) { 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); - var time_format = time.strftime_to_moment_format(l10n.time_format); - var datetime_format = date_format + ' ' + time_format; - return value.format(datetime_format); + return value.format(time.getLangDatetimeFormat()); } /** @@ -349,7 +344,7 @@ function parseDate(value, field, options) { if (!value) { return false; } - var datePattern = time.strftime_to_moment_format(core._t.database.parameters.date_format); + var datePattern = time.getLangDateFormat(); var datePatternWoZero = datePattern.replace('MM','M').replace('DD','D'); var date; if (options && options.isUTC) { @@ -388,8 +383,8 @@ function parseDateTime(value, field, options) { if (!value) { return false; } - var datePattern = time.strftime_to_moment_format(core._t.database.parameters.date_format), - timePattern = time.strftime_to_moment_format(core._t.database.parameters.time_format); + var datePattern = time.getLangDateFormat(), + timePattern = time.getLangTimeFormat(); var datePatternWoZero = datePattern.replace('MM','M').replace('DD','D'), timePatternWoZero = timePattern.replace('HH','H').replace('mm','m').replace('ss','s'); var pattern1 = datePattern + ' ' + timePattern; |
