mirror of
https://code.castopod.org/adaures/castopod.git
synced 2024-09-11 12:58:04 +02: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;
|