2 * Copyright (c) 2014 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-2013, 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>
36 CF_IMPLICIT_BRIDGING_ENABLED
39 typedef struct __CFCalendar
* CFCalendarRef
;
42 CFTypeID
CFCalendarGetTypeID(void);
45 CFCalendarRef
CFCalendarCopyCurrent(void);
48 CFCalendarRef
CFCalendarCreateWithIdentifier(CFAllocatorRef allocator
, CFStringRef identifier
);
49 // Create a calendar. The identifiers are the kCF*Calendar
50 // constants in CFLocale.h.
53 CFStringRef
CFCalendarGetIdentifier(CFCalendarRef calendar
);
54 // Returns the calendar's identifier.
57 CFLocaleRef
CFCalendarCopyLocale(CFCalendarRef calendar
);
60 void CFCalendarSetLocale(CFCalendarRef calendar
, CFLocaleRef locale
);
63 CFTimeZoneRef
CFCalendarCopyTimeZone(CFCalendarRef calendar
);
66 void CFCalendarSetTimeZone(CFCalendarRef calendar
, CFTimeZoneRef tz
);
69 CFIndex
CFCalendarGetFirstWeekday(CFCalendarRef calendar
);
72 void CFCalendarSetFirstWeekday(CFCalendarRef calendar
, CFIndex wkdy
);
75 CFIndex
CFCalendarGetMinimumDaysInFirstWeek(CFCalendarRef calendar
);
78 void CFCalendarSetMinimumDaysInFirstWeek(CFCalendarRef calendar
, CFIndex mwd
);
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),
99 CFRange
CFCalendarGetMinimumRangeOfUnit(CFCalendarRef calendar
, CFCalendarUnit unit
);
102 CFRange
CFCalendarGetMaximumRangeOfUnit(CFCalendarRef calendar
, CFCalendarUnit unit
);
105 CFRange
CFCalendarGetRangeOfUnit(CFCalendarRef calendar
, CFCalendarUnit smallerUnit
, CFCalendarUnit biggerUnit
, CFAbsoluteTime at
);
108 CFIndex
CFCalendarGetOrdinalityOfUnit(CFCalendarRef calendar
, CFCalendarUnit smallerUnit
, CFCalendarUnit biggerUnit
, CFAbsoluteTime at
);
111 Boolean
CFCalendarGetTimeRangeOfUnit(CFCalendarRef calendar
, CFCalendarUnit unit
, CFAbsoluteTime at
, CFAbsoluteTime
*startp
, CFTimeInterval
*tip
) CF_AVAILABLE(10_5
, 2_0
);
114 Boolean
CFCalendarComposeAbsoluteTime(CFCalendarRef calendar
, /* out */ CFAbsoluteTime
*at
, const char *componentDesc
, ...);
117 Boolean
CFCalendarDecomposeAbsoluteTime(CFCalendarRef calendar
, CFAbsoluteTime at
, const char *componentDesc
, ...);
121 kCFCalendarComponentsWrap
= (1UL << 0) // option for adding
125 Boolean
CFCalendarAddComponents(CFCalendarRef calendar
, /* inout */ CFAbsoluteTime
*at
, CFOptionFlags options
, const char *componentDesc
, ...);
128 Boolean
CFCalendarGetComponentDifference(CFCalendarRef calendar
, CFAbsoluteTime startingAT
, CFAbsoluteTime resultAT
, CFOptionFlags options
, const char *componentDesc
, ...);
132 CF_IMPLICIT_BRIDGING_DISABLED
134 #endif /* ! __COREFOUNDATION_CFCALENDAR__ */