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

Date.Extra.Format.isoString isn't parsable in Safari. #29

Closed
mrozbarry opened this issue Jan 19, 2017 · 6 comments
Closed

Date.Extra.Format.isoString isn't parsable in Safari. #29

mrozbarry opened this issue Jan 19, 2017 · 6 comments

Comments

@mrozbarry
Copy link

I'm building an elm app that builds a Date.Date from two different sources, and gets the local timezone to submit to a server in an iso8601 format. To extract the local timezone, I was originally doing:

localTimeZone : String
localTimeZone =
  (Date.fromTime 0)
    |> Date.Extra.Format.isoString
    |> String.right 5
    -- Result : -0500

Later, I combine my date and time parts with this local timezone and do a Date.fromString which I'm guessing backs onto javascript's Date implementation. This works perfectly fine in Chrome and Firefox, but Safari throws an error saying the date I assembled isn't a proper 8601 format.

After some fiddling, I discovered Safari would only accept a timezone if it was formatted with a : between the hour and minute, ie 1999-01-01T12:00:00-05:00.

Would it be possible to have isoString output with that format, as it can be parsed on all browsers using Date.fromString from elm's core packages.

@rluiten
Copy link
Owner

rluiten commented Jan 19, 2017

Sounds eminently reasonable.
Had a look at the code the format specifier :z does put a colon out for zone.

Hmm but the default isn't using it for some reason.
isoMsecOffsetFormat = "%Y-%m-%dT%H:%M:%S.%L%z"

I'll look into this next time I am in code base.

@mrozbarry
Copy link
Author

That would be perfect - if I have some time and beat you to it, I'll do a PR as well.

@mrozbarry
Copy link
Author

@rluiten I just did a fresh install of my project, and it looks like the ":" is back in the timezone - was this fixed?

@rluiten
Copy link
Owner

rluiten commented Jan 24, 2017

I have not updated the lib yet.

@mrozbarry
Copy link
Author

Oh, I see, I had a bug in my code, which was also affected by this missing ":".

@rluiten
Copy link
Owner

rluiten commented Jan 31, 2017

I am about to publish this change to include : in Format.isoString result and in exported format string Format.isoMsecOffsetFormat in v8.2.0.

@rluiten rluiten closed this as completed Jan 31, 2017
rluiten added a commit that referenced this issue Jan 31, 2017
fix(Format): isoMsecOffsetFormat now defaults to %:z format to include colon in string, which seems a more general solution.
See #29 for context.

style(Internal): removed some left over Debug.log.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants