Now server started shows browser time, not server time.

This commit is contained in:
LukasDoesDev 2020-12-16 01:17:41 +02:00
parent 4c9f947aa1
commit 359a2e1c42
2 changed files with 19 additions and 2 deletions

View File

@ -125,7 +125,9 @@ class PanelHandler(BaseHandler):
self.render(
template,
data=page_data
data=page_data,
time=time,
utc_offset=(time.timezone * -1 / 60 / 60),
)
@tornado.web.authenticated

View File

@ -78,12 +78,27 @@
return output;
}
document.addEventListener('load', () => {
document.body.onload = (() => {
console.log('calculateTime');
let uptime = document.querySelector('#uptime');
let started = document.querySelector('#started');
if (started != null) {
let startedUTC = '{{ (datetime.datetime.strptime(data['server_stats'][0]['started'], '%Y-%m-%d %H:%M:%S') - datetime.timedelta(seconds=-time.timezone)).strftime('%Y-%m-%d %H:%M:%S') }}';
console.log('utc', startedUTC);
startedUTC = moment.utc(startedUTC, 'YYYY-MM-DD HH:mm:ss');
let browserUTCOffset = moment().utcOffset(); // This is in minutes
let startedLocal = startedUTC.utcOffset(browserUTCOffset);
startedLocal = startedLocal.format('YYYY-MM-DD HH:mm:ss');
console.log('local', startedLocal);
started.textContent = startedLocal
}
let nowServerTime = '{{ data['time'] }}';
let startedServerTime = '{{ data['server_stats'][0]['started'] }}';