Commit 7bd0bac2 authored by Nicolas Wavrant's avatar Nicolas Wavrant

fixup! erp5_web_renderjs_ui: datetime field formats date in the interface language

parent d1f19c42
......@@ -238,16 +238,33 @@
gadget_list = result_list[1],
text_content = "",
state_date,
locale_formatted_state_date,
offset_time_zone;
if (gadget.state.value) {
state_date = new Date(gadget.state.value);
/* Ideally we would like to use {timeStyle: "short"} as option
* to hide seconds. Unfortunately it doesn't work in older
* versions of firefox. Luckily, by using
* {hour: "numeric", minute: "numeric"}
* it hides seconds, and still respects the locale.
* >> date = new Date(2019, 1, 1, 1, 1)
* >> date.toLocaleTimeString(
* 'en', {hour: "numeric", minute: "numeric"}
* )
* "1:01 AM"
* >> date.toLocaleTimeString(
* 'fr', {hour: "numeric", minute: "numeric"}
* )
* "01:01"
*/
locale_formatted_state_date = state_date.toLocaleTimeString(
language,
{hour: "numeric", minute: "numeric"}
);
if (gadget.state.timezone_style) {
text_content = state_date.toLocaleDateString(language);
if (!gadget.state.date_only) {
text_content += " " + state_date.toLocaleTimeString(
language,
{timeStyle: "short"}
);
text_content += " " + locale_formatted_state_date;
}
} else {
//get timezone difference between server and local browser
......@@ -256,10 +273,7 @@
state_date.setUTCHours(state_date.getUTCHours() + offset_time_zone);
text_content = state_date.toLocaleDateString(language);
if (!gadget.state.date_only) {
text_content += " " + state_date.toLocaleTimeString(
language,
{timeStyle: "short"}
);
text_content += " " + locale_formatted_state_date;
}
}
}
......
......@@ -228,7 +228,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>980.48184.20620.63641</string> </value>
<value> <string>980.55051.50282.19404</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -246,7 +246,7 @@
</tuple>
<state>
<tuple>
<float>1577760705.94</float>
<float>1577775957.85</float>
<string>UTC</string>
</tuple>
</state>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment