aboutsummaryrefslogtreecommitdiff
path: root/src/frontend/tau/util.cljs
blob: 1a3e243eedcf2df5a99c6fdf3a5868ca207287ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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)))