From 9339e42caee4d4e8356bf925650d7375cb40dfa1 Mon Sep 17 00:00:00 2001 From: Thierry Carrez Date: Wed, 6 May 2020 15:56:26 +0200 Subject: [PATCH] UTC times can be confusing, explain times better If real time equivalents for the time slots are provided, add a link to timeanddate.com corresponding to the time, and display browser local time equivalent for the time displayed. Also make sure that the day tab corresponds to the UTC day (until 01 UTC the next day) whatever your timezone is. Change-Id: I7847e0ac68fc6fcd176d40cc94d4e21c3c6e03e0 --- base.json | 1 + html/ptg.html | 2 +- html/ptg.js | 19 ++++++++++++++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/base.json b/base.json index ee8cdd9..1718f39 100644 --- a/base.json +++ b/base.json @@ -9,6 +9,7 @@ "slots": { "Monday": [ { + "realtime": "2020-06-01T09:00:00Z", "desc": "09:00-10:45", "name": "MonA1" }, diff --git a/html/ptg.html b/html/ptg.html index 83179ec..2eb1b07 100644 --- a/html/ptg.html +++ b/html/ptg.html @@ -112,7 +112,7 @@ {{#each times as |time|}} - + {{/each}} {{#each @root.schedule as |sched room|}} diff --git a/html/ptg.js b/html/ptg.js index 835321b..137d940 100644 --- a/html/ptg.js +++ b/html/ptg.js @@ -86,10 +86,27 @@ Handlebars.registerHelper('roomcode', return new Handlebars.SafeString(cell); }); +Handlebars.registerHelper('displaytime', + function(time) { + if (time['realtime'] != undefined) { + var t = new Date(time['realtime']); + content = '' + + time['desc'] +''; + } else { + content = time['desc']; + } + return new Handlebars.SafeString(content); +}); + + // What is the day today ? +// Return Monday until Tuesday 1 UTC var now = new Date(); +now.setHours(now.getHours()-1); var days = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday']; -var day = days[ now.getDay() ]; +var day = days[ now.getUTCDay() ]; var checkins = {}; $.getJSON("ptg.json", function(json) {
{{time.desc}}{{ displaytime time }}