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) {
|
||||||
timestamp.innerText = new Intl.DateTimeFormat(undefined, {
|
if (timestamp?.dateTime) {
|
||||||
dateStyle: "long",
|
timestamp.innerText = new Intl.DateTimeFormat(undefined, {
|
||||||
timeStyle: "short",
|
dateStyle: "long",
|
||||||
}).format(new Date(timestamp.dateTime));
|
timeStyle: "short",
|
||||||
|
}).format(new Date(timestamp.dateTime));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue