aboutsummaryrefslogtreecommitdiff
path: root/asset-sources
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2025-12-24 11:17:44 +0100
committerDaniel Schadt <kingdread@gmx.de>2025-12-30 19:16:32 +0100
commite365f5757cd129f37d53bfa429315e8d014df1a1 (patch)
tree5fa687125d3e40a40b9a3438e47f89d0ee867bbb /asset-sources
parentc1bec8eaf3a4f0685a61cdb88e3ef4bf3600dd9f (diff)
downloadfietsboek-e365f5757cd129f37d53bfa429315e8d014df1a1.tar.gz
fietsboek-e365f5757cd129f37d53bfa429315e8d014df1a1.tar.bz2
fietsboek-e365f5757cd129f37d53bfa429315e8d014df1a1.zip
add page to add a journey
Diffstat (limited to 'asset-sources')
-rw-r--r--asset-sources/fietsboek.ts26
1 files changed, 18 insertions, 8 deletions
diff --git a/asset-sources/fietsboek.ts b/asset-sources/fietsboek.ts
index 66caa4f..bcce661 100644
--- a/asset-sources/fietsboek.ts
+++ b/asset-sources/fietsboek.ts
@@ -540,6 +540,23 @@ function loadProfileStats() {
/* Used via in-page scripts, so make eslint happy */
loadProfileStats;
+/**
+ * Formats the given timestamp to the user's locale.
+ *
+ * @param timestamp - The timestamp in milliseconds since the epoch.
+ * @return The formatted string.
+ */
+function formatTimestamp(timestamp: number): string {
+ const date = new Date(timestamp);
+ // TypeScript complains about this, but according to MDN it is fine, at
+ // least in "somewhat modern" browsers
+ const intl = new Intl.DateTimeFormat(LOCALE, {
+ dateStyle: "medium",
+ timeStyle: "medium",
+ } as any);
+ return intl.format(date);
+}
+
document.addEventListener('DOMContentLoaded', function() {
window.fietsboekImageIndex = 0;
@@ -567,13 +584,6 @@ document.addEventListener('DOMContentLoaded', function() {
/* Format all datetimes to the local timezone */
document.querySelectorAll(".fietsboek-local-datetime").forEach((obj) => {
const timestamp = parseFloat(obj.attributes.getNamedItem("data-utc-timestamp")!.value);
- const date = new Date(timestamp * 1000);
- // TypeScript complains about this, but according to MDN it is fine, at
- // least in "somewhat modern" browsers
- const intl = new Intl.DateTimeFormat(LOCALE, {
- dateStyle: "medium",
- timeStyle: "medium",
- } as any);
- obj.innerHTML = intl.format(date);
+ obj.innerHTML = formatTimestamp(timestamp * 1000);
});
});