]> git.saurik.com Git - apple/cf.git/blob - CFCalendar.h
CF-635.15.tar.gz
[apple/cf.git] / CFCalendar.h
1 /*
2 * Copyright (c) 2011 Apple Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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
11 * file.
12 *
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.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24 /* CFCalendar.h
25 Copyright (c) 2004-2011, Apple Inc. All rights reserved.
26 */
27
28 #if !defined(__COREFOUNDATION_CFCALENDAR__)
29 #define __COREFOUNDATION_CFCALENDAR__ 1
30
31 #include <CoreFoundation/CFBase.h>
32 #include <CoreFoundation/CFLocale.h>
33 #include <CoreFoundation/CFDate.h>
34 #include <CoreFoundation/CFTimeZone.h>
35
36 CF_EXTERN_C_BEGIN
37
38 typedef struct __CFCalendar * CFCalendarRef;
39
40 CF_EXPORT
41 CFTypeID CFCalendarGetTypeID(void);
42
43 CF_EXPORT
44 CFCalendarRef CFCalendarCopyCurrent(void);
45
46 CF_EXPORT
47 CFCalendarRef CFCalendarCreateWithIdentifier(CFAllocatorRef allocator, CFStringRef identifier);
48 // Create a calendar. The identifiers are the kCF*Calendar
49 // constants in CFLocale.h.
50
51 CF_EXPORT
52 CFStringRef CFCalendarGetIdentifier(CFCalendarRef calendar);
53 // Returns the calendar's identifier.
54
55 CF_EXPORT
56 CFLocaleRef CFCalendarCopyLocale(CFCalendarRef calendar);
57
58 CF_EXPORT
59 void CFCalendarSetLocale(CFCalendarRef calendar, CFLocaleRef locale);
60
61 CF_EXPORT
62 CFTimeZoneRef CFCalendarCopyTimeZone(CFCalendarRef calendar);
63
64 CF_EXPORT
65 void CFCalendarSetTimeZone(CFCalendarRef calendar, CFTimeZoneRef tz);
66
67 CF_EXPORT
68 CFIndex CFCalendarGetFirstWeekday(CFCalendarRef calendar);
69
70 CF_EXPORT
71 void CFCalendarSetFirstWeekday(CFCalendarRef calendar, CFIndex wkdy);
72
73 CF_EXPORT
74 CFIndex CFCalendarGetMinimumDaysInFirstWeek(CFCalendarRef calendar);
75
76 CF_EXPORT
77 void CFCalendarSetMinimumDaysInFirstWeek(CFCalendarRef calendar, CFIndex mwd);
78
79
80 enum {
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),
93 #endif
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),
98 #endif
99 };
100 typedef CFOptionFlags CFCalendarUnit;
101
102 CF_EXPORT
103 CFRange CFCalendarGetMinimumRangeOfUnit(CFCalendarRef calendar, CFCalendarUnit unit);
104
105 CF_EXPORT
106 CFRange CFCalendarGetMaximumRangeOfUnit(CFCalendarRef calendar, CFCalendarUnit unit);
107
108 CF_EXPORT
109 CFRange CFCalendarGetRangeOfUnit(CFCalendarRef calendar, CFCalendarUnit smallerUnit, CFCalendarUnit biggerUnit, CFAbsoluteTime at);
110
111 CF_EXPORT
112 CFIndex CFCalendarGetOrdinalityOfUnit(CFCalendarRef calendar, CFCalendarUnit smallerUnit, CFCalendarUnit biggerUnit, CFAbsoluteTime at);
113
114 CF_EXPORT
115 Boolean CFCalendarGetTimeRangeOfUnit(CFCalendarRef calendar, CFCalendarUnit unit, CFAbsoluteTime at, CFAbsoluteTime *startp, CFTimeInterval *tip) CF_AVAILABLE(10_5, 2_0);
116
117 CF_EXPORT
118 Boolean CFCalendarComposeAbsoluteTime(CFCalendarRef calendar, /* out */ CFAbsoluteTime *at, const char *componentDesc, ...);
119
120 CF_EXPORT
121 Boolean CFCalendarDecomposeAbsoluteTime(CFCalendarRef calendar, CFAbsoluteTime at, const char *componentDesc, ...);
122
123
124 enum {
125 kCFCalendarComponentsWrap = (1UL << 0) // option for adding
126 };
127
128 CF_EXPORT
129 Boolean CFCalendarAddComponents(CFCalendarRef calendar, /* inout */ CFAbsoluteTime *at, CFOptionFlags options, const char *componentDesc, ...);
130
131 CF_EXPORT
132 Boolean CFCalendarGetComponentDifference(CFCalendarRef calendar, CFAbsoluteTime startingAT, CFAbsoluteTime resultAT, CFOptionFlags options, const char *componentDesc, ...);
133
134
135 CF_EXTERN_C_END
136
137 #endif /* ! __COREFOUNDATION_CFCALENDAR__ */
138