]> git.saurik.com Git - apple/cf.git/blob - CFDate.h
CF-635.tar.gz
[apple/cf.git] / CFDate.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 /* CFDate.h
25 Copyright (c) 1998-2011, Apple Inc. All rights reserved.
26 */
27
28 #if !defined(__COREFOUNDATION_CFDATE__)
29 #define __COREFOUNDATION_CFDATE__ 1
30
31 #include <CoreFoundation/CFBase.h>
32
33 CF_EXTERN_C_BEGIN
34
35 typedef double CFTimeInterval;
36 typedef CFTimeInterval CFAbsoluteTime;
37 /* absolute time is the time interval since the reference date */
38 /* the reference date (epoch) is 00:00:00 1 January 2001. */
39
40 CF_EXPORT
41 CFAbsoluteTime CFAbsoluteTimeGetCurrent(void);
42
43 CF_EXPORT
44 const CFTimeInterval kCFAbsoluteTimeIntervalSince1970;
45 CF_EXPORT
46 const CFTimeInterval kCFAbsoluteTimeIntervalSince1904;
47
48 typedef const struct __CFDate * CFDateRef;
49
50 CF_EXPORT
51 CFTypeID CFDateGetTypeID(void);
52
53 CF_EXPORT
54 CFDateRef CFDateCreate(CFAllocatorRef allocator, CFAbsoluteTime at);
55
56 CF_EXPORT
57 CFAbsoluteTime CFDateGetAbsoluteTime(CFDateRef theDate);
58
59 CF_EXPORT
60 CFTimeInterval CFDateGetTimeIntervalSinceDate(CFDateRef theDate, CFDateRef otherDate);
61
62 CF_EXPORT
63 CFComparisonResult CFDateCompare(CFDateRef theDate, CFDateRef otherDate, void *context);
64
65 typedef const struct __CFTimeZone * CFTimeZoneRef;
66
67 typedef struct {
68 SInt32 year;
69 SInt8 month;
70 SInt8 day;
71 SInt8 hour;
72 SInt8 minute;
73 double second;
74 } CFGregorianDate;
75
76 typedef struct {
77 SInt32 years;
78 SInt32 months;
79 SInt32 days;
80 SInt32 hours;
81 SInt32 minutes;
82 double seconds;
83 } CFGregorianUnits;
84
85 enum {
86 kCFGregorianUnitsYears = (1UL << 0),
87 kCFGregorianUnitsMonths = (1UL << 1),
88 kCFGregorianUnitsDays = (1UL << 2),
89 kCFGregorianUnitsHours = (1UL << 3),
90 kCFGregorianUnitsMinutes = (1UL << 4),
91 kCFGregorianUnitsSeconds = (1UL << 5),
92 kCFGregorianAllUnits = 0x00FFFFFF
93 };
94 typedef CFOptionFlags CFGregorianUnitFlags;
95
96 CF_EXPORT
97 Boolean CFGregorianDateIsValid(CFGregorianDate gdate, CFOptionFlags unitFlags);
98
99 CF_EXPORT
100 CFAbsoluteTime CFGregorianDateGetAbsoluteTime(CFGregorianDate gdate, CFTimeZoneRef tz);
101
102 CF_EXPORT
103 CFGregorianDate CFAbsoluteTimeGetGregorianDate(CFAbsoluteTime at, CFTimeZoneRef tz);
104
105 CF_EXPORT
106 CFAbsoluteTime CFAbsoluteTimeAddGregorianUnits(CFAbsoluteTime at, CFTimeZoneRef tz, CFGregorianUnits units);
107
108 CF_EXPORT
109 CFGregorianUnits CFAbsoluteTimeGetDifferenceAsGregorianUnits(CFAbsoluteTime at1, CFAbsoluteTime at2, CFTimeZoneRef tz, CFOptionFlags unitFlags);
110
111 CF_EXPORT
112 SInt32 CFAbsoluteTimeGetDayOfWeek(CFAbsoluteTime at, CFTimeZoneRef tz);
113
114 CF_EXPORT
115 SInt32 CFAbsoluteTimeGetDayOfYear(CFAbsoluteTime at, CFTimeZoneRef tz);
116
117 CF_EXPORT
118 SInt32 CFAbsoluteTimeGetWeekOfYear(CFAbsoluteTime at, CFTimeZoneRef tz);
119
120 CF_EXTERN_C_END
121
122 #endif /* ! __COREFOUNDATION_CFDATE__ */
123