dateformat only supports whole seconds but JSON date strings may include fractions ex. 2020-08-21T19:35:42.994Z.
Use case:
fetch some data from db
convert to aeson Value using toJSON
pass as context to easyRender
Expected behavior:
Dates can be formatted using dateformat.
Actual behavior:
In case the date has an exact number of seconds everything works fine. However, when fractions of seconds are present ex. 2020-08-21T19:35:42.994Z then dateformat produces no output.
I think the only change needed would be to add %Q to the first 4 formats here. This handles both cases:
λ> parseTimeOrError False defaultTimeLocale "%Y-%m-%dT%H:%M:%S%Q%Z" "2020-08-21T19:35:42.994Z" :: UTCTime
2020-08-21 19:35:42.994 UTC
it :: UTCTime
λ> parseTimeOrError False defaultTimeLocale "%Y-%m-%dT%H:%M:%S%Q%Z" "2020-08-21T19:35:42Z" :: UTCTime
2020-08-21 19:35:42 UTC
it :: UTCTime
Hi,
dateformat
only supports whole seconds but JSON date strings may include fractions ex.2020-08-21T19:35:42.994Z
.Use case:
Value
usingtoJSON
Expected behavior: Dates can be formatted using
dateformat
.Actual behavior: In case the date has an exact number of seconds everything works fine. However, when fractions of seconds are present ex.
2020-08-21T19:35:42.994Z
thendateformat
produces no output.I think the only change needed would be to add
%Q
to the first 4 formats here. This handles both cases: