]> git.saurik.com Git - apple/cf.git/blob - CFCalendar.h
433c41599a87a618ce6fcc8a9e84a2709aa3d7b7
[apple/cf.git] / CFCalendar.h
1 /*
2 * Copyright (c) 2014 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-2013, 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_IMPLICIT_BRIDGING_ENABLED
37 CF_EXTERN_C_BEGIN
38
39 typedef struct __CFCalendar * CFCalendarRef;
40
41 CF_EXPORT
42 CFTypeID CFCalendarGetTypeID(void);
43
44 CF_EXPORT
45 CFCalendarRef CFCalendarCopyCurrent(void);
46
47 CF_EXPORT
48 CFCalendarRef CFCalendarCreateWithIdentifier(CFAllocatorRef allocator, CFStringRef identifier);
49 // Create a calendar. The identifiers are the kCF*Calendar
50 // constants in CFLocale.h.
51
52 CF_EXPORT
53 CFStringRef CFCalendarGetIdentifier(CFCalendarRef calendar);
54 // Returns the calendar's identifier.
55
56 CF_EXPORT
57 CFLocaleRef CFCalendarCopyLocale(CFCalendarRef calendar);
58
59 CF_EXPORT
60 void CFCalendarSetLocale(CFCalendarRef calendar, CFLocaleRef locale);
61
62 CF_EXPORT
63 CFTimeZoneRef CFCalendarCopyTimeZone(CFCalendarRef calendar);
64
65 CF_EXPORT
66 void CFCalendarSetTimeZone(CFCalendarRef calendar, CFTimeZoneRef tz);
67
68 CF_EXPORT
69 CFIndex CFCalendarGetFirstWeekday(CFCalendarRef calendar);
70
71 CF_EXPORT
72 void CFCalendarSetFirstWeekday(CFCalendarRef calendar, CFIndex wkdy);
73
74 CF_EXPORT
75 CFIndex CFCalendarGetMinimumDaysInFirstWeek(CFCalendarRef calendar);
76
77 CF_EXPORT
78 void CFCalendarSetMinimumDaysInFirstWeek(CFCalendarRef calendar, CFIndex mwd);
79
80
81 typedef CF_OPTIONS(CFOptionFlags, CFCalendarUnit) {
82 kCFCalendarUnitEra = (1UL << 1),
83 kCFCalendarUnitYear = (1UL << 2),
84 kCFCalendarUnitMonth = (1UL << 3),
85 kCFCalendarUnitDay = (1UL << 4),
86 kCFCalendarUnitHour = (1UL << 5),
87 kCFCalendarUnitMinute = (1UL << 6),
88 kCFCalendarUnitSecond = (1UL << 7),
89 kCFCalendarUnitWeek = (1UL << 8) /* CF_DEPRECATED(10_4, 10_7, 2_0, 5_0) */,
90 kCFCalendarUnitWeekday = (1UL << 9),
91 kCFCalendarUnitWeekdayOrdinal = (1UL << 10),
92 kCFCalendarUnitQuarter CF_ENUM_AVAILABLE(10_6, 4_0) = (1UL << 11),
93 kCFCalendarUnitWeekOfMonth CF_ENUM_AVAILABLE(10_7, 5_0) = (1UL << 12),
94 kCFCalendarUnitWeekOfYear CF_ENUM_AVAILABLE(10_7, 5_0) = (1UL << 13),
95 kCFCalendarUnitYearForWeekOfYear CF_ENUM_AVAILABLE(10_7, 5_0) = (1UL << 14),
96 };
97
98 CF_EXPORT
99 CFRange CFCalendarGetMinimumRangeOfUnit(CFCalendarRef calendar, CFCalendarUnit unit);
100
101 CF_EXPORT
102 CFRange CFCalendarGetMaximumRangeOfUnit(CFCalendarRef calendar, CFCalendarUnit unit);
103
104 CF_EXPORT
105 CFRange CFCalendarGetRangeOfUnit(CFCalendarRef calendar, CFCalendarUnit smallerUnit, CFCalendarUnit biggerUnit, CFAbsoluteTime at);
106
107 CF_EXPORT
108 CFIndex CFCalendarGetOrdinalityOfUnit(CFCalendarRef calendar, CFCalendarUnit smallerUnit, CFCalendarUnit biggerUnit, CFAbsoluteTime at);
109
110 CF_EXPORT
111 Boolean CFCalendarGetTimeRangeOfUnit(CFCalendarRef calendar, CFCalendarUnit unit, CFAbsoluteTime at, CFAbsoluteTime *startp, CFTimeInterval *tip) CF_AVAILABLE(10_5, 2_0);
112
113 CF_EXPORT
114 Boolean CFCalendarComposeAbsoluteTime(CFCalendarRef calendar, /* out */ CFAbsoluteTime *at, const char *componentDesc, ...);
115
116 CF_EXPORT
117 Boolean CFCalendarDecomposeAbsoluteTime(CFCalendarRef calendar, CFAbsoluteTime at, const char *componentDesc, ...);
118
119
120 enum {
121 kCFCalendarComponentsWrap = (1UL << 0) // option for adding
122 };
123
124 CF_EXPORT
125 Boolean CFCalendarAddComponents(CFCalendarRef calendar, /* inout */ CFAbsoluteTime *at, CFOptionFlags options, const char *componentDesc, ...);
126
127 CF_EXPORT
128 Boolean CFCalendarGetComponentDifference(CFCalendarRef calendar, CFAbsoluteTime startingAT, CFAbsoluteTime resultAT, CFOptionFlags options, const char *componentDesc, ...);
129
130
131 CF_EXTERN_C_END
132 CF_IMPLICIT_BRIDGING_DISABLED
133
134 #endif /* ! __COREFOUNDATION_CFCALENDAR__ */
135