Enumeration

NSCalendarUnit

Calendrical units such as year, month, day and hour.

Declaration

typedef enum NSCalendarUnit : NSUInteger {
    ...
} NSCalendarUnit;

Overview

Calendar units may be used as a bit mask to specify a combination of units. Values in this enumeration are equal to the corresponding constants in CFCalendarUnit.

Topics

Specifying Years and Months

NSCalendarUnitEra

Identifier for the era unit.

NSCalendarUnitYear

Identifier for the year unit.

NSCalendarUnitYearForWeekOfYear

Identifier for the week-counting year unit.

NSCalendarUnitQuarter

Identifier for the quarter of the calendar.

NSCalendarUnitMonth

Identifier for the month unit.

Specifying Weeks and Days

NSCalendarUnitWeekOfYear

Identifier for the week of the year calendar unit.

NSCalendarUnitWeekOfMonth

Identifier for the week of the month calendar unit.

NSCalendarUnitWeekday

Identifier for the weekday unit.

NSCalendarUnitWeekdayOrdinal

Identifier for the ordinal weekday unit.

NSCalendarUnitDay

Identifier for the day unit.

Specifying Hours, Minutes, and Seconds

NSCalendarUnitHour

Identifier for the hour unit.

NSCalendarUnitMinute

Identifier for the minute unit.

NSCalendarUnitSecond

Identifier for the second unit.

NSCalendarUnitNanosecond

Identifier for the nanosecond unit.

Specifying Calendars and Time Zones

NSCalendarUnitCalendar

Identifier for the calendar of a date components object.

NSCalendarUnitTimeZone

Identifier for the time zone of a date components object.

Deprecated

NSEraCalendarUnit

Specifies the era unit.

Deprecated
NSYearCalendarUnit

Specifies the year unit.

Deprecated
NSMonthCalendarUnit

Specifies the month unit.

Deprecated
NSDayCalendarUnit

Specifies the day unit.

Deprecated
NSHourCalendarUnit

Specifies the hour unit.

Deprecated
NSMinuteCalendarUnit

Specifies the minute unit.

Deprecated
NSSecondCalendarUnit

Specifies the second unit.

Deprecated
NSWeekCalendarUnit

Specifies the week unit.

Deprecated
NSWeekdayCalendarUnit

Specifies the weekday unit.

Deprecated
NSWeekdayOrdinalCalendarUnit

Specifies the ordinal weekday unit.

Deprecated
NSQuarterCalendarUnit

Specifies the quarter of the calendar as a kCFCalendarUnitSecond. In macOS 10.6 and earlier this was defined as equal to kCFCalendarUnitQuarter. In macOS 10.7 and later it is defined as (1 << 20).

Deprecated
NSWeekOfMonthCalendarUnit

Specifies the original week of a month calendar unit.

Deprecated
NSWeekOfYearCalendarUnit

Specifies the original week of the year calendar unit.

Deprecated
NSYearForWeekOfYearCalendarUnit

Specifies the year when the calendar is being interpreted as a week-based calendar.

Deprecated
NSCalendarCalendarUnit

Specifies the calendar of the calendar.

Deprecated
NSTimeZoneCalendarUnit

Specifies the time zone of the calendar as an NSTimeZone.

Deprecated

See Also

Getting Calendar Information

calendarIdentifier

An identifier for the calendar.

firstWeekday

The index of the first weekday of the receiver.

locale

The locale of the receiver.

timeZone

The time zone for the calendar.

- maximumRangeOfUnit:

Returns the maximum range limits of the values that a given unit can take on.

- minimumRangeOfUnit:

Returns the minimum range limits of the values that a given unit can take on.

minimumDaysInFirstWeek

The minimum number of days in the first week of the receiver.

- ordinalityOfUnit:inUnit:forDate:

Returns, for a given absolute time, the ordinal number of a smaller calendar unit (such as a day) within a specified larger calendar unit (such as a week).

- rangeOfUnit:inUnit:forDate:

Returns the range of absolute time values that a smaller calendar unit (such as a day) can take on in a larger calendar unit (such as a month) that includes a specified absolute time.

- rangeOfUnit:startDate:interval:forDate:

Returns by reference the starting time and duration of a given calendar unit that contains a given date.

- rangeOfWeekendStartDate:interval:containingDate:

Returns whether a given date falls within a weekend period, and if so, returns by reference the start date and time interval of the weekend range.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software