compare(_:)
Indicates the temporal ordering of the receiver and another given date.
Declaration
func compare(_ other: Date) -> ComparisonResultParameters
- other:
The date with which to compare the receiver.
This value must not be
nil. If the value isnil, the behavior is undefined and may change in future versions of macOS.
Return Value
If:
The receiver and
anotherDateare exactly equal to each other, ComparisonResult.orderedSameThe receiver is later in time than
anotherDate, ComparisonResult.orderedDescendingThe receiver is earlier in time than
anotherDate, ComparisonResult.orderedAscending.
Discussion
This method detects sub-second differences between dates. If you want to compare dates with a less fine granularity, use timeIntervalSince(_:) to compare the two dates.