Liking cljdoc? Tell your friends :D

district-time

Build Status

Set of functions helpful for working with time.

Installation

Add [district0x/district-time "1.0.1"] into your project.clj
Include [district.time] in your CLJS file

API Overview

district.time

time-units [milis]

Divides given miliseconds into seconds, minutes, hours, days.

(time/time-units 400000000)
;; => {:seconds 40 :minutes 6 :hours 15 :days 4}

biggest-time-unit [{:keys [:seconds :minutes :hours :days]}]

Returns biggest positive time unit from given parameters.

(time/biggest-time-unit (time/time-units 400000000))
;; => [:days 4]

time-remaining [from-time to-time]

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}

time-remaining-biggest-unit [from-time to-time]

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]

epoch->long [x]

Converts epoch to long time format.

(time/epoch->long 1516314507)
;; => 1516314507000

long->epoch [x]

Converts long to epoch time format.

(time/long->epoch 1516314507000)
;; => 1516314507

days->seconds [x]

Converts days to seconds.

(time/days->seconds 3)
;; => 259200

seconds->days [x]

Converts seconds to days.

(time/seconds->days 345600)
;; => 259200

Development

lein deps
# To run tests and rerun on changes
lein doo chrome tests

Can you improve this documentation?Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close