Fix time display
This commit is contained in:
@@ -42,16 +42,14 @@
|
|||||||
if (!isoStr) return "";
|
if (!isoStr) return "";
|
||||||
var d = new Date(isoStr);
|
var d = new Date(isoStr);
|
||||||
if (isNaN(d.getTime())) return isoStr;
|
if (isNaN(d.getTime())) return isoStr;
|
||||||
return (
|
return formatDate(isoStr) + " " + formatTimeOnly(isoStr);
|
||||||
formatDate(isoStr) + " " + pad2(d.getHours()) + ":" + pad2(d.getMinutes())
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatTimeOnly(isoStr) {
|
function formatTimeOnly(isoStr) {
|
||||||
if (!isoStr) return "";
|
if (!isoStr) return "";
|
||||||
var d = new Date(isoStr);
|
var match = isoStr.match(/T(\d{2}):(\d{2})/);
|
||||||
if (isNaN(d.getTime())) return isoStr;
|
if (!match) return isoStr;
|
||||||
return pad2(d.getHours()) + ":" + pad2(d.getMinutes());
|
return match[1] + ":" + match[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatEventListTime(startIso, fallbackTime) {
|
function formatEventListTime(startIso, fallbackTime) {
|
||||||
|
|||||||
26
js/main.js
26
js/main.js
@@ -94,35 +94,15 @@
|
|||||||
);
|
);
|
||||||
if (!nodes || nodes.length === 0) return;
|
if (!nodes || nodes.length === 0) return;
|
||||||
|
|
||||||
var formatter;
|
|
||||||
try {
|
|
||||||
formatter = new Intl.DateTimeFormat("de-DE", {
|
|
||||||
hour: "2-digit",
|
|
||||||
minute: "2-digit",
|
|
||||||
hour12: false,
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
formatter = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var i = 0; i < nodes.length; i++) {
|
for (var i = 0; i < nodes.length; i++) {
|
||||||
var node = nodes[i];
|
var node = nodes[i];
|
||||||
var raw = node.getAttribute("data-luxtools-start") || "";
|
var raw = node.getAttribute("data-luxtools-start") || "";
|
||||||
if (!raw) continue;
|
if (!raw) continue;
|
||||||
|
|
||||||
var date = new Date(raw);
|
var match = raw.match(/T(\d{2}):(\d{2})/);
|
||||||
if (isNaN(date.getTime())) continue;
|
if (!match) continue;
|
||||||
|
|
||||||
var label;
|
node.textContent = match[1] + ":" + match[2];
|
||||||
if (formatter) {
|
|
||||||
label = formatter.format(date);
|
|
||||||
} else {
|
|
||||||
var hh = String(date.getHours()).padStart(2, "0");
|
|
||||||
var mm = String(date.getMinutes()).padStart(2, "0");
|
|
||||||
label = hh + ":" + mm;
|
|
||||||
}
|
|
||||||
|
|
||||||
node.textContent = label;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user