[go: up one dir, main page]

Properly parse and format dates

Node API respond with dates following the iso8601 format: 2019-07-18T22:01:17+00:00. Currently, it's only being decoded to String and trimmed down. They should be stored as Time.Posix in order to facilitate sorting and other manipulations, finally should be transformed to a human readable time.

Decoder example:

iso8601 : Decoder Time.Posix
iso8601 =
  Decode.string
    |> Decode.andThen (fromResult << Result.mapError (\_ -> "Not a valid ISO8601 string) << Iso8601.toTime)
Edited by Leo