File tree 1 file changed +10
-0
lines changed
1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -16,21 +16,31 @@ import Foundation
16
16
/// Follows this mathematical pattern:
17
17
/// let difference = lhs - rhs
18
18
/// rhs + difference = lhs
19
+ ///
19
20
public func - ( lhs: Date , rhs: Date ) -> DateComponents {
20
21
SwiftDate . defaultRegion. calendar. dateComponents ( DateComponents . allComponentsSet, from: rhs, to: lhs)
21
22
}
22
23
23
24
/// Adds date components to a date and returns a new date.
25
+ ///
24
26
public func + ( lhs: Date , rhs: DateComponents ) -> Date {
25
27
rhs. from ( lhs) !
26
28
}
27
29
28
30
/// Adds date components to a date and returns a new date.
31
+ ///
29
32
public func + ( lhs: DateComponents , rhs: Date ) -> Date {
30
33
( rhs + lhs)
31
34
}
32
35
36
+ /// Adds ``DateInRegion`` to a date and returns a new date.
37
+ ///
38
+ public func + ( lhs: Date , rhs: DateInRegion ) -> Date {
39
+ return ( lhs + rhs. date. dateComponents)
40
+ }
41
+
33
42
/// Subtracts date components from a date and returns a new date.
43
+ ///
34
44
public func - ( lhs: Date , rhs: DateComponents ) -> Date {
35
45
( lhs + ( - rhs) )
36
46
}
You can’t perform that action at this time.
0 commit comments