Contents

compare(_:)

Compares the receiver with the specified date interval.

Declaration

func compare(_ dateInterval: DateInterval) -> ComparisonResult

Parameters

  • dateInterval:

    The date interval with which to compare the receiver.

Return Value

Returns an ComparisonResult value that indicates the temporal ordering of the receiver and a given date interval:

Discussion

The following figure illustrates four NSDateInterval objects plotted on an arbitrary time axis. Each date interval spans its duration from left to right, from its startDate to its endDate.

[Image]

The result of comparing the date interval labeled A with the date interval labeled B is ComparisonResult.orderedAscending, because A has a startDate that occurs earlier than that of B.

The result of comparing the date interval labeled C with the date interval labeled D is ComparisonResult.orderedDescending, because because C and D have the same startDate, and C has a duration greater than that of D.

See Also

Comparing Date Intervals