Fix time display
This commit is contained in:
26
js/main.js
26
js/main.js
@@ -94,35 +94,15 @@
|
||||
);
|
||||
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++) {
|
||||
var node = nodes[i];
|
||||
var raw = node.getAttribute("data-luxtools-start") || "";
|
||||
if (!raw) continue;
|
||||
|
||||
var date = new Date(raw);
|
||||
if (isNaN(date.getTime())) continue;
|
||||
var match = raw.match(/T(\d{2}):(\d{2})/);
|
||||
if (!match) continue;
|
||||
|
||||
var label;
|
||||
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;
|
||||
node.textContent = match[1] + ":" + match[2];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user