Structure

NSCalendar.Unit

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

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

Constants

static var era: NSCalendar.Unit

Specifies the era unit.

static var year: NSCalendar.Unit

Specifies the year unit.

static var month: NSCalendar.Unit

Specifies the month unit.

static var day: NSCalendar.Unit

Specifies the day unit.

static var hour: NSCalendar.Unit

Specifies the hour unit.

static var minute: NSCalendar.Unit

Specifies the minute unit.

static var second: NSCalendar.Unit

Specifies the second unit.

static var weekday: NSCalendar.Unit

Specifies the weekday unit.

static var weekdayOrdinal: NSCalendar.Unit

Specifies the ordinal weekday unit.

static var quarter: NSCalendar.Unit

Specifies the quarter of the calendar.

static var weekOfMonth: NSCalendar.Unit

Specifies the original week of a month calendar unit.

static var weekOfYear: NSCalendar.Unit

Specifies the original week of the year calendar unit.

static var yearForWeekOfYear: NSCalendar.Unit

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

static var nanosecond: NSCalendar.Unit

Specifies the nanosecond unit.

static var calendar: NSCalendar.Unit

Specifies the calendar of a date components object as an NSCalendar.

static var timeZone: NSCalendar.Unit

Specifies the time zone of a date components object as an NSTimeZone.

static var NSEraCalendarUnit: NSCalendar.Unit

Specifies the era unit.

Deprecated
static var NSYearCalendarUnit: NSCalendar.Unit

Specifies the year unit.

Deprecated
static var NSMonthCalendarUnit: NSCalendar.Unit

Specifies the month unit.

Deprecated
static var NSDayCalendarUnit: NSCalendar.Unit

Specifies the day unit.

Deprecated
static var NSHourCalendarUnit: NSCalendar.Unit

Specifies the hour unit.

Deprecated
static var NSMinuteCalendarUnit: NSCalendar.Unit

Specifies the minute unit.

Deprecated
static var NSSecondCalendarUnit: NSCalendar.Unit

Specifies the second unit.

Deprecated
static var NSWeekCalendarUnit: NSCalendar.Unit

Specifies the week unit.

Deprecated
static var NSWeekdayCalendarUnit: NSCalendar.Unit

Specifies the weekday unit.

Deprecated
static var NSWeekdayOrdinalCalendarUnit: NSCalendar.Unit

Specifies the ordinal weekday unit.

Deprecated
static var NSQuarterCalendarUnit: NSCalendar.Unit

Specifies the quarter of the calendar as an kCFCalendarUnitSecond. In OS X v10.6 and earlier this was defined as equal to kCFCalendarUnitQuarter. In macOS 10.7 and later it is defined as (1 << 20).

Deprecated
static var NSWeekOfMonthCalendarUnit: NSCalendar.Unit

Specifies the original week of a month calendar unit.

Deprecated
static var NSWeekOfYearCalendarUnit: NSCalendar.Unit

Specifies the original week of the year calendar unit.

Deprecated
static var NSYearForWeekOfYearCalendarUnit: NSCalendar.Unit

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

Deprecated
static var NSCalendarCalendarUnit: NSCalendar.Unit

Specifies the calendar of the calendar.

Deprecated
static var NSTimeZoneCalendarUnit: NSCalendar.Unit

Specifies the time zone of the calendar as an NSTimeZone.

Deprecated

Relationships

Conforms To

See Also

Getting Calendar Information

var calendarIdentifier: NSCalendar.Identifier

A string representing a calendar identity.

var firstWeekday: Int

The index of the first weekday of the receiver.

var locale: Locale?

The locale of the receiver.

func maximumRange(of: NSCalendar.Unit)

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

func minimumRange(of: NSCalendar.Unit)

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

var minimumDaysInFirstWeek: Int

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

func ordinality(of: NSCalendar.Unit, in: NSCalendar.Unit, for: Date)

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).

func range(of: NSCalendar.Unit, in: NSCalendar.Unit, for: Date)

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.

func range(of: NSCalendar.Unit, start: AutoreleasingUnsafeMutablePointer<NSDate?>?, interval: UnsafeMutablePointer<TimeInterval>?, for: Date)

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

func range(ofWeekendStart: AutoreleasingUnsafeMutablePointer<NSDate?>?, interval: UnsafeMutablePointer<TimeInterval>?, containing: Date)

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.

var timeZone: TimeZone

The time zone for the receiver.