Instance Method

compareDate:toDate:toUnitGranularity:

Indicates the ordering of two given dates based on their components down to a given unit granularity.

Declaration

- (NSComparisonResult)compareDate:(NSDate *)date1 toDate:(NSDate *)date2 toUnitGranularity:(NSCalendarUnit)unit;

Parameters

date1

The first date to compare.

date2

The second date to compare.

unit

The smallest unit that must, along with all larger units, be equal for the given dates to be considered the same. For possible values, see NSCalendarUnit.

Return Value

NSOrderedSame if the dates are the same down to the given granularity, otherwise NSOrderedAscending or NSOrderedDescending.

See Also

Comparing Dates

- isDate:equalToDate:toUnitGranularity:

Indicates whether two dates are equal to a given unit of granularity.

- isDate:inSameDayAsDate:

Indicates whether two dates are in the same day.

- isDateInToday:

Indicates whether the given date is in “today.”

- isDateInTomorrow:

Indicates whether the given date is in “tomorrow.”

- isDateInWeekend:

Indicates whether a given date falls within a weekend period, as defined by the calendar and the calendar's locale.

- isDateInYesterday:

Indicates whether the given date is in “yesterday.”