Skip to content

Commit

Permalink
Merge pull request #268 from artyom-razinov/master
Browse files Browse the repository at this point in the history
Fix date parsing for certain environments
  • Loading branch information
AvdLee authored Apr 9, 2024
2 parents cf24434 + 2ca8b65 commit be42e9b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Sources/APIProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ public final class APIProvider {
if let date = formatter.date(from: dateStr) {
return date
}
// Example: 2024-01-01T23:59:59.000+00:00
let isoDateFormatter = ISO8601DateFormatter()
isoDateFormatter.formatOptions = [.withInternetDateTime, .withFractionalSeconds]
if let date = isoDateFormatter.date(from: dateStr) {
return date
}
throw APIProvider.Error.dateDecodingError(dateStr)
})
return decoder
Expand Down

0 comments on commit be42e9b

Please sign in to comment.