summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-mod-system/htdocs/luci-static/resources/view/system/system.js
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2021-10-19 23:08:36 +0200
committerJo-Philipp Wich <jo@mein.io>2021-10-19 23:09:46 +0200
commit07569c5af23d74bad8b78905b25d7e85bd2d3141 (patch)
treefc683cbe898f0ec76c3e1592d7b17b2903e0e0e2 /modules/luci-mod-system/htdocs/luci-static/resources/view/system/system.js
parentcd3d614c560bdea99240ab68261c15b774c7a5fe (diff)
luci-mod-system: fix time display logic
Use the system/info ubus call to obtain a TZ adjusted epoch value and format the date time string manually instead of relying on the browsers local representation. Fixes: #5454 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-mod-system/htdocs/luci-static/resources/view/system/system.js')
-rw-r--r--modules/luci-mod-system/htdocs/luci-static/resources/view/system/system.js23
1 files changed, 18 insertions, 5 deletions
diff --git a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/system.js b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/system.js
index 1c2aa46c52..d207a5c994 100644
--- a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/system.js
+++ b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/system.js
@@ -29,9 +29,9 @@ callInitAction = rpc.declare({
});
callGetLocaltime = rpc.declare({
- object: 'luci',
- method: 'getLocaltime',
- expect: { result: 0 }
+ object: 'system',
+ method: 'info',
+ expect: { localtime: 0 }
});
callSetLocaltime = rpc.declare({
@@ -47,6 +47,19 @@ callTimezone = rpc.declare({
expect: { '': {} }
});
+function formatTime(epoch) {
+ var date = new Date(epoch * 1000);
+
+ return '%04d-%02d-%02d %02d:%02d:%02d'.format(
+ date.getUTCFullYear(),
+ date.getUTCMonth() + 1,
+ date.getUTCDate(),
+ date.getUTCHours(),
+ date.getUTCMinutes(),
+ date.getUTCSeconds()
+ );
+}
+
CBILocalTime = form.DummyValue.extend({
renderWidget: function(section_id, option_id, cfgvalue) {
return E([], [
@@ -54,7 +67,7 @@ CBILocalTime = form.DummyValue.extend({
'id': 'localtime',
'type': 'text',
'readonly': true,
- 'value': new Date(cfgvalue * 1000).toLocaleString()
+ 'value': formatTime(cfgvalue)
}),
E('br'),
E('span', { 'class': 'control-group' }, [
@@ -285,7 +298,7 @@ return view.extend({
return m.render().then(function(mapEl) {
poll.add(function() {
return callGetLocaltime().then(function(t) {
- mapEl.querySelector('#localtime').value = new Date(t * 1000).toLocaleString();
+ mapEl.querySelector('#localtime').value = formatTime(t);
});
});