gigobyte/iso8601-duration/1.0.0

Iso8601.Duration

Convert between ISO-8601 durations strings and Duration values.

type alias Duration =
{ years : Float
, months : Float
, days : Float
, hours : Float
, minutes : Float
, seconds : Float
}
fromString : String -> Maybe Duration

Convert from an ISO-8601 duration string to a Duration value.

In case a week duration is given only the days property will be populated with the number of weeks * 7.

toString : Duration -> String

Convert a Duration value to an ISO-8601 duration string.

Week durations are not supported, even values with days only will still be serialized as PnD.

decoder : Decoder Duration

Decode an ISO-8601 duration string to a Duration value using fromString.

encode : Duration -> Value

Encode a Duration value as an ISO-8601 duration string using toString.