Skip to content

Latest commit

 

History

History
87 lines (71 loc) · 2.4 KB

README.md

File metadata and controls

87 lines (71 loc) · 2.4 KB

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

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

Development

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