Commit 6f737abc authored by Romain Courteaud's avatar Romain Courteaud

erp5_web_renderjs_ui: fix getRelativeTimeString for year

New year does not mean the period is 365 days.
parent 18fc0a93
......@@ -37,16 +37,15 @@
hour = minute * 60,
day = hour * 24,
week = day * 7,
year = day * 365,
time_format = new Intl.RelativeTimeFormat(language);
diff = date.getFullYear() - current_date.getFullYear();
if (diff !== 0) {
return time_format.format(diff, 'year');
}
diff = date - current_date;
abs = Math.abs(diff);
// "year", "quarter", "month", "week", "day", "hour", "minute", "second"
if (abs > year) {
return time_format.format(Math.floor(diff / year), 'year');
}
if (abs > (week * 2)) {
return time_format.format(Math.floor(diff / week), 'week');
}
......
......@@ -238,7 +238,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1017.21412.29767.13277</string> </value>
<value> <string>1017.42673.18426.35652</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -258,7 +258,7 @@
</tuple>
<state>
<tuple>
<float>1718640624.19</float>
<float>1735815864.25</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