mirror of
https://code.castopod.org/adaures/castopod
synced 2025-04-23 01:01:20 +00:00

- podcast name was too vague and didn't come clearly for users: handle is more relevant - update package.json dependencies and remove unnused packages closes #126
22 lines
681 B
TypeScript
22 lines
681 B
TypeScript
const Time = (): void => {
|
|
const timeElements: NodeListOf<HTMLTimeElement> =
|
|
document.querySelectorAll("time");
|
|
|
|
for (let i = 0; i < timeElements.length; i++) {
|
|
const timeElement = timeElements[i];
|
|
|
|
// convert UTC date value to user timezone
|
|
const timeElementDateTime = timeElement.getAttribute("datetime");
|
|
|
|
// check if timeElementDateTime is not null and not a duration
|
|
if (timeElementDateTime && !timeElementDateTime.startsWith("PT")) {
|
|
const dateTime = new Date(timeElementDateTime);
|
|
|
|
// replace <time/> title with localized datetime
|
|
timeElement.setAttribute("title", dateTime.toLocaleString());
|
|
}
|
|
}
|
|
};
|
|
|
|
export default Time;
|