Skip to content

Commit

Permalink
Fix date parsing for certain environments
Browse files Browse the repository at this point in the history
There were 2 users (in a certain company where I work, which is a very small fraction of users) who experienced this issue, they had some specific environment, we did not check which environment they had or why this code works, we only know that it solves the issue
  • Loading branch information
artyom-razinov committed Apr 8, 2024
1 parent 2fb0578 commit 2ca8b65
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 2ca8b65

Please sign in to comment.