forked from swiftlang/swift-corelibs-foundation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCFDateComponents.h
92 lines (65 loc) · 2.98 KB
/
CFDateComponents.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/* CFDateComponents.h
Copyright (c) 2004-2017, Apple Inc. and the Swift project authors
Portions Copyright (c) 2014-2017, Apple Inc. and the Swift project authors
Licensed under Apache License v2.0 with Runtime Library Exception
See http://swift.org/LICENSE.txt for license information
See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
*/
#if !defined(__COREFOUNDATION_CFDATECOMPONENTS__)
#define __COREFOUNDATION_CFDATECOMPONENTS__ 1
#include <CoreFoundation/CFBase.h>
CF_IMPLICIT_BRIDGING_ENABLED
CF_EXTERN_C_BEGIN
CF_ASSUME_NONNULL_BEGIN
// Must match NSDateComponentUndefined
CF_ENUM(CFIndex) {
#if TARGET_OS_WIN32
CFDateComponentUndefined = LLONG_MAX
#else
CFDateComponentUndefined = __LONG_MAX__
#endif
};
enum {
kCFCalendarUnitNanosecond = (1 << 15), // Must match NSCalendarUnitNanosecond
kCFCalendarUnitCalendar = (1 << 20), // Must match NSCalendarUnitCalendar
kCFCalendarUnitTimeZone = (1 << 21), // Must match NSCalendarUnitTimeZone
kCFCalendarUnitLeapMonth = (1 << 30)
};
typedef struct CF_BRIDGED_TYPE(id) __CFDateComponents * CFDateComponentsRef;
CF_EXPORT
CFDateComponentsRef _Nullable CFDateComponentsCreate(CFAllocatorRef _Nullable allocator) CF_RETURNS_RETAINED;
CF_EXPORT
CFIndex CFDateComponentsGetValue(CFDateComponentsRef dateComp, CFCalendarUnit unit);
CF_EXPORT
void CFDateComponentsSetValue(CFDateComponentsRef dateComp, CFCalendarUnit unit, CFIndex value);
CF_EXPORT
CFCalendarRef _Nullable CFDateComponentsCopyCalendar(CFDateComponentsRef dateComp);
CF_EXPORT
void CFDateComponentsSetCalendar(CFDateComponentsRef dateComp, CFCalendarRef _Nullable calendar);
CF_EXPORT
CFTimeZoneRef _Nullable CFDateComponentsCopyTimeZone(CFDateComponentsRef dateComp);
CF_EXPORT
void CFDateComponentsSetTimeZone(CFDateComponentsRef dateComp, CFTimeZoneRef _Nullable timeZone);
CF_EXPORT
Boolean CFDateComponentsIsLeapMonthSet(CFDateComponentsRef dc);
CF_EXPORT
Boolean CFDateComponentsIsLeapMonth(CFDateComponentsRef dc);
CF_EXPORT
Boolean CFDateComponentsIsValidDate(CFDateComponentsRef dateComp);
CF_EXPORT
Boolean CFDateComponentsIsValidDateInCalendar(CFDateComponentsRef dateComp, CFCalendarRef _Nullable calendar);
// Calendar API
CF_EXPORT
Boolean CFDateComponentsDateMatchesComponents(CFDateComponentsRef dateComp, CFCalendarRef calendar, CFDateRef date);
CF_EXPORT
CFDateRef _Nullable CFCalendarCreateDateFromComponents(CFAllocatorRef _Nullable allocator, CFCalendarRef calendar, CFDateComponentsRef dateComp);
CF_EXPORT
CFIndex CFCalendarGetComponentFromDate(CFCalendarRef calendar, CFCalendarUnit unit, CFDateRef date);
CF_EXPORT
CFDateComponentsRef CFCalendarCreateDateComponentsFromDate(CFAllocatorRef _Nullable allocator, CFCalendarRef calendar, CFCalendarUnit units, CFDateRef date);
CF_EXPORT
CFDateComponentsRef CFDateComponentsCreateCopy(CFAllocatorRef allocator, CFDateComponentsRef dc);
CF_ASSUME_NONNULL_END
CF_EXTERN_C_END
CF_IMPLICIT_BRIDGING_DISABLED
#endif /* ! __COREFOUNDATION_CFDATECOMPONENTS__ */