Only process dates with valid dateTime attributes
This commit is contained in:
parent
1647746a20
commit
ac428b0f6c
1 changed files with 6 additions and 4 deletions
|
@ -2,9 +2,11 @@
|
||||||
|
|
||||||
Array.from(document.getElementsByClassName("relative-timestamp")).forEach(
|
Array.from(document.getElementsByClassName("relative-timestamp")).forEach(
|
||||||
function (timestamp) {
|
function (timestamp) {
|
||||||
|
if (timestamp?.dateTime) {
|
||||||
timestamp.innerText = new Intl.DateTimeFormat(undefined, {
|
timestamp.innerText = new Intl.DateTimeFormat(undefined, {
|
||||||
dateStyle: "long",
|
dateStyle: "long",
|
||||||
timeStyle: "short",
|
timeStyle: "short",
|
||||||
}).format(new Date(timestamp.dateTime));
|
}).format(new Date(timestamp.dateTime));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue