@@ -8,11 +8,11 @@ import Foundation
8
8
9
9
public struct RecommendTimeRange : Codable , JSONEncodable {
10
10
/// When the rule should start to be active, in Unix epoch time.
11
- public var from : Int64
11
+ public var from : Int64 ?
12
12
/// When the rule should stop to be active, in Unix epoch time.
13
- public var until : Int64
13
+ public var until : Int64 ?
14
14
15
- public init ( from: Int64 , until: Int64 ) {
15
+ public init ( from: Int64 ? = nil , until: Int64 ? = nil ) {
16
16
self . from = from
17
17
self . until = until
18
18
}
@@ -26,8 +26,8 @@ public struct RecommendTimeRange: Codable, JSONEncodable {
26
26
27
27
public func encode( to encoder: Encoder ) throws {
28
28
var container = encoder. container ( keyedBy: CodingKeys . self)
29
- try container. encode ( self . from, forKey: . from)
30
- try container. encode ( self . until, forKey: . until)
29
+ try container. encodeIfPresent ( self . from, forKey: . from)
30
+ try container. encodeIfPresent ( self . until, forKey: . until)
31
31
}
32
32
}
33
33
@@ -40,7 +40,7 @@ extension RecommendTimeRange: Equatable {
40
40
41
41
extension RecommendTimeRange : Hashable {
42
42
public func hash( into hasher: inout Hasher ) {
43
- hasher. combine ( self . from. hashValue)
44
- hasher. combine ( self . until. hashValue)
43
+ hasher. combine ( self . from? . hashValue)
44
+ hasher. combine ( self . until? . hashValue)
45
45
}
46
46
}
0 commit comments