File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -16,21 +16,31 @@ import Foundation
1616/// Follows this mathematical pattern:
1717/// let difference = lhs - rhs
1818/// rhs + difference = lhs
19+ ///
1920public func - ( lhs: Date , rhs: Date ) -> DateComponents {
2021 SwiftDate . defaultRegion. calendar. dateComponents ( DateComponents . allComponentsSet, from: rhs, to: lhs)
2122}
2223
2324/// Adds date components to a date and returns a new date.
25+ ///
2426public func + ( lhs: Date , rhs: DateComponents ) -> Date {
2527 rhs. from ( lhs) !
2628}
2729
2830/// Adds date components to a date and returns a new date.
31+ ///
2932public func + ( lhs: DateComponents , rhs: Date ) -> Date {
3033 ( rhs + lhs)
3134}
3235
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+
3342/// Subtracts date components from a date and returns a new date.
43+ ///
3444public func - ( lhs: Date , rhs: DateComponents ) -> Date {
3545 ( lhs + ( - rhs) )
3646}
You can’t perform that action at this time.
0 commit comments