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/core | |
| 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/core')
| -rw-r--r-- | addons/web/static/src/js/core/time.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/addons/web/static/src/js/core/time.js b/addons/web/static/src/js/core/time.js index af13aa5a3b1..47a4c81465d 100644 --- a/addons/web/static/src/js/core/time.js +++ b/addons/web/static/src/js/core/time.js @@ -279,6 +279,27 @@ var normalize_format_table = { }; var inverse_normalize_format_table = _.invert(normalize_format_table); +/** + * Get date format of the user's language + */ +function getLangDateFormat() { + return this.strftime_to_moment_format(_t.database.parameters.date_format); +} + +/** + * Get time format of the user's language + */ +function getLangTimeFormat() { + return this.strftime_to_moment_format(_t.database.parameters.time_format); +} + +/** + * Get date time format of the user's language + */ +function getLangDatetimeFormat() { + return this.strftime_to_moment_format(_t.database.parameters.date_format + " " + _t.database.parameters.time_format); +} + return { @@ -293,6 +314,9 @@ return { auto_date_to_str: auto_date_to_str, strftime_to_moment_format: strftime_to_moment_format, moment_to_strftime_format: moment_to_strftime_format, + getLangDateFormat: getLangDateFormat, + getLangTimeFormat: getLangTimeFormat, + getLangDatetimeFormat: getLangDatetimeFormat, }; }); |
