From 1bb8b0557336b4ceba5262e847869bfb63c5e006 Mon Sep 17 00:00:00 2001 From: Sacha Chua Date: Thu, 15 Oct 2026 14:18:54 -0400 Subject: translate to local time --- script.js | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'script.js') diff --git a/script.js b/script.js index 9777c060..4f89f4d6 100644 --- a/script.js +++ b/script.js @@ -62,18 +62,32 @@ // @license magnet:?xt=urn:btih:90dc5c0be029de84e523b9b3922520e79e0e6f08&dn=cc0.txt txt CC0-1.0 // Copyright (C) 2021, 2022, 2026 Sacha Chua - function addLocalTimeToSVGs() { +function addLocalTimeToSVGs() { var dateOptions = { year: 'numeric', month: 'numeric', day: 'numeric', - hour: 'numeric', minute: 'numeric', - timeZoneName: 'short' }; + hour: 'numeric', minute: 'numeric', + timeZoneName: 'short' + }; document.querySelectorAll('svg a[data-start]').forEach((o) => { let start = new Date(o.getAttribute('data-start')); + let end = new Date(o.getAttribute('data-end')); let title = o.querySelector('title'); if (title) { - title.textContent += ' = ' + start.toLocaleString([], dateOptions); + title.textContent = + start.toLocaleString([], {hour: 'numeric', minute: 'numeric'}).replace(/\\./g, '') + ' - ' + + end.toLocaleString([], {hour: 'numeric', minute: 'numeric', timeZoneName: 'short'}).replace(/\\./g, '') + ': ' + o.getAttribute('title'); } }); + document.querySelectorAll('.hour-label[data-start]').forEach((o) => { + let start = new Date(o.getAttribute('data-start')); + o.textContent = start.toLocaleString([], {hour: 'numeric', minute: 'numeric', timeZoneName: 'short'}).replace(/\./g, ''); + }); + +document.querySelectorAll('.day-label[data-start]').forEach((o) => { + let start = new Date(o.getAttribute('data-start')); + o.textContent = start.toLocaleString([], {weekday: 'long', month: 'short', day: 'numeric', timeZoneName: 'long'}).replace(/\./g, ''); + }); + } addLocalTimeToSVGs(); -- cgit v1.2.3