Instance Method

date:matchesComponents:

Returns whether a given date matches all of the given date components.

Declaration

- (BOOL)date:(NSDate *)date matchesComponents:(NSDateComponents *)components;

Parameters

date

The date for which to perform the calculation.

comps

The date components to match.

Return Value

YES if the given date matches the given components, otherwise NO.

Discussion

This method is useful for determining whether dates calculated by methods like nextDateAfterDate:matchingUnit:value:options: or enumerateDatesStartingAfterDate:matchingComponents:options:usingBlock: are exact, or required an adjustment due to a nonexistent time.

See Also

Extracting Components

- component:fromDate:

Returns the specified date component from a given date.

- components:fromDate:

Returns the date components representing a given date.

- components:fromDate:toDate:options:

Returns the difference between two supplied dates as date components.

- components:fromDateComponents:toDateComponents:options:

Returns the difference between start and end dates given as date components.

- componentsInTimeZone:fromDate:

Returns all the date components of a date, as if in a given time zone (instead of the receiving calendar’s time zone).

- getEra:year:month:day:fromDate:

Returns by reference the era, year, week of year, and weekday component values for a given date.

- getEra:yearForWeekOfYear:weekOfYear:weekday:fromDate:

Returns by reference the era, year, week of year, and weekday component values for a given date.

- getHour:minute:second:nanosecond:fromDate:

Returns by reference the hour, minute, second, and nanosecond component values for a given date.