Set of functions helpful for working with time.
Add [district0x/district-time "1.0.1"]
into your project.clj
Include [district.time]
in your CLJS file
Divides given miliseconds into seconds, minutes, hours, days.
(time/time-units 400000000)
;; => {:seconds 40 :minutes 6 :hours 15 :days 4}
Returns biggest positive time unit from given parameters.
(time/biggest-time-unit (time/time-units 400000000))
;; => [:days 4]
Time remaining from from-time
to to-time
. Passed times are from cljs-time format.
(time/time-remaining (t/now) (t/plus (t/now) (t/hours 3)))
;; => {:seconds 0 :minutes 0 :hours 3 :days 0}
Returns biggest time unit from remaining time. Passed times are from cljs-time format.
(time/time-remaining-biggest-unit (t/now) (t/plus (t/now) (t/hours 3)))
;; => [:hours 3]
Converts epoch to long time format.
(time/epoch->long 1516314507)
;; => 1516314507000
Converts long to epoch time format.
(time/long->epoch 1516314507000)
;; => 1516314507
Converts days to seconds.
(time/days->seconds 3)
;; => 259200
Converts seconds to days.
(time/seconds->days 345600)
;; => 259200
lein deps
# To run tests and rerun on changes
lein doo chrome tests