});
callGetLocaltime = rpc.declare({
- object: 'luci',
- method: 'getLocaltime',
- expect: { result: 0 }
+ object: 'system',
+ method: 'info',
+ expect: { localtime: 0 }
});
callSetLocaltime = 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([], [
'id': 'localtime',
'type': 'text',
'readonly': true,
- 'value': new Date(cfgvalue * 1000).toLocaleString()
+ 'value': formatTime(cfgvalue)
}),
E('br'),
E('span', { 'class': 'control-group' }, [
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);
});
});
"description": "Grant access to system configuration",
"read": {
"ubus": {
- "luci": [ "getInitList", "getLEDs", "getLocaltime", "getTimezones", "getUSBDevices" ]
+ "luci": [ "getInitList", "getLEDs", "getTimezones", "getUSBDevices" ],
+ "system": [ "info" ]
},
"uci": [ "luci", "system" ]
},