From 8c46de38348c421c0c9f102d604fcfc18807c0bb Mon Sep 17 00:00:00 2001 From: Miguel Ángel Moreno Date: Thu, 29 Dec 2022 02:26:20 +0100 Subject: feat(frontend): Add further features and address quirks --- src/frontend/tau/util.cljs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/frontend/tau/util.cljs (limited to 'src/frontend/tau/util.cljs') 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))) -- cgit v1.2.3