Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
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
- 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
>>>
duration
65923323.002000>>>
humanReadableDuration duration
"2 years 33 days 2 min 3s 2ms"
humanReadableDuration' :: Real a => a -> String Source #
number of seconds in one minute
>>>
minute / oneSecond
60.000000>>>
minute / ms
60000.000000
number of seconds in one hour
>>>
hour / minute
60.000000>>>
hour / oneSecond
3600.000000
number of seconds in one day
>>>
day / hour
24.000000>>>
day / oneSecond
86400.000000
getMs :: Seconds -> Integer Source #
number of milli seconds given a duration in micro seconds
>>>
getMs 1
1000>>>
getMs 1.618033
1618
getSeconds :: Seconds -> Integer Source #
number of seconds given a duration in micro seconds
>>>
getSeconds 1
1>>>
getSeconds 1.618033
1
getMinutes :: Seconds -> Integer Source #
number of minutes given a duration in micro seconds
>>>
getMinutes 60
1>>>
getMinutes 59
0
getHours :: Seconds -> Integer Source #
number of hours given a duration in micro seconds
>>>
getHours 3600
1>>>
getHours (60 * minute)
1>>>
getHours (2 * day)
48