aboutsummaryrefslogtreecommitdiff
path: root/static/js/timeago.ts
diff options
context:
space:
mode:
Diffstat (limited to 'static/js/timeago.ts')
-rw-r--r--static/js/timeago.ts12
1 files changed, 12 insertions, 0 deletions
diff --git a/static/js/timeago.ts b/static/js/timeago.ts
index 47f6b79..2949d44 100644
--- a/static/js/timeago.ts
+++ b/static/js/timeago.ts
@@ -39,6 +39,18 @@
const past = Math.sign(seconds) === 1;
const future = Math.sign(seconds) === -1;
+ if (element.dataset.type === "localDate") {
+ return element.textContent = new Intl.DateTimeFormat([], {
+ dateStyle: "medium",
+ }).format(time).replace(",", "");
+ }
+
+ if (element.dataset.type === "localTime") {
+ return element.textContent = new Intl.DateTimeFormat([], {
+ hour12: false, timeStyle: "short",
+ }).format(time) + " " + new Intl.DateTimeFormat([], { timeZoneName: "short" }).format(time).split(" ")[1];
+ }
+
if (past) {
if (seconds <= 60) { return element.textContent = tiny(relative.format(-1 * seconds, "second",), 1); }
if (minutes <= 120) { return element.textContent = tiny(relative.format(-1 * minutes, "minute",), 1); }