iOS Developer Library

Developer

CoreFoundation Framework Reference CFCalendar Reference

Options
Deployment Target:

On This Page
Language:

CFCalendar Reference

Inheritance


Not Applicable

Conforms To


Not Applicable

Import Statement


Swift

import CoreFoundation

Objective-C

@import CoreFoundation;

The CFCalendar opaque type represents a calendar system. The associated API provides information about a calendar and supports calendrical computations such as determining the range of a given calendrical unit and adding units to a given absolute time.

CFAbsoluteTime is the operational lingua franca of CFCalendar—to do calendar arithmetic, you start and end with an absolute time; to convert between a decomposed date in one calendar and another calendar, you first convert to an absolute time. CFAbsoluteTime provides the absolute scale and epoch for dates and times, which can then be rendered into a particular calendar, for calendrical computations or user display.

In a calendar, day, week, weekday, month, and year numbers are generally 1-based, but there may be calendar-specific exceptions. Ordinal numbers, where they occur, are 1-based. Some calendars represented by this API may have to map their basic unit concepts into year/month/week/day/… nomenclature. For example, a calendar composed of 4 quarters in a year instead of 12 months uses the “month” unit to represent quarters. The particular values of the unit are defined by each calendar, and are not necessarily “consistent with” or have a “correspondence with,” values for that unit in another calendar.

Several CFCalendar functions (CFCalendarComposeAbsoluteTime, CFCalendarDecomposeAbsoluteTime, CFCalendarAddComponents, and CFCalendarGetComponentDifference) take a description string that describes the calendrical components provided in a varargs parameter area. You can provide as many components as you need (or choose to), in whatever order you choose. When there is incomplete information to compute an absolute time, default values similar to 0 and 1 are usually chosen by a calendar, but this is a calendar-specific choice. If you provide inconsistent information, calendar-specific disambiguation is performed (which may involve ignoring one or more of the parameters). The characters of the description string specify the units and order of the parameters which follow. The characters are adopted from the corresponding format characters used by CFDateFormatter when possible, as shown in Table 1.

Table 1Calendrical components parameter descriptors

Symbol

Meaning

Value Type

y

year

int

M

month

int

d

day

int

H

hour

int

m

minute

int

s

second

int

Information related to formatting dates and times and name-related calendar information is managed by CFDateFormatter.

CFCalendar is subject to some limitations. There is no leap second handling—the existence of leap seconds is ignored as in the other CoreFoundation API. In general, historical accuracy of calendars is not guaranteed. There is currently no API for defining your own calendars.

CFCalendar is “toll-free bridged” with its Cocoa Foundation counterpart, NSCalendar. This means that the Core Foundation type is interchangeable in function or method calls with the bridged Foundation object. Therefore, in a method where you see an NSCalendar * parameter, you can pass in a CFCalendarRef, and in a function where you see a CFCalendarRef parameter, you can pass in an NSCalendar instance. See Toll-Free Bridged Types for more information on toll-free bridging.

Functions

  • Returns a copy of the logical calendar for the current user.

    Declaration

    Swift

    func CFCalendarCopyCurrent() -> CFCalendar!

    Objective-C

    CFCalendarRef CFCalendarCopyCurrent ( void );

    Return Value

    The logical calendar for the current user that is formed from the settings for the current user’s chosen system locale overlaid with any custom settings the user has specified in System Preferences. This function may return a retained cached object, not a new object. Ownership follows the Create Rule.

    Discussion

    Settings you get from this calendar do not change if user defaults change so that your operations are consistent.

    Typically you perform some operations on the returned object and then release it. The returned object may be cached, so you do not need to hold on to it indefinitely.

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later.

  • Returns a calendar object for the calendar identified by a calendar identifier.

    Declaration

    Swift

    func CFCalendarCreateWithIdentifier(_ alloc: CFAllocator!, _ ident: CFString!) -> CFCalendar!

    Objective-C

    CFCalendarRef CFCalendarCreateWithIdentifier ( CFAllocatorRef allocator, CFStringRef identifier );

    Parameters

    alloc

    The allocator to use to allocate memory for the new object. Pass NULL or kCFAllocatorDefault to use the current default allocator.

    ident

    A calendar identifier. Calendar identifier constants are given in CFLocaleRef.

    Return Value

    A calendar object for the calendar identified by ident. If the identifier is unknown (if, for example, it is either an unrecognized string, or the calendar is not supported by the current version of the operating system), returns NULL. Ownership follows the Create Rule.

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later.

  • Computes the absolute time when specified components are added to a given absolute time.

    Declaration

    Objective-C

    Boolean CFCalendarAddComponents ( CFCalendarRef calendar, CFAbsoluteTime *at, CFOptionFlags options, const char *componentDesc, ... );

    Parameters

    calendar

    The calendar to use for the computation.

    at

    A reference to an absolute time. On input, points to the absolute time to which components are to be added; on output, points to the result of the computation.

    options

    Options for the calculation. For valid values, see Constants.

    componentDesc

    A string that describes the components provided in the vararg parameters.

    ...

    Vararg parameters giving amounts of each calendrical component in the order specified by componentDesc. The amounts to add may be negative, zero, positive, or any combination thereof.

    Return Value

    TRUE—and in at the computed time—if at falls inside the defined range of the calendar and it is possible to calculate the absolute time when the components (the calendrical components specified by componentDesc and given in the varargs) are added to the input absolute time at; otherwise FALSE.

    Discussion

    Some operations can be ambiguous, and the behavior of the computation is calendar-specific, but generally components are added in the order specified.

    If you specify a “wrap” option (kCFCalendarComponentsWrap), the specified components should be incremented and wrap around to zero/one on overflow, but should not cause higher units to be incremented. When “Wrap” is false, overflow in a unit carries into the higher units, as in typical addition.

    Note that some computations can take a relatively long time to perform.

    The following example shows how to add 2 months and 3 days to absolute time at‘s current value using an existing calendar (gregorian):

    • CFCalendarAddComponents(gregorian, &at, 0, "Md", 2, 3);

    Import Statement

    Objective-C

    @import CoreFoundation;

    Availability

    Available in iOS 2.0 and later.

  • Computes the absolute time from components in a description string.

    Declaration

    Objective-C

    Boolean CFCalendarComposeAbsoluteTime ( CFCalendarRef calendar, CFAbsoluteTime *at, const char *componentDesc, ... );

    Parameters

    calendar

    The calendar to use for the computation.

    at

    Upon return, contains the computed absolute time.

    componentDesc

    A string that describes the components provided in the vararg parameters.

    ...

    Vararg parameters giving amounts of each calendrical component in the order specified by componentDesc. The amounts to add may be negative, zero, positive, or any combination thereof.

    Return Value

    TRUE—and in at the absolute time computed from the given components—if the componentDesc description string can be converted into an absolute time, otherwise FALSE. Also returns FALSE for out-of-range values.

    Discussion

    When there are insufficient components provided to completely specify an absolute time, a calendar uses default values of its choice. When there is inconsistent information, a calendar may ignore some of the parameters or the function may return FALSE. Unnecessary components are ignored (for example, Day takes precedence over Weekday + Weekday ordinal). Note that some computations can take a relatively long time to perform.

    The following example shows how to use this function to initialize an absolute time, at, to 6 January 1965 14:10:00, for a given calendar gregorian .

    • CFCalendarComposeAbsoluteTime(gregorian, &at, "yMdHms", 1965, 1, 6, 14, 10, 00);

    Import Statement

    Objective-C

    @import CoreFoundation;

    Availability

    Available in iOS 2.0 and later.

  • Computes the components which are indicated by the componentDesc description string for the given absolute time.

    Declaration

    Objective-C

    Boolean CFCalendarDecomposeAbsoluteTime ( CFCalendarRef calendar, CFAbsoluteTime at, const char *componentDesc, ... );

    Parameters

    calendar

    The calendar to use for the computation.

    at

    An absolute time.

    componentDesc

    A string that describes the components provided in the vararg parameters.

    ...

    Vararg pointers to storage for each of the desired components. On successful return, the pointers are filled with values of the corresponding components. The type of all units is int.

    Return Value

    TRUE if the function is able to compute the components indicated by the componentDesc description string for the given absolute time, and fills the values to the components given in the varargs. Returns FALSE if the absolute time falls outside the defined range of the calendar, or the computation cannot be performed.

    Discussion

    The Weekday ordinality, when requested, refers to the next larger (than Week) of the requested units. Some computations can take a relatively long time to perform.

    The following example shows how to use this function to determine the current year, month, and day, using an existing calendar (gregorian):

    • CFCalendarDecomposeAbsoluteTime(gregorian, CFAbsoluteTimeGetCurrent(), "yMd", &year, &month, &day);

    Import Statement

    Objective-C

    @import CoreFoundation;

    Availability

    Available in iOS 2.0 and later.

  • Computes the difference between the two absolute times, in terms of specified calendrical components.

    Declaration

    Objective-C

    Boolean CFCalendarGetComponentDifference ( CFCalendarRef calendar, CFAbsoluteTime startingAT, CFAbsoluteTime resultAT, CFOptionFlags options, const char *componentDesc, ... );

    Parameters

    calendar

    The calendar to use for the computation.

    startingAT

    The starting absolute time.

    resultAT

    The result absolute time.

    options

    Options for the calculation. For valid values, see Constants.

    componentDesc

    A string that describes the components provided in the vararg parameters.

    ...

    Vararg pointers to storage for each of the desired components. On successful return, the pointers are filled with values of the corresponding components. The type of all units is int.

    Return Value

    TRUE—and in the varargs the differences—if it is possible to calculate the difference (result - starting) between resultAT and startingAT in terms of the calendrical components specified by componentDesc. Returns FALSE if either absolute time falls outside the defined range of the calendar, or the computation cannot be performed.

    Discussion

    The result is lossy if there isn’t a small enough unit requested to hold the full precision of the difference. Some operations can be ambiguous, and the behavior of the computation is calendar-specific, but generally larger components will be computed before smaller components; for example, in the Gregorian calendar a result might be 1 month and 5 days, instead of, for example, 0 months and 35 days. The resulting component values may be negative if later is before earlier.

    This computation is roughly the inverse of the CFCalendarAddComponents operation, but calendrical arithmetic is invertible only in simple cases. This computation tends to be several times more expensive than the Add operation.

    The following example shows how to get the approximate number of days between two absolute times (at1, at2) using an existing calendar (gregorian):

    • CFCalendarGetComponentDifference(gregorian, at1, at2, 0, "d", &days);

    Import Statement

    Objective-C

    @import CoreFoundation;

    Availability

    Available in iOS 2.0 and later.

  • Returns the range of values that one unit can take on within a larger unit during which a specific absolute time occurs.

    Declaration

    Swift

    func CFCalendarGetRangeOfUnit(_ calendar: CFCalendar!, _ smallerUnit: CFCalendarUnit, _ biggerUnit: CFCalendarUnit, _ at: CFAbsoluteTime) -> CFRange

    Objective-C

    CFRange CFCalendarGetRangeOfUnit ( CFCalendarRef calendar, CFCalendarUnit smallerUnit, CFCalendarUnit biggerUnit, CFAbsoluteTime at );

    Parameters

    calendar

    The calendar to examine.

    smallerUnit

    A calendar unit. For valid values see CFCalendarUnit.

    biggerUnit

    A calendar unit. For valid values see CFCalendarUnit.

    at

    An absolute time.

    Return Value

    The range of values that the calendar unit specified by smallerUnit can take on within the calendar unit specified by biggerUnit that includes the absolute time at. For example, the range the Day unit can take on in the Month in which the absolute time lies.

    If biggerUnit is not logically bigger than smallerUnit in the calendar, or the given combination of units does not make sense (or is a computation which is undefined), the result is {kCFNotFound, kCFNotFound}.

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later.

  • Returns the ordinal number of a calendrical unit within a larger unit at a specified absolute time.

    Declaration

    Swift

    func CFCalendarGetOrdinalityOfUnit(_ calendar: CFCalendar!, _ smallerUnit: CFCalendarUnit, _ biggerUnit: CFCalendarUnit, _ at: CFAbsoluteTime) -> CFIndex

    Objective-C

    CFIndex CFCalendarGetOrdinalityOfUnit ( CFCalendarRef calendar, CFCalendarUnit smallerUnit, CFCalendarUnit biggerUnit, CFAbsoluteTime at );

    Parameters

    calendar

    The calendar to examine.

    smallerUnit

    A calendar unit. For valid values see CFCalendarUnit.

    biggerUnit

    A calendar unit. For valid values see CFCalendarUnit.

    at

    An absolute time.

    Return Value

    The ordinal number of the calendar unit specified by smallerUnit within the calendar unit specified by biggerUnit at the absolute time at. For example, the time 00:45 is in the first hour of the day, and for units Hour and Day respectively, the result would be 1.

    If the biggerUnit parameter is not logically bigger than the smallerUnit parameter in the calendar, or the given combination of units does not make sense (or is a computation which is undefined), the result is kCFNotFound.

    Discussion

    The ordinality is in most cases not the same as the decomposed value of the unit. Typically return values are 1 and greater; an exception is the week-in-month calculation, which returns 0 for days before the first week in the month containing the date. Note that some computations can take a relatively long time to perform.

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later.

  • Returns by reference the start time and duration of a given calendar unit that contains a given absolute time.

    Declaration

    Swift

    func CFCalendarGetTimeRangeOfUnit(_ calendar: CFCalendar!, _ unit: CFCalendarUnit, _ at: CFAbsoluteTime, _ startp: UnsafeMutablePointer<CFAbsoluteTime>, _ tip: UnsafeMutablePointer<CFTimeInterval>) -> Boolean

    Objective-C

    Boolean CFCalendarGetTimeRangeOfUnit ( CFCalendarRef calendar, CFCalendarUnit unit, CFAbsoluteTime at, CFAbsoluteTime *startp, CFTimeInterval *tip );

    Parameters

    calendar

    The calendar to examine.

    unit

    A calendar unit (for valid values, see CFCalendarUnit).

    at

    An absolute time.

    startp

    Upon return, contains the beginning of the calendar unit specified by unit that contains the time at.

    tip

    Upon return, contains the duration of the calendar unit specified by unit that contains the time at.

    Return Value

    true if the values of startp and tip could be calculated, otherwise false.

    Discussion

    The function may fail if, for example, you try to get the range of a kCFCalendarUnitWeekday and specify a time (at) that is during a weekend.

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later.

  • Returns the maximum range limits of the values that a specified unit can take on in a given calendar.

    Declaration

    Swift

    func CFCalendarGetMaximumRangeOfUnit(_ calendar: CFCalendar!, _ unit: CFCalendarUnit) -> CFRange

    Objective-C

    CFRange CFCalendarGetMaximumRangeOfUnit ( CFCalendarRef calendar, CFCalendarUnit unit );

    Parameters

    calendar

    The calendar to examine.

    unit

    A calendar unit. For valid values see CFCalendarUnit.

    Return Value

    The maximum range limits of the values that the specified unit can take on in calendar. For example, in the Gregorian calendar the maximum ranges for the Day unit is 1-31.

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later.

  • Returns the minimum range limits of the values that a specified unit can take on in a given calendar.

    Declaration

    Swift

    func CFCalendarGetMinimumRangeOfUnit(_ calendar: CFCalendar!, _ unit: CFCalendarUnit) -> CFRange

    Objective-C

    CFRange CFCalendarGetMinimumRangeOfUnit ( CFCalendarRef calendar, CFCalendarUnit unit );

    Parameters

    calendar

    The calendar to examine.

    unit

    A calendar unit. For valid values see CFCalendarUnit.

    Return Value

    The minimum range limits of the values that the specified unit can take on in calendar. For example, in the Gregorian calendar the minimum ranges for the Day unit is 1-28.

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later.

  • Returns a time zone object for a specified calendar.

    Declaration

    Swift

    func CFCalendarCopyTimeZone(_ calendar: CFCalendar!) -> CFTimeZone!

    Objective-C

    CFTimeZoneRef CFCalendarCopyTimeZone ( CFCalendarRef calendar );

    Parameters

    calendar

    The calendar to examine.

    Return Value

    A copy of the time zone object for the specified calendar. Ownership follows the Create Rule.

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later.

  • Sets the time zone for a calendar.

    Declaration

    Swift

    func CFCalendarSetTimeZone(_ calendar: CFCalendar!, _ locale: CFTimeZone!)

    Objective-C

    void CFCalendarSetTimeZone ( CFCalendarRef calendar, CFTimeZoneRef tz );

    Parameters

    calendar

    The calendar to modify.

    locale

    The time zone to set for calendar.

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later.

  • Returns the given calendar’s identifier.

    Declaration

    Swift

    func CFCalendarGetIdentifier(_ calendar: CFCalendar!) -> CFString!

    Objective-C

    CFStringRef CFCalendarGetIdentifier ( CFCalendarRef calendar );

    Parameters

    calendar

    The calendar to examine.

    Return Value

    A string representation of calendar’s identifier. Calendar identifier constants can be found in CFLocaleRef. Ownership follows the Get Rule.

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later.

  • Returns a locale object for a specified calendar.

    Declaration

    Swift

    func CFCalendarCopyLocale(_ calendar: CFCalendar!) -> CFLocale!

    Objective-C

    CFLocaleRef CFCalendarCopyLocale ( CFCalendarRef calendar );

    Parameters

    calendar

    The calendar to examine.

    Return Value

    A copy of the locale object for the specified calendar. Ownership follows the Create Rule.

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later.

  • Sets the locale for a calendar.

    Declaration

    Swift

    func CFCalendarSetLocale(_ calendar: CFCalendar!, _ locale: CFLocale!)

    Objective-C

    void CFCalendarSetLocale ( CFCalendarRef calendar, CFLocaleRef locale );

    Parameters

    calendar

    The calendar to modify.

    locale

    The locale to set for calendar.

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later.

  • Returns the index of first weekday for a specified calendar.

    Declaration

    Swift

    func CFCalendarGetFirstWeekday(_ calendar: CFCalendar!) -> CFIndex

    Objective-C

    CFIndex CFCalendarGetFirstWeekday ( CFCalendarRef calendar );

    Parameters

    calendar

    The calendar to examine.

    Return Value

    The index of the first weekday of the specified calendar.

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later.

  • Sets the first weekday for a calendar.

    Declaration

    Swift

    func CFCalendarSetFirstWeekday(_ calendar: CFCalendar!, _ wkdy: CFIndex)

    Objective-C

    void CFCalendarSetFirstWeekday ( CFCalendarRef calendar, CFIndex wkdy );

    Parameters

    calendar

    The calendar to modify.

    wkdy

    The index to set for the first weekday of calendar.

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later.

  • Returns the minimum number of days in the first week of a specified calendar.

    Declaration

    Swift

    func CFCalendarGetMinimumDaysInFirstWeek(_ calendar: CFCalendar!) -> CFIndex

    Objective-C

    CFIndex CFCalendarGetMinimumDaysInFirstWeek ( CFCalendarRef calendar );

    Parameters

    calendar

    The calendar to examine.

    Return Value

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

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later.

  • Sets the minimum number of days in the first week of a specified calendar.

    Declaration

    Swift

    func CFCalendarSetMinimumDaysInFirstWeek(_ calendar: CFCalendar!, _ mwd: CFIndex)

    Objective-C

    void CFCalendarSetMinimumDaysInFirstWeek ( CFCalendarRef calendar, CFIndex mwd );

    Parameters

    calendar

    The calendar to modify.

    mwd

    The number to set as the minimum number of days in the first week of calendar.

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later.

  • Returns the type identifier for the CFCalendar opaque type.

    Declaration

    Swift

    func CFCalendarGetTypeID() -> CFTypeID

    Objective-C

    CFTypeID CFCalendarGetTypeID ( void );

    Return Value

    The type identifier for the CFCalendar opaque type.

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later.

Data Types

Miscellaneous

  • A reference to a CFCalendar object.

    Declaration

    Swift

    typealias CFCalendarRef = CFCalendar

    Objective-C

    typedef const struct __CFCalendar *CFCalendarRef;

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later.

Constants

Miscellaneous

  • CFCalendarUnit constants are used to specify calendrical units, such as day or month, in various calendar calculations.

    Declaration

    Swift

    struct CFCalendarUnit : RawOptionSetType { init(_ rawValue: CFOptionFlags) init(rawValue rawValue: CFOptionFlags) static var Era: CFCalendarUnit { get } static var Year: CFCalendarUnit { get } static var Month: CFCalendarUnit { get } static var Day: CFCalendarUnit { get } static var Hour: CFCalendarUnit { get } static var Minute: CFCalendarUnit { get } static var Second: CFCalendarUnit { get } static var Week: CFCalendarUnit { get } static var Weekday: CFCalendarUnit { get } static var WeekdayOrdinal: CFCalendarUnit { get } static var Quarter: CFCalendarUnit { get } static var WeekOfMonth: CFCalendarUnit { get } static var WeekOfYear: CFCalendarUnit { get } static var YearForWeekOfYear: CFCalendarUnit { get } }

    Objective-C

    typedef enum { kCFCalendarUnitEra = (1 << 1), kCFCalendarUnitYear = (1 << 2), kCFCalendarUnitMonth = (1 << 3), kCFCalendarUnitDay = (1 << 4), kCFCalendarUnitHour = (1 << 5), kCFCalendarUnitMinute = (1 << 6), kCFCalendarUnitSecond = (1 << 7), kCFCalendarUnitWeek = (1 << 8), kCFCalendarUnitWeekday = (1 << 9), kCFCalendarUnitWeekdayOrdinal = (1 << 10), kCFCalendarUnitQuarter = (1UL << 11), kCFCalendarUnitWeekOfMonth = (1UL << 12), kCFCalendarUnitWeekOfYear = (1UL << 13), kCFCalendarUnitYearForWeekOfYear = (1UL << 14), } CFCalendarUnit;

    Constants

    • Era

      kCFCalendarUnitEra

      Specifies the era unit.

      Available in iOS 2.0 and later.

    • Year

      kCFCalendarUnitYear

      Specifies the year unit.

      Available in iOS 2.0 and later.

    • Month

      kCFCalendarUnitMonth

      Specifies the month unit.

      Available in iOS 2.0 and later.

    • Day

      kCFCalendarUnitDay

      Specifies the day unit.

      Available in iOS 2.0 and later.

    • Hour

      kCFCalendarUnitHour

      Specifies the hour unit.

      Available in iOS 2.0 and later.

    • Minute

      kCFCalendarUnitMinute

      Specifies the minute unit.

      Available in iOS 2.0 and later.

    • Second

      kCFCalendarUnitSecond

      Specifies the second unit.

      Available in iOS 2.0 and later.

    • Week

      kCFCalendarUnitWeek

      Specifies the week unit.

      Available in iOS 2.0 and later.

      Deprecated in iOS 8.0.

    • Weekday

      kCFCalendarUnitWeekday

      Specifies the weekday unit.

      The weekday units are the numbers 1-N (where for the Gregorian calendar N=7 and 1 is Sunday).

      Available in iOS 2.0 and later.

    • WeekdayOrdinal

      kCFCalendarUnitWeekdayOrdinal

      Specifies the ordinal weekday unit.

      The weekday ordinal unit describes ordinal position within the month unit of the corresponding weekday unit. For example, in the Gregorian calendar a weekday ordinal unit of 2 for a weekday unit 3 indicates "the second Tuesday in the month".

      Available in iOS 2.0 and later.

    • Quarter

      kCFCalendarUnitQuarter

      Specifies the quarter-year unit.

      Available in iOS 4.0 and later.

    • WeekOfMonth

      kCFCalendarUnitWeekOfMonth

      Specifies the original week of a month calendar unit.

      Available in iOS 5.0 and later.

    • WeekOfYear

      kCFCalendarUnitWeekOfYear

      Specifies the original week of the year calendar unit.

      Available in iOS 5.0 and later.

    • YearForWeekOfYear

      kCFCalendarUnitYearForWeekOfYear

      Specifies the relative year for a week within a year calendar unit.

      Available in iOS 5.0 and later.

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later.

  • The wrapping option specifies overflow behavior for calendar components in calendrical calculations—see CFCalendarAddComponents and CFCalendarGetComponentDifference.

    Declaration

    Swift

    var kCFCalendarComponentsWrap: Int { get }

    Objective-C

    enum { kCFCalendarComponentsWrap = (1 << 0) }

    Constants

    • kCFCalendarComponentsWrap

      kCFCalendarComponentsWrap

      Specifies that the components specified for calendar components should be incremented and wrap around to zero/one on overflow, but should not cause higher units to be incremented.

      Available in iOS 2.0 and later.