CFCalendar
Declaration
class CFCalendarOverview
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 below.
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.
Topics
Creating a Calendar
Getting Ranges of Units
CFCalendarGetRangeOfUnit(_:_:_:_:)CFCalendarGetOrdinalityOfUnit(_:_:_:_:)CFCalendarGetTimeRangeOfUnit(_:_:_:_:_:)CFCalendarGetMaximumRangeOfUnit(_:_:)CFCalendarGetMinimumRangeOfUnit(_:_:)
Getting and Setting the Time Zone
Getting the Identifier
Getting and Setting the Locale
Getting and Setting Day Information
CFCalendarGetFirstWeekday(_:)CFCalendarSetFirstWeekday(_:_:)CFCalendarGetMinimumDaysInFirstWeek(_:)CFCalendarSetMinimumDaysInFirstWeek(_:_:)
Getting the Type ID
Constants
See Also
Related Documentation
- Date and Time Programming Guide for Core Foundation
- Internationalization and Localization Guide