Skip to content

Commit 394b977

Browse files
committed
Add fallback for fractional seconds
1 parent e81f70f commit 394b977

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Sources/OpenAPIRuntime/Conversion/Configuration.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ public struct ISO8601DateTranscoder: DateTranscoder {
3434

3535
/// Creates and returns a date object from the specified ISO 8601 formatted string representation.
3636
public func decode(_ dateString: String) throws -> Date {
37-
guard let date = ISO8601DateFormatter().date(from: dateString) else {
37+
let fallbackFormatter = ISO8601DateFormatter()
38+
fallbackFormatter.formatOptions = [.withFractionalSeconds, .withInternetDateTime]
39+
guard let date = ISO8601DateFormatter().date(from: dateString) ?? fallbackFormatter.date(from: dateString) else {
3840
throw DecodingError.dataCorrupted(
3941
.init(
4042
codingPath: [],

0 commit comments

Comments
 (0)