2 * Copyright (c) 2011 Apple Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
25 Copyright (c) 2004-2011, Apple Inc. All rights reserved.
28 #if !defined(__COREFOUNDATION_CFCALENDAR__)
29 #define __COREFOUNDATION_CFCALENDAR__ 1
31 #include <CoreFoundation/CFBase.h>
32 #include <CoreFoundation/CFLocale.h>
33 #include <CoreFoundation/CFDate.h>
34 #include <CoreFoundation/CFTimeZone.h>
38 typedef struct __CFCalendar
* CFCalendarRef
;
41 CFTypeID
CFCalendarGetTypeID(void);
44 CFCalendarRef
CFCalendarCopyCurrent(void);
47 CFCalendarRef
CFCalendarCreateWithIdentifier(CFAllocatorRef allocator
, CFStringRef identifier
);
48 // Create a calendar. The identifiers are the kCF*Calendar
49 // constants in CFLocale.h.
52 CFStringRef
CFCalendarGetIdentifier(CFCalendarRef calendar
);
53 // Returns the calendar's identifier.
56 CFLocaleRef
CFCalendarCopyLocale(CFCalendarRef calendar
);
59 void CFCalendarSetLocale(CFCalendarRef calendar
, CFLocaleRef locale
);
62 CFTimeZoneRef
CFCalendarCopyTimeZone(CFCalendarRef calendar
);
65 void CFCalendarSetTimeZone(CFCalendarRef calendar
, CFTimeZoneRef tz
);
68 CFIndex
CFCalendarGetFirstWeekday(CFCalendarRef calendar
);
71 void CFCalendarSetFirstWeekday(CFCalendarRef calendar
, CFIndex wkdy
);
74 CFIndex
CFCalendarGetMinimumDaysInFirstWeek(CFCalendarRef calendar
);
77 void CFCalendarSetMinimumDaysInFirstWeek(CFCalendarRef calendar
, CFIndex mwd
);
81 kCFCalendarUnitEra
= (1UL << 1),
82 kCFCalendarUnitYear
= (1UL << 2),
83 kCFCalendarUnitMonth
= (1UL << 3),
84 kCFCalendarUnitDay
= (1UL << 4),
85 kCFCalendarUnitHour
= (1UL << 5),
86 kCFCalendarUnitMinute
= (1UL << 6),
87 kCFCalendarUnitSecond
= (1UL << 7),
88 kCFCalendarUnitWeek
= (1UL << 8) /* CF_DEPRECATED(10_4, 10_7, 2_0, 5_0) */,
89 kCFCalendarUnitWeekday
= (1UL << 9),
90 kCFCalendarUnitWeekdayOrdinal
= (1UL << 10),
91 #if MAC_OS_X_VERSION_10_6 <= MAC_OS_X_VERSION_MAX_ALLOWED || __IPHONE_4_0 <= __IPHONE_OS_VERSION_MAX_ALLOWED
92 kCFCalendarUnitQuarter
= (1UL << 11),
94 #if MAC_OS_X_VERSION_10_7 <= MAC_OS_X_VERSION_MAX_ALLOWED || __IPHONE_5_0 <= __IPHONE_OS_VERSION_MAX_ALLOWED
95 kCFCalendarUnitWeekOfMonth
= (1UL << 12),
96 kCFCalendarUnitWeekOfYear
= (1UL << 13),
97 kCFCalendarUnitYearForWeekOfYear
= (1UL << 14),
100 typedef CFOptionFlags CFCalendarUnit
;
103 CFRange
CFCalendarGetMinimumRangeOfUnit(CFCalendarRef calendar
, CFCalendarUnit unit
);
106 CFRange
CFCalendarGetMaximumRangeOfUnit(CFCalendarRef calendar
, CFCalendarUnit unit
);
109 CFRange
CFCalendarGetRangeOfUnit(CFCalendarRef calendar
, CFCalendarUnit smallerUnit
, CFCalendarUnit biggerUnit
, CFAbsoluteTime at
);
112 CFIndex
CFCalendarGetOrdinalityOfUnit(CFCalendarRef calendar
, CFCalendarUnit smallerUnit
, CFCalendarUnit biggerUnit
, CFAbsoluteTime at
);
115 Boolean
CFCalendarGetTimeRangeOfUnit(CFCalendarRef calendar
, CFCalendarUnit unit
, CFAbsoluteTime at
, CFAbsoluteTime
*startp
, CFTimeInterval
*tip
) CF_AVAILABLE(10_5
, 2_0
);
118 Boolean
CFCalendarComposeAbsoluteTime(CFCalendarRef calendar
, /* out */ CFAbsoluteTime
*at
, const char *componentDesc
, ...);
121 Boolean
CFCalendarDecomposeAbsoluteTime(CFCalendarRef calendar
, CFAbsoluteTime at
, const char *componentDesc
, ...);
125 kCFCalendarComponentsWrap
= (1UL << 0) // option for adding
129 Boolean
CFCalendarAddComponents(CFCalendarRef calendar
, /* inout */ CFAbsoluteTime
*at
, CFOptionFlags options
, const char *componentDesc
, ...);
132 Boolean
CFCalendarGetComponentDifference(CFCalendarRef calendar
, CFAbsoluteTime startingAT
, CFAbsoluteTime resultAT
, CFOptionFlags options
, const char *componentDesc
, ...);
137 #endif /* ! __COREFOUNDATION_CFCALENDAR__ */