ringvold / elm-iso8601-date-strings / Iso8601

Convert between ISO-8601 date strings and POSIX times.

fromTime : Time.Posix -> String

Inflate a Posix integer into a more memory-intensive ISO-8601 date string.

It's generally best to avoid doing this unless an external API requires it.

(UTC integers are less error-prone, take up less memory, and are more efficient for time arithmetic.)

Format: YYYY-MM-DDTHH:mm:ss.SSSZ

toTime : String -> Result (List Parser.DeadEnd) Time.Posix

Convert from an ISO-8601 date string to a Time.Posix value.

ISO-8601 date strings sometimes specify things in UTC. Other times, they specify a non-UTC time as well as a UTC offset. Regardless of which format the ISO-8601 string uses, this function normalizes it and returns a time in UTC.

decoder : Json.Decode.Decoder Time.Posix

Decode an ISO-8601 date string to a Time.Posix value using toTime.

encode : Time.Posix -> Json.Encode.Value

Encode a Time.Posix value as an ISO-8601 date string using fromTime.