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

[SR-13218] Swift's ISO8601DateFormatter doesn't parse all valid RFC3339 dates #55658

Open
swift-ci opened this issue Jul 14, 2020 · 0 comments
Open
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-13218
Radar https://feedbackassistant.apple.com/feedback/7999894
Original Reporter kerrmarin (JIRA User)
Type Bug
Environment

Xcode Version 11.5 (11E608c)

Additional Detail from JIRA
Votes 0
Component/s
Labels Bug
Assignee None
Priority Medium

md5: 518c44c95703fc867fc7955333957c79

relates to:

  • SR-12104 ISO8601DateFormatter fails to parse "2013-11-01T00:00.00Z"

Issue Description:

The ISO8601 standard RFC 3339 states that all of these:

1985-04-12T23:20:50.52Z
1996-12-19T16:39:57-08:00 //does work
1996-12-20T00:39:57Z //does work
1990-12-31T23:59:60Z
1937-01-01T12:00:27.87+00:20

are valid dates. However, the `ISO8601DateFormatter` doesn't decode all these. It decodes the ones with the "//does work".

Also, the `JSONDecoder` class with `dateDecodingStrategy` of `.iso8601` fails in the same way.

You can reproduce with this in a playground:

import Foundation
let formatter = ISO8601DateFormatter()
let dates = [
    "1985-04-12T23:20:50.52Z",
    "1996-12-19T16:39:57-08:00", //works
    "1996-12-20T00:39:57Z", // works.
    "1990-12-31T23:59:60Z",
    "1990-12-31T15:59:60-08:00",
    "1937-01-01T12:00:27.87+00:20"
]
let result: [Date?] = dates.map {
    return formatter.date(from: $0)
}
print(result)
@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.
Projects
None yet
Development

No branches or pull requests

1 participant