mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-06 00:45:32 +00:00
Fixes #510. If a keyboard.json has no timezone in the last modified date string, then it will still install
This commit is contained in:
parent
bb47b29e16
commit
46efbbc5c8
2 changed files with 16 additions and 5 deletions
|
|
@ -9,6 +9,12 @@
|
|||
import Foundation
|
||||
|
||||
extension JSONDecoder.DateDecodingStrategy {
|
||||
static var iso8601WithoutTimezone: JSONDecoder.DateDecodingStrategy {
|
||||
let formatter = DateFormatter()
|
||||
formatter.locale = Locale(identifier: "en_US_POSIX")
|
||||
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss"
|
||||
return .formatted(formatter)
|
||||
}
|
||||
static var ios8601WithFallback: JSONDecoder.DateDecodingStrategy {
|
||||
if #available(iOS 10.0, *) {
|
||||
return .iso8601
|
||||
|
|
|
|||
|
|
@ -595,12 +595,17 @@ public class Manager: NSObject, HTTPDownloadDelegate, UIGestureRecognizerDelegat
|
|||
if let keyboard = try? decoder.decode(KeyboardAPICall.self, from: data) {
|
||||
downloadKeyboard(keyboard)
|
||||
} else {
|
||||
decoder.dateDecodingStrategy = .ios8601WithMilliseconds
|
||||
do {
|
||||
let keyboard = try decoder.decode(KeyboardAPICall.self, from: data)
|
||||
decoder.dateDecodingStrategy = .iso8601WithoutTimezone
|
||||
if let keyboard = try? decoder.decode(KeyboardAPICall.self, from: data) {
|
||||
downloadKeyboard(keyboard)
|
||||
} catch {
|
||||
downloadFailed(forKeyboards: [], error: error)
|
||||
} else {
|
||||
decoder.dateDecodingStrategy = .ios8601WithMilliseconds
|
||||
do {
|
||||
let keyboard = try decoder.decode(KeyboardAPICall.self, from: data)
|
||||
downloadKeyboard(keyboard)
|
||||
} catch {
|
||||
downloadFailed(forKeyboards: [], error: error)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue