elm-date-format
elm-date-format copied to clipboard
Inconsistent output from formatISO8601
Date.Format.formatISO8601
appears to be ignoring time zone information.
Here, in the repl, Date.fromString
appears to parse dates correctly; toString
shows them in BST or GMT depending when they fall in the year :
> Date.fromString "2015-11-10T20:34:17Z"
Ok <Tue Nov 10 2015 20:34:17 GMT+0000 (GMT)> : Result.Result String Date.Date
> Date.fromString "2015-10-10T20:34:17Z"
Ok <Sat Oct 10 2015 21:34:17 GMT+0100 (BST)> : Result.Result String Date.Date
But when I use Date.Format.formatISO8601
these two examples result in different times: both should be 20:34
, but the one in October shows up as 21:34:
> Date.fromString "2015-11-10T20:34:17Z" |> Result.map Date.Format.formatISO8601
Ok "2015-11-10T20:34:17Z" : Result.Result String String
> Date.fromString "2015-10-10T20:34:17Z" |> Result.map Date.Format.formatISO8601
Ok "2015-10-10T21:34:17Z" : Result.Result String String
@mgold as discussed on slack general, Date.hour
returns a value adjusted by the timezone offset, but the Date
library does not provide an easy way to get the timezone offset. However, it is possible. See https://github.com/justinmimbs/elm-date-extra/blob/2.0.3/src/Date/Internal/Extract.elm#L61
Thanks for the heads-up.
What do you think about just merging this library into elm-date-extra? Seems silly not to if it's going to depend on it.