-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from Liquidsoul/fix/iso8601-dates
Workaround the unsupported milliseconds part of ISO8601DateFormatter
- Loading branch information
Showing
4 changed files
with
36 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
Tests/AutoJSONSerializationTests/JSONDateFormatterTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import XCTest | ||
@testable import AutoJSONSerialization | ||
|
||
class JSONDateFormatterTests: XCTestCase { | ||
func test_dateFromString() { | ||
let expectedDate = Date(timeIntervalSince1970: 482196050) | ||
|
||
let dateStrings = [ | ||
"1985-04-12T23:20:50Z", | ||
"1985-04-12T22:20:50-01:00", | ||
"1985-04-12T23:20:50.678Z", | ||
"1985-04-12T22:20:50.467-01:00" | ||
] | ||
|
||
dateStrings.forEach { dateString in | ||
XCTAssertEqual(expectedDate, | ||
JSONDateFormatter.date(from: dateString), | ||
"Failed to correctly parse '\(dateString)'") | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters