You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -49,10 +50,49 @@ open class DictionaryDecoder: Decoder {
49
50
}catch{
50
51
storage.push(container: value)
51
52
defer{ _ = storage.popContainer()}
53
+
if type ==Date.self {
54
+
returntryunwrapDate()as!T
55
+
}
52
56
returntryT(from:self)
53
57
}
54
58
}
55
59
60
+
privatefunc unwrapDate()throws->Date{
61
+
switch dateDecodingStrategy {
62
+
case.deferredToDate:
63
+
returntryDate(from:self)
64
+
65
+
case.secondsSince1970:
66
+
letcontainer=SingleValueContainer(decoder:self)
67
+
letdouble=try container.decode(Double.self)
68
+
returnDate(timeIntervalSince1970: double)
69
+
70
+
case.millisecondsSince1970:
71
+
letcontainer=SingleValueContainer(decoder:self)
72
+
letdouble=try container.decode(Double.self)
73
+
returnDate(timeIntervalSince1970: double /1000.0)
74
+
75
+
case.iso8601:
76
+
letcontainer=SingleValueContainer(decoder:self)
77
+
letstring=try container.decode(String.self)
78
+
guardlet date = _iso8601Formatter.date(from: string)else{
79
+
throwDecodingError.dataCorrupted(DecodingError.Context(codingPath:self.codingPath, debugDescription:"Expected date string to be ISO8601-formatted."))
80
+
}
81
+
return date
82
+
83
+
case.formatted(let formatter):
84
+
letcontainer=SingleValueContainer(decoder:self)
85
+
letstring=try container.decode(String.self)
86
+
guardlet date = formatter.date(from: string)else{
87
+
throwDecodingError.dataCorrupted(DecodingError.Context(codingPath:self.codingPath, debugDescription:"Date string does not match format expected by formatter."))
0 commit comments