SwiftMoment
SwiftMoment copied to clipboard
timezone is ignored in the iso8601 conversion from string to date
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".
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
Any news about this issue, it's serious issue when working with timezones.
Same issue.
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"))