Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Ordinary timing durations, in H:M:S:m (Hours:Minutes:Seconds:milliseconds)
Synopsis
- data Duration = Duration {}
- s_sms :: (RealFrac n, Integral i) => n -> (i, i)
- sms_s :: Integral i => (i, i) -> Double
- read_duration_tuple :: String -> (Int, Int, Int, Int)
- read_duration :: String -> Duration
- show_duration :: Duration -> String
- normalise_minutes :: Duration -> Duration
- normalise_seconds :: Duration -> Duration
- normalise_milliseconds :: Duration -> Duration
- normalise_duration :: Duration -> Duration
- duration_to_tuple :: (Int -> a) -> Duration -> (a, a, a, a)
- tuple_to_duration :: (a -> Int) -> (a, a, a, a) -> Duration
- duration_to_hours :: Fractional n => Duration -> n
- duration_to_minutes :: Fractional n => Duration -> n
- duration_to_seconds :: Fractional n => Duration -> n
- hours_to_duration :: RealFrac a => a -> Duration
- minutes_to_duration :: RealFrac a => a -> Duration
- seconds_to_duration :: RealFrac a => a -> Duration
- nil_duration :: Duration
- negate_duration :: Duration -> Duration
- duration_diff :: Duration -> Duration -> Duration
Documentation
Duration stored as hours, minutes, seconds and milliseconds.
s_sms :: (RealFrac n, Integral i) => n -> (i, i) Source #
Convert fractional seconds to integral (seconds,milliseconds).
s_sms 1.75 == (1,750)
read_duration :: String -> Duration Source #
show_duration :: Duration -> String Source #
normalise_minutes :: Duration -> Duration Source #
If minutes is not in (0,59) then edit hours.
normalise_seconds :: Duration -> Duration Source #
If seconds is not in (0,59) then edit minutes.
normalise_milliseconds :: Duration -> Duration Source #
If milliseconds is not in (0,999) then edit seconds.
normalise_duration :: Duration -> Duration Source #
Normalise duration so that all parts are in normal ranges.
duration_to_tuple :: (Int -> a) -> Duration -> (a, a, a, a) Source #
Extract Duration
tuple applying filter function at each element
duration_to_tuple id (Duration 1 35 5 250) == (1,35,5,250)
tuple_to_duration :: (a -> Int) -> (a, a, a, a) -> Duration Source #
Inverse of duration_to_tuple
.
duration_to_hours :: Fractional n => Duration -> n Source #
Duration as fractional hours.
duration_to_hours (read "01:35:05.250") == 1.5847916666666668
duration_to_minutes :: Fractional n => Duration -> n Source #
Duration as fractional minutes.
duration_to_minutes (read "01:35:05.250") == 95.0875
duration_to_seconds :: Fractional n => Duration -> n Source #
Duration as fractional seconds.
duration_to_seconds (read "01:35:05.250") == 5705.25
hours_to_duration :: RealFrac a => a -> Duration Source #
Inverse of duration_to_hours.
hours_to_duration 1.5847916 == Duration 1 35 5 250
minutes_to_duration :: RealFrac a => a -> Duration Source #
Inverse of duration_to_minutes.
seconds_to_duration :: RealFrac a => a -> Duration Source #
Inverse of duration_to_seconds.
nil_duration :: Duration Source #
Empty (zero) duration.
negate_duration :: Duration -> Duration Source #
Negate the leftmost non-zero element of Duration.
duration_diff :: Duration -> Duration -> Duration Source #
Difference between two durations as a duration. Implemented by translation to and from Rational fractional hours.
duration_diff (Duration 1 35 5 250) (Duration 0 25 1 125) == Duration 1 10 4 125 duration_diff (Duration 0 25 1 125) (Duration 1 35 5 250) == Duration (-1) 10 4 125 duration_diff (Duration 0 25 1 125) (Duration 0 25 1 250) == Duration 0 0 0 (-125)