diff options
author | Miguel Ángel Moreno <mail@migalmoreno.com> | 2022-12-29 02:26:20 +0100 |
---|---|---|
committer | Miguel Ángel Moreno <mail@migalmoreno.com> | 2022-12-29 02:26:20 +0100 |
commit | 8c46de38348c421c0c9f102d604fcfc18807c0bb (patch) | |
tree | 3174b4392ca3eadd24c1da06929830b220764e38 /src/frontend/tau/util.cljs | |
parent | dfcc61063822dfb0fe699896da312249e93d5439 (diff) |
feat(frontend): Add further features and address quirks
Diffstat (limited to 'src/frontend/tau/util.cljs')
-rw-r--r-- | src/frontend/tau/util.cljs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/frontend/tau/util.cljs b/src/frontend/tau/util.cljs new file mode 100644 index 0000000..1a3e243 --- /dev/null +++ b/src/frontend/tau/util.cljs @@ -0,0 +1,16 @@ +(ns tau.util) + +(defn format-quantity + [num] + (.format + (js/Intl.NumberFormat + "en-US" #js {"notation" "compact" "maximumFractionDigits" 1}) + num)) + +(defn format-duration + [num] + (let [duration (js/Date. (* num 1000)) + slice (if (> (.getHours duration) 1) + #(.slice % 11 19) + #(.slice % 14 19))] + (-> duration (.toISOString) slice))) |