move date-fmt to the bitty script

This commit is contained in:
2025-12-01 01:30:41 +03:00
parent 5c03ba3d3a
commit db2d09cb03
3 changed files with 8 additions and 11 deletions

View File

@@ -28,5 +28,4 @@
</footer> </footer>
</bitty-6-0> </bitty-6-0>
<script src="{{ "/static/js/ui.js" | cachebust }}"></script> <script src="{{ "/static/js/ui.js" | cachebust }}"></script>
<script src="{{ "/static/js/date-fmt.js" | cachebust }}"></script>
</body> </body>

View File

@@ -246,4 +246,12 @@ export default class {
el.scrollIntoView(); el.scrollIntoView();
el.focus(); el.focus();
} }
convertTimestamps(ev, el) {
const timestamp = el.getInt('utc');
if (!isNaN(timestamp)) {
const date = new Date(timestamp * 1000);
el.textContent = date.toLocaleString();
}
}
} }

View File

@@ -1,10 +0,0 @@
document.addEventListener("DOMContentLoaded", () => {
const timestampSpans = document.getElementsByClassName("timestamp");
for (let timestampSpan of timestampSpans) {
const timestamp = parseInt(timestampSpan.dataset.utc);
if (!isNaN(timestamp)) {
const date = new Date(timestamp * 1000);
timestampSpan.textContent = date.toLocaleString();
}
}
})