Only process dates with valid dateTime attributes

This commit is contained in:
Jonas Tobias Hopusch 2023-03-11 16:02:59 +01:00
parent 1647746a20
commit ac428b0f6c
Signed by: jotoho
GPG key ID: 913BDF1196DCF600

View file

@ -2,9 +2,11 @@
Array.from(document.getElementsByClassName("relative-timestamp")).forEach(
function (timestamp) {
timestamp.innerText = new Intl.DateTimeFormat(undefined, {
dateStyle: "long",
timeStyle: "short",
}).format(new Date(timestamp.dateTime));
if (timestamp?.dateTime) {
timestamp.innerText = new Intl.DateTimeFormat(undefined, {
dateStyle: "long",
timeStyle: "short",
}).format(new Date(timestamp.dateTime));
}
}
);