castopod/app/Resources/js/modules/Time.ts
Yassine Doghri 37c54d2477 feat: build hashed static files to renew browser cache
- 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
2021-07-12 17:47:56 +00:00

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;