mirror of
https://code.castopod.org/adaures/castopod.git
synced 2024-09-04 18:07:18 +02:00
- replace rollup config with vitejs - use vite dev server during development to take advantage of hot module replacement (HMR) - add vite service using Vite library to load css and js assets - update package.json scripts and remove unnecessary dependencies - update scripts/bundle-prepare.sh closes #107
23 lines
685 B
TypeScript
23 lines
685 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;
|