| Safe Haskell | Safe |
|---|---|
| Language | Haskell2010 |
Data.Duration
Description
This is a minimal Haskell library to display duration.
> let duration = 2 * ms + 3 * oneSecond + 2 * minute + 33*day + 2*year > humanReadableDuration duration "2 years 33 days 2 min 3s 2ms" > getYears duration 2 > getDays duration 763 > getMs duration 65923323002
Synopsis
- humanReadableDuration :: Seconds -> String
- humanReadableDuration' :: Real a => a -> String
- approximativeDuration :: Micro -> String
- type Seconds = Micro
- ms :: Seconds
- oneSecond :: Seconds
- minute :: Seconds
- hour :: Seconds
- day :: Seconds
- year :: Seconds
- getMs :: Seconds -> Integer
- getSeconds :: Seconds -> Integer
- getMinutes :: Seconds -> Integer
- getHours :: Seconds -> Integer
- getDays :: Seconds -> Integer
- getYears :: Seconds -> Integer
Documentation
humanReadableDuration :: Seconds -> String Source #
humanReadableDuration take some time in micro-second precision and render a human readable duration.
>>>let duration = 2 * ms + 3 * oneSecond + 2 * minute + 33*day + 2*year>>>duration65923323.002000>>>humanReadableDuration duration"2 years 33 days 2 min 3s 2ms"
humanReadableDuration' :: Real a => a -> String Source #
approximativeDuration :: Micro -> String Source #
humanReadableDuration take some time in micro-second precision and render a human readable duration.
>>>let duration = 2 * ms + 3 * oneSecond + 2 * minute + 33*day + 2*year>>>duration65923323.002000>>>approximativeDuration duration"2 years">>>let duration = 2 * ms + 3 * oneSecond + 2 * minute + 33*day>>>approximativeDuration duration"33 days">>>let duration = 2 * ms + 3 * oneSecond + 280 * minute>>>approximativeDuration duration"4 hours">>>let duration = 2 * ms + 3 * oneSecond + 22 * minute>>>approximativeDuration duration"22 min">>>let duration = 2 * ms + 3 * oneSecond>>>approximativeDuration duration"3s">>>let duration = 12 * ms>>>approximativeDuration duration"12ms"
number of seconds in one minute
>>>minute / oneSecond60.000000>>>minute / ms60000.000000
number of seconds in one hour
>>>hour / minute60.000000>>>hour / oneSecond3600.000000
number of seconds in one day
>>>day / hour24.000000>>>day / oneSecond86400.000000
getMs :: Seconds -> Integer Source #
number of milli seconds given a duration in micro seconds
>>>getMs 11000>>>getMs 1.6180331618
getSeconds :: Seconds -> Integer Source #
number of seconds given a duration in micro seconds
>>>getSeconds 11>>>getSeconds 1.6180331
getMinutes :: Seconds -> Integer Source #
number of minutes given a duration in micro seconds
>>>getMinutes 601>>>getMinutes 590
getHours :: Seconds -> Integer Source #
number of hours given a duration in micro seconds
>>>getHours 36001>>>getHours (60 * minute)1>>>getHours (2 * day)48