From: gregor herrmann Date: Thu, 2 Aug 2018 11:11:43 +0000 (+0200) Subject: do some horribly wrong timezone magic X-Git-Url: https://git.toastfreeware.priv.at/chrisu/seepark.git/commitdiff_plain/ebe2bb2492812aea5d73facd2a87cfb66e04ee3d do some horribly wrong timezone magic --- diff --git a/web/static/seepark_web.js b/web/static/seepark_web.js index 1390cd7..e663296 100644 --- a/web/static/seepark_web.js +++ b/web/static/seepark_web.js @@ -125,8 +125,13 @@ function loaddays(days) { function beginend(days) { var now = Date.now(); - var end = new Date(now).toISOString().substr(0, 19); // 2018-06-13T16:52:30.995Z - var begin = new Date(now - days * 60*60*24 * 1000).toISOString().substr(0, 19); + + // TODO: this timezone calculation relies on the browser being in Europe/Vienna + var refdate = new Date(now); + var offset = refdate.getTimezoneOffset(); // -120 for UTC+2 + + var end = new Date(now - offset * 60 * 1000).toISOString().substr(0, 19); // 2018-06-13T16:52:30.995Z + var begin = new Date(now - days * 60*60*24 * 1000 - offset * 60 * 1000).toISOString().substr(0, 19); return '&begin=' + begin + '&end=' + end; }