aboutsummaryrefslogtreecommitdiff
path: root/assets/js
diff options
context:
space:
mode:
authortdro <tdro@noreply.example.com>2023-10-15 17:17:20 -0400
committertdro <tdro@noreply.example.com>2023-10-15 17:17:20 -0400
commita098764110b882a261fe0bf6ad14b7a0ea6e9f72 (patch)
treebb8b2f36eeec78e05aca6c241e25d38cdba2586e /assets/js
parent30f40a84cf28fbffca82d04a35904eb2674593ae (diff)
downloadcanory-a098764110b882a261fe0bf6ad14b7a0ea6e9f72.tar.gz
canory-a098764110b882a261fe0bf6ad14b7a0ea6e9f72.tar.bz2
canory-a098764110b882a261fe0bf6ad14b7a0ea6e9f72.zip
static/js/timeago: Localize time
Diffstat (limited to 'assets/js')
-rw-r--r--assets/js/index.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/assets/js/index.js b/assets/js/index.js
index dc4fef1..3d133fd 100644
--- a/assets/js/index.js
+++ b/assets/js/index.js
@@ -593,6 +593,19 @@
const days = Math.round(hours / 24);
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);