Skip to content

Commit 42a84c3

Browse files
committed
[DateInterval] Fix func contains(_:) -> Bool.
Resolves #4588
1 parent 4f3c5ad commit 42a84c3

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

Sources/Foundation/DateInterval.swift

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,7 @@ public struct DateInterval : ReferenceConvertible, Comparable, Hashable {
141141

142142
/// Returns `true` if `self` contains `date`.
143143
public func contains(_ date: Date) -> Bool {
144-
let timeIntervalForGivenDate = abs(date.timeIntervalSinceReferenceDate)
145-
let timeIntervalForSelfStart = abs(start.timeIntervalSinceReferenceDate)
146-
let timeIntervalForSelfEnd = abs(end.timeIntervalSinceReferenceDate)
147-
if (timeIntervalForGivenDate >= timeIntervalForSelfStart) && (timeIntervalForGivenDate <= timeIntervalForSelfEnd) {
148-
return true
149-
}
150-
return false
144+
return (start...end).contains(date)
151145
}
152146

153147
public func hash(into hasher: inout Hasher) {

0 commit comments

Comments
 (0)