Time.Duration

lib/Time/Duration.gob

An exact amount of elapsed time, to the nanosecond: the distance between two points on the timeline. Stored as a count of nanoseconds, so it spans about 292 years either way, and arithmetic on it panics on overflow as Int's does.

There is no unit of days. A day on the calendar is 23, 24 or 25 hours long depending on the zone and the date; "one day later" is a calendar shift by a Period, and "24 hours later" is written as that.

type Duration : Ord
fun hours : fun(Int) -> Duration
fun minutes : fun(Int) -> Duration
fun seconds : fun(Int) -> Duration
fun millis : fun(Int) -> Duration
fun micros : fun(Int) -> Duration
fun nanos : fun(Int) -> Duration
let zero : Duration
fun toNanos : fun(Duration) -> Int
fun toSeconds : fun(Duration) -> Int

Whole seconds, rounded toward zero.

fun times : fun(Duration, Int) -> Duration
fun divide : fun(Duration, Int) -> Duration

Rounded toward zero, to the nanosecond.

fun parse : fun(String) -> Option Duration

ISO 8601 time-based durations: PT1H30M, PT90M, PT1.5S, an optional sign before the P, at least one of the fields in the order H, M, S, and a fraction on the seconds only. A date part (P1D) is not a duration, and an amount too large to hold is None.

instance Add Duration
instance Sub Duration
instance Neg Duration
instance Show Duration

ISO 8601, with hours as the largest unit: PT1H30M, PT0.25S, PT0S for zero, and a leading - for a negative duration, -PT5M.