Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent output from formatISO8601 #18

Open
bitterjug opened this issue Mar 1, 2017 · 2 comments
Open

Inconsistent output from formatISO8601 #18

bitterjug opened this issue Mar 1, 2017 · 2 comments

Comments

@bitterjug
Copy link

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

bitterjug added a commit to bitterjug/elm-wpc that referenced this issue Mar 2, 2017
Use Date.Extra in place of DateFormat
to parse and format dates, to avoid
bug with date format not respecting time zones
mgold/elm-date-format#18
@ktonon
Copy link

ktonon commented Mar 5, 2017

@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

@mgold
Copy link
Owner

mgold commented Mar 6, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants