summaryrefslogtreecommitdiffstats
path: root/templates/page.tmpl
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--templates/page.tmpl14
1 files changed, 10 insertions, 4 deletions
diff --git a/templates/page.tmpl b/templates/page.tmpl
index ba832af6..33885246 100644
--- a/templates/page.tmpl
+++ b/templates/page.tmpl
@@ -295,7 +295,7 @@ Last edited <TMPL_VAR MTIME>
<script>
// @license magnet:?xt=urn:btih:90dc5c0be029de84e523b9b3922520e79e0e6f08&dn=cc0.txt txt CC0-1.0
// Copyright (C) 2021, 2022 Sacha Chua
-
+
if (document.querySelector('.times')) {
var dateOptions = {dateStyle: 'short', timeStyle: 'short'};
var localStart = (new Date(document.querySelector('.times').getAttribute('start'))).toLocaleString([], dateOptions);
@@ -311,9 +311,15 @@ Last edited <TMPL_VAR MTIME>
document.querySelectorAll('.time-overlay').forEach(function (o) {
if (o.getAttribute('title')) return;
var dateOptions = {dateStyle: 'short', timeStyle: 'short'};
- var localStart = (new Date(o.getAttribute('start'))).toLocaleString([], dateOptions);
- var localEnd = (new Date(o.getAttribute('end'))).toLocaleString([], dateOptions);
- o.setAttribute('title', 'Your local time: ~ ' + localStart + ' to ~ ' + localEnd);
+ var localStart, localEnd;
+ if (o.getAttribute('start') && o.getAttribute('end')) {
+ localStart = (new Date(o.getAttribute('start'))).toLocaleString([], dateOptions);
+ localEnd = (new Date(o.getAttribute('end'))).toLocaleString([], dateOptions);
+ o.setAttribute('title', 'Your local time: ~ ' + localStart + ' to ~ ' + localEnd);
+ } else if (o.getAttribute('start')) {
+ localStart = (new Date(o.getAttribute('start'))).toLocaleString([], dateOptions);
+ o.setAttribute('title', 'Your local time: ~ ' + localStart);
+ }
});
}