Periods
A small time-period (e.g. 4 months, 3 hours, 2 minutes) library for easy conversion and normalization. Not meant to work on date-times. I repeat, this is not a date-time library.
Installation
Usage
From this point forward, it is assumed that your require statement looks like this
(require '[periods.core :as periods])
Periods are just maps.
{:hours 25}
The keys are unabbreviated and plural.
(def period-units
[:years :months :days :hours :minutes :seconds :milliseconds])
Normalize periods to be proper.
(periods/normalize {:hours 25}) ;; => {:days 1, :hours 1}
Want to convert some period into a single period?
(periods/period->mono-period {:years 2 :days 40} :minutes) ;; => {:minutes 1109520}
365.25 days a year
(periods/normalize-milliseconds {:milliseconds 66571200000}) ;; => {:years 2, :months 1, :days 9, :hours 13, :minutes 30}