diff options
Diffstat (limited to 'ios')
| -rw-r--r-- | ios/MullvadVPN/REST/RESTCoding.swift | 31 |
1 files changed, 1 insertions, 30 deletions
diff --git a/ios/MullvadVPN/REST/RESTCoding.swift b/ios/MullvadVPN/REST/RESTCoding.swift index 8a5356e3bc..b8c917e6b4 100644 --- a/ios/MullvadVPN/REST/RESTCoding.swift +++ b/ios/MullvadVPN/REST/RESTCoding.swift @@ -27,36 +27,7 @@ extension REST.Coding { let decoder = JSONDecoder() decoder.keyDecodingStrategy = .convertFromSnakeCase decoder.dataDecodingStrategy = .base64 - - let iso8601Formatter = ISO8601DateFormatter() - - // Setup additional formatter to account for fractional seconds returned - // by some of the API calls. - lazy var iso8601WithSubSecondsFormatter: ISO8601DateFormatter = { - let formatter = ISO8601DateFormatter() - formatter.formatOptions.insert(.withFractionalSeconds) - return formatter - }() - - decoder.dateDecodingStrategy = .custom({ decoder in - let container = try decoder.singleValueContainer() - let value = try container.decode(String.self) - - let date = iso8601Formatter.date(from: value) ?? - iso8601WithSubSecondsFormatter.date(from: value) - - switch date { - case .some(let parsedDate): - return parsedDate - - case .none: - throw DecodingError.dataCorruptedError( - in: container, - debugDescription: "Expected date string to be RFC3339 or ISO8601-formatted." - ) - } - }) - + decoder.dateDecodingStrategy = .iso8601 return decoder } } |
