From 85bd44b677381dffff9c7752bfecb390d094d92a Mon Sep 17 00:00:00 2001 From: Serraniel Date: Mon, 28 Dec 2020 17:17:56 +0100 Subject: [PATCH] #147 Display correct timezone on hover --- src/javascript/enhancements/timeConversion.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/javascript/enhancements/timeConversion.js b/src/javascript/enhancements/timeConversion.js index 9f69de3..5c230e4 100644 --- a/src/javascript/enhancements/timeConversion.js +++ b/src/javascript/enhancements/timeConversion.js @@ -156,6 +156,16 @@ function updateTime(node) { return true; } +function updateTimeZone(node) { + const HINT_UTC = 'UTC+1'; + if (node.textContent === HINT_UTC) { + let tzMeta = spacetime().timezone(); + console.log(tzMeta); + + node.textContent = `${tzMeta.name} (UTC${tzMeta.current.offset >= 0 ? '+' : ''}${tzMeta.current.offset})`; + } +} + function updateTimestamps(node) { let nodes = helper.findTextNodes(node); @@ -179,5 +189,7 @@ function updateTimestamps(node) { __alteredNodes.push(node); return; } + + updateTimeZone(node); }); } \ No newline at end of file