]> git.saurik.com Git - apple/cf.git/blob - NumberDate.subproj/CFDate.h
CF-299.tar.gz
[apple/cf.git] / NumberDate.subproj / CFDate.h
1 /*
2 * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25 /* CFDate.h
26 Copyright (c) 1998-2003, Apple, Inc. All rights reserved.
27 */
28
29 #if !defined(__COREFOUNDATION_CFDATE__)
30 #define __COREFOUNDATION_CFDATE__ 1
31
32 #include <CoreFoundation/CFBase.h>
33
34 #if defined(__cplusplus)
35 extern "C" {
36 #endif
37
38 typedef double CFTimeInterval;
39 typedef CFTimeInterval CFAbsoluteTime;
40 /* absolute time is the time interval since the reference date */
41 /* the reference date (epoch) is 00:00:00 1 January 2001. */
42
43 CF_EXPORT
44 CFAbsoluteTime CFAbsoluteTimeGetCurrent(void);
45
46 CF_EXPORT
47 const CFTimeInterval kCFAbsoluteTimeIntervalSince1970;
48 CF_EXPORT
49 const CFTimeInterval kCFAbsoluteTimeIntervalSince1904;
50
51 typedef const struct __CFDate * CFDateRef;
52
53 CF_EXPORT
54 CFTypeID CFDateGetTypeID(void);
55
56 CF_EXPORT
57 CFDateRef CFDateCreate(CFAllocatorRef allocator, CFAbsoluteTime at);
58
59 CF_EXPORT
60 CFAbsoluteTime CFDateGetAbsoluteTime(CFDateRef theDate);
61
62 CF_EXPORT
63 CFTimeInterval CFDateGetTimeIntervalSinceDate(CFDateRef theDate, CFDateRef otherDate);
64
65 CF_EXPORT
66 CFComparisonResult CFDateCompare(CFDateRef theDate, CFDateRef otherDate, void *context);
67
68 typedef const struct __CFTimeZone * CFTimeZoneRef;
69
70 typedef struct {
71 SInt32 year;
72 SInt8 month;
73 SInt8 day;
74 SInt8 hour;
75 SInt8 minute;
76 double second;
77 } CFGregorianDate;
78
79 typedef struct {
80 SInt32 years;
81 SInt32 months;
82 SInt32 days;
83 SInt32 hours;
84 SInt32 minutes;
85 double seconds;
86 } CFGregorianUnits;
87
88 typedef enum {
89 kCFGregorianUnitsYears = (1 << 0),
90 kCFGregorianUnitsMonths = (1 << 1),
91 kCFGregorianUnitsDays = (1 << 2),
92 kCFGregorianUnitsHours = (1 << 3),
93 kCFGregorianUnitsMinutes = (1 << 4),
94 kCFGregorianUnitsSeconds = (1 << 5),
95 #if 0
96 kCFGregorianUnitsTimeZone = (1 << 8),
97 kCFGregorianUnitsDayOfWeek = (1 << 9),
98 #endif
99 kCFGregorianAllUnits = 0x00FFFFFF
100 } CFGregorianUnitFlags;
101
102 CF_EXPORT
103 Boolean CFGregorianDateIsValid(CFGregorianDate gdate, CFOptionFlags unitFlags);
104
105 CF_EXPORT
106 CFAbsoluteTime CFGregorianDateGetAbsoluteTime(CFGregorianDate gdate, CFTimeZoneRef tz);
107
108 CF_EXPORT
109 CFGregorianDate CFAbsoluteTimeGetGregorianDate(CFAbsoluteTime at, CFTimeZoneRef tz);
110
111 CF_EXPORT
112 CFAbsoluteTime CFAbsoluteTimeAddGregorianUnits(CFAbsoluteTime at, CFTimeZoneRef tz, CFGregorianUnits units);
113
114 CF_EXPORT
115 CFGregorianUnits CFAbsoluteTimeGetDifferenceAsGregorianUnits(CFAbsoluteTime at1, CFAbsoluteTime at2, CFTimeZoneRef tz, CFOptionFlags unitFlags);
116
117 CF_EXPORT
118 SInt32 CFAbsoluteTimeGetDayOfWeek(CFAbsoluteTime at, CFTimeZoneRef tz);
119
120 CF_EXPORT
121 SInt32 CFAbsoluteTimeGetDayOfYear(CFAbsoluteTime at, CFTimeZoneRef tz);
122
123 CF_EXPORT
124 SInt32 CFAbsoluteTimeGetWeekOfYear(CFAbsoluteTime at, CFTimeZoneRef tz);
125
126 #if defined(__cplusplus)
127 }
128 #endif
129
130 #endif /* ! __COREFOUNDATION_CFDATE__ */
131