]> git.saurik.com Git - apple/cf.git/blob - CFDateFormatter.h
CF-550.tar.gz
[apple/cf.git] / CFDateFormatter.h
1 /*
2 * Copyright (c) 2009 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 /* CFDateFormatter.h
24 Copyright (c) 2003-2009, Apple Inc. All rights reserved.
25 */
26
27 #if !defined(__COREFOUNDATION_CFDATEFORMATTER__)
28 #define __COREFOUNDATION_CFDATEFORMATTER__ 1
29
30 #include <CoreFoundation/CFBase.h>
31 #include <CoreFoundation/CFDate.h>
32 #include <CoreFoundation/CFLocale.h>
33
34 #if MAC_OS_X_VERSION_10_3 <= MAC_OS_X_VERSION_MAX_ALLOWED
35
36 CF_EXTERN_C_BEGIN
37
38 typedef struct __CFDateFormatter *CFDateFormatterRef;
39
40 // CFDateFormatters are not thread-safe. Do not use one from multiple threads!
41
42 CF_EXPORT
43 CFStringRef CFDateFormatterCreateDateFormatFromTemplate(CFAllocatorRef allocator, CFStringRef tmplate, CFOptionFlags options, CFLocaleRef locale) AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER;
44 // no options defined, pass 0 for now
45
46 CF_EXPORT
47 CFTypeID CFDateFormatterGetTypeID(void) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
48
49 enum { // date and time format styles
50 kCFDateFormatterNoStyle = 0,
51 kCFDateFormatterShortStyle = 1,
52 kCFDateFormatterMediumStyle = 2,
53 kCFDateFormatterLongStyle = 3,
54 kCFDateFormatterFullStyle = 4
55 };
56 typedef CFIndex CFDateFormatterStyle;
57
58 // The exact formatted result for these date and time styles depends on the
59 // locale, but generally:
60 // Short is completely numeric, such as "12/13/52" or "3:30pm"
61 // Medium is longer, such as "Jan 12, 1952"
62 // Long is longer, such as "January 12, 1952" or "3:30:32pm"
63 // Full is pretty complete; e.g. "Tuesday, April 12, 1952 AD" or "3:30:42pm PST"
64 // The specifications though are left fuzzy, in part simply because a user's
65 // preference choices may affect the output, and also the results may change
66 // from one OS release to another. To produce an exactly formatted date you
67 // should not rely on styles and localization, but set the format string and
68 // use nothing but numbers.
69
70 CF_EXPORT
71 CFDateFormatterRef CFDateFormatterCreate(CFAllocatorRef allocator, CFLocaleRef locale, CFDateFormatterStyle dateStyle, CFDateFormatterStyle timeStyle) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
72 // Returns a CFDateFormatter, localized to the given locale, which
73 // will format dates to the given date and time styles.
74
75 CF_EXPORT
76 CFLocaleRef CFDateFormatterGetLocale(CFDateFormatterRef formatter) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
77
78 CF_EXPORT
79 CFDateFormatterStyle CFDateFormatterGetDateStyle(CFDateFormatterRef formatter) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
80
81 CF_EXPORT
82 CFDateFormatterStyle CFDateFormatterGetTimeStyle(CFDateFormatterRef formatter) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
83 // Get the properties with which the date formatter was created.
84
85 CF_EXPORT
86 CFStringRef CFDateFormatterGetFormat(CFDateFormatterRef formatter) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
87
88 CF_EXPORT
89 void CFDateFormatterSetFormat(CFDateFormatterRef formatter, CFStringRef formatString) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
90 // Set the format description string of the date formatter. This
91 // overrides the style settings. The format of the format string
92 // is as defined by the ICU library. The date formatter starts with a
93 // default format string defined by the style arguments with
94 // which it was created.
95
96
97 CF_EXPORT
98 CFStringRef CFDateFormatterCreateStringWithDate(CFAllocatorRef allocator, CFDateFormatterRef formatter, CFDateRef date) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
99
100 CF_EXPORT
101 CFStringRef CFDateFormatterCreateStringWithAbsoluteTime(CFAllocatorRef allocator, CFDateFormatterRef formatter, CFAbsoluteTime at) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
102 // Create a string representation of the given date or CFAbsoluteTime
103 // using the current state of the date formatter.
104
105
106 CF_EXPORT
107 CFDateRef CFDateFormatterCreateDateFromString(CFAllocatorRef allocator, CFDateFormatterRef formatter, CFStringRef string, CFRange *rangep) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
108
109 CF_EXPORT
110 Boolean CFDateFormatterGetAbsoluteTimeFromString(CFDateFormatterRef formatter, CFStringRef string, CFRange *rangep, CFAbsoluteTime *atp) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
111 // Parse a string representation of a date using the current state
112 // of the date formatter. The range parameter specifies the range
113 // of the string in which the parsing should occur in input, and on
114 // output indicates the extent that was used; this parameter can
115 // be NULL, in which case the whole string may be used. The
116 // return value indicates whether some date was computed and
117 // (if atp is not NULL) stored at the location specified by atp.
118
119
120 CF_EXPORT
121 void CFDateFormatterSetProperty(CFDateFormatterRef formatter, CFStringRef key, CFTypeRef value) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
122
123 CF_EXPORT
124 CFTypeRef CFDateFormatterCopyProperty(CFDateFormatterRef formatter, CFStringRef key) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
125 // Set and get various properties of the date formatter, the set of
126 // which may be expanded in the future.
127
128 CF_EXPORT const CFStringRef kCFDateFormatterIsLenient AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER; // CFBoolean
129 CF_EXPORT const CFStringRef kCFDateFormatterTimeZone AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER; // CFTimeZone
130 CF_EXPORT const CFStringRef kCFDateFormatterCalendarName AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER; // CFString
131 CF_EXPORT const CFStringRef kCFDateFormatterDefaultFormat AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER; // CFString
132 CF_EXPORT const CFStringRef kCFDateFormatterTwoDigitStartDate AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER; // CFDate
133 CF_EXPORT const CFStringRef kCFDateFormatterDefaultDate AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER; // CFDate
134 CF_EXPORT const CFStringRef kCFDateFormatterCalendar AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER; // CFCalendar
135 CF_EXPORT const CFStringRef kCFDateFormatterEraSymbols AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER; // CFArray of CFString
136 CF_EXPORT const CFStringRef kCFDateFormatterMonthSymbols AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER; // CFArray of CFString
137 CF_EXPORT const CFStringRef kCFDateFormatterShortMonthSymbols AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER; // CFArray of CFString
138 CF_EXPORT const CFStringRef kCFDateFormatterWeekdaySymbols AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER; // CFArray of CFString
139 CF_EXPORT const CFStringRef kCFDateFormatterShortWeekdaySymbols AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER; // CFArray of CFString
140 CF_EXPORT const CFStringRef kCFDateFormatterAMSymbol AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER; // CFString
141 CF_EXPORT const CFStringRef kCFDateFormatterPMSymbol AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER; // CFString
142 CF_EXPORT const CFStringRef kCFDateFormatterLongEraSymbols AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER; // CFArray of CFString
143 CF_EXPORT const CFStringRef kCFDateFormatterVeryShortMonthSymbols AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER; // CFArray of CFString
144 CF_EXPORT const CFStringRef kCFDateFormatterStandaloneMonthSymbols AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER; // CFArray of CFString
145 CF_EXPORT const CFStringRef kCFDateFormatterShortStandaloneMonthSymbols AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER; // CFArray of CFString
146 CF_EXPORT const CFStringRef kCFDateFormatterVeryShortStandaloneMonthSymbols AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER; // CFArray of CFString
147 CF_EXPORT const CFStringRef kCFDateFormatterVeryShortWeekdaySymbols AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER; // CFArray of CFString
148 CF_EXPORT const CFStringRef kCFDateFormatterStandaloneWeekdaySymbols AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER; // CFArray of CFString
149 CF_EXPORT const CFStringRef kCFDateFormatterShortStandaloneWeekdaySymbols AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER; // CFArray of CFString
150 CF_EXPORT const CFStringRef kCFDateFormatterVeryShortStandaloneWeekdaySymbols AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER; // CFArray of CFString
151 CF_EXPORT const CFStringRef kCFDateFormatterQuarterSymbols AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER; // CFArray of CFString
152 CF_EXPORT const CFStringRef kCFDateFormatterShortQuarterSymbols AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER; // CFArray of CFString
153 CF_EXPORT const CFStringRef kCFDateFormatterStandaloneQuarterSymbols AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER; // CFArray of CFString
154 CF_EXPORT const CFStringRef kCFDateFormatterShortStandaloneQuarterSymbols AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER; // CFArray of CFString
155 CF_EXPORT const CFStringRef kCFDateFormatterGregorianStartDate AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER; // CFDate
156 CF_EXPORT const CFStringRef kCFDateFormatterDoesRelativeDateFormattingKey AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER; // CFBoolean
157
158 // See CFLocale.h for these calendar constants:
159 // const CFStringRef kCFGregorianCalendar;
160 // const CFStringRef kCFBuddhistCalendar;
161 // const CFStringRef kCFJapaneseCalendar;
162 // const CFStringRef kCFIslamicCalendar;
163 // const CFStringRef kCFIslamicCivilCalendar;
164 // const CFStringRef kCFHebrewCalendar;
165 // const CFStringRef kCFChineseCalendar;
166 // const CFStringRef kCFRepublicOfChinaCalendar;
167 // const CFStringRef kCFPersianCalendar;
168 // const CFStringRef kCFIndianCalendar;
169 // const CFStringRef kCFISO8601Calendar; not yet implemented
170
171 CF_EXTERN_C_END
172
173 #endif
174
175 #endif /* ! __COREFOUNDATION_CFDATEFORMATTER__ */
176