hswaw/checkinator: convert timestamp to browsers timezone
Change-Id: Ib7439269bf13de530a5f170bf231f89d815b0f3e
Reviewed-on: https://gerrit.hackerspace.pl/c/hscloud/+/1246
Reviewed-by: q3k <q3k@hackerspace.pl>
diff --git a/hswaw/checkinator/at/templates/main.html b/hswaw/checkinator/at/templates/main.html
index 6012b21..36ab1cd 100644
--- a/hswaw/checkinator/at/templates/main.html
+++ b/hswaw/checkinator/at/templates/main.html
@@ -9,7 +9,7 @@
{% for user, timestamp in users %}
<li>
<a href="{{ user | wikiurl }}">
- {{ user }} ({{ timestamp|strfts() }})
+ {{ user }} (<span class="timestamp" data-datetime="{{ timestamp|utcisoformat }}">{{ timestamp|strfts() }} UTC</span>)
</a>
</li>
{% endfor %}
@@ -31,4 +31,19 @@
{% endtrans %}
<hr>
<a href="claim">Claim this device!</a>
+ <script>
+ function formatDate(d) {
+ function pad(n) {return n<10 ? '0'+n : n};
+ return d.getFullYear()+'-'
+ + pad(d.getMonth()+1)+'-'
+ + pad(d.getDate())+' '
+ + pad(d.getHours())+':'
+ + pad(d.getMinutes());
+ }
+
+ for (const tstamp of document.getElementsByClassName('timestamp')) {
+ const dt = new Date(tstamp.getAttribute("data-datetime"));
+ tstamp.innerHTML = formatDate(dt);
+ }
+ </script>
{% endblock %}