Skip to content
This repository has been archived by the owner on Feb 3, 2020. It is now read-only.

timezone is ignored in the iso8601 conversion from string to date #85

Open
crarau opened this issue Feb 9, 2017 · 4 comments
Open

timezone is ignored in the iso8601 conversion from string to date #85

crarau opened this issue Feb 9, 2017 · 4 comments

Comments

@crarau
Copy link

crarau commented Feb 9, 2017

SwiftMoment ignores the timezone from an iso8601 string formatted date even if it's specified.

Example:
The code
print(moment("2017-02-09T03:17:52.477Z")!.format("yyyy-MM-dd'T'HH:mm:ss.SSSXXXXX")) displays: 2017-02-09T03:17:52.477-05:00
the expected output is either 2017-02-09T03:17:52.477Z or 2017-02-08T22:17:52.477-05:00

from Wikipedia: If the time is in UTC, add a Z directly after the time without a space. Z is the zone designator for the zero UTC offset. "09:30 UTC" is therefore represented as "09:30Z" or "0930Z". "14:45:15 UTC" would be "14:45:15Z" or "144515Z".

@crarau
Copy link
Author

crarau commented Feb 9, 2017

As a parallel in Javascript for this
console.log(moment("2017-02-09T03:17:52.477Z", moment.ISO_8601).format())
we get
2017-02-08T22:17:52-05:00

@crarau
Copy link
Author

crarau commented Apr 24, 2017

Any news about this issue, it's serious issue when working with timezones.

@DarkDirectX
Copy link

Same issue.

@psi-gh
Copy link

psi-gh commented Oct 27, 2017

Same issue here. SwiftMoment can't handle milliseconds. In

print(moment("2017-02-09T03:17:52.477Z"))

try

print(moment("2017-02-09T03:17:52Z"))

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

No branches or pull requests

3 participants