- Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCFDateFormatter.h
183 lines (153 loc) · 8.91 KB
/
CFDateFormatter.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/*
* Copyright (c) 2008-2012 Brent Fulgham <bfulgham@gmail.org>. All rights reserved.
*
* This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
* the terms of the APSL version 2.0 (see below).
*
* For information about changes from the original Apple source release can be found by reviewing the
* source control system for the project at https://sourceforge.net/svn/?group_id=246198.
*
* The original license information is as follows:
*
* Copyright (c) 2012 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/* CFDateFormatter.h
Copyright (c) 2003-2011, Apple Inc. All rights reserved.
*/
#if !defined(__COREFOUNDATION_CFDATEFORMATTER__)
#define__COREFOUNDATION_CFDATEFORMATTER__ 1
#include<CoreFoundation/CFBase.h>
#include<CoreFoundation/CFDate.h>
#include<CoreFoundation/CFLocale.h>
CF_EXTERN_C_BEGIN
typedefstruct__CFDateFormatter*CFDateFormatterRef;
// CFDateFormatters are not thread-safe. Do not use one from multiple threads!
CF_EXPORT
CFStringRefCFDateFormatterCreateDateFormatFromTemplate(CFAllocatorRefallocator, CFStringReftmplate, CFOptionFlagsoptions, CFLocaleReflocale) CF_AVAILABLE(10_6, 4_0);
// no options defined, pass 0 for now
CF_EXPORT
CFTypeIDCFDateFormatterGetTypeID(void);
enum { // date and time format styles
kCFDateFormatterNoStyle=0,
kCFDateFormatterShortStyle=1,
kCFDateFormatterMediumStyle=2,
kCFDateFormatterLongStyle=3,
kCFDateFormatterFullStyle=4
};
typedefCFIndexCFDateFormatterStyle;
// The exact formatted result for these date and time styles depends on the
// locale, but generally:
// Short is completely numeric, such as "12/13/52" or "3:30pm"
// Medium is longer, such as "Jan 12, 1952"
// Long is longer, such as "January 12, 1952" or "3:30:32pm"
// Full is pretty complete; e.g. "Tuesday, April 12, 1952 AD" or "3:30:42pm PST"
// The specifications though are left fuzzy, in part simply because a user's
// preference choices may affect the output, and also the results may change
// from one OS release to another. To produce an exactly formatted date you
// should not rely on styles and localization, but set the format string and
// use nothing but numbers.
CF_EXPORT
CFDateFormatterRefCFDateFormatterCreate(CFAllocatorRefallocator, CFLocaleReflocale, CFDateFormatterStyledateStyle, CFDateFormatterStyletimeStyle);
// Returns a CFDateFormatter, localized to the given locale, which
// will format dates to the given date and time styles.
CF_EXPORT
CFLocaleRefCFDateFormatterGetLocale(CFDateFormatterRefformatter);
CF_EXPORT
CFDateFormatterStyleCFDateFormatterGetDateStyle(CFDateFormatterRefformatter);
CF_EXPORT
CFDateFormatterStyleCFDateFormatterGetTimeStyle(CFDateFormatterRefformatter);
// Get the properties with which the date formatter was created.
CF_EXPORT
CFStringRefCFDateFormatterGetFormat(CFDateFormatterRefformatter);
CF_EXPORT
voidCFDateFormatterSetFormat(CFDateFormatterRefformatter, CFStringRefformatString);
// Set the format description string of the date formatter. This
// overrides the style settings. The format of the format string
// is as defined by the ICU library. The date formatter starts with a
// default format string defined by the style arguments with
// which it was created.
CF_EXPORT
CFStringRefCFDateFormatterCreateStringWithDate(CFAllocatorRefallocator, CFDateFormatterRefformatter, CFDateRefdate);
CF_EXPORT
CFStringRefCFDateFormatterCreateStringWithAbsoluteTime(CFAllocatorRefallocator, CFDateFormatterRefformatter, CFAbsoluteTimeat);
// Create a string representation of the given date or CFAbsoluteTime
// using the current state of the date formatter.
CF_EXPORT
CFDateRefCFDateFormatterCreateDateFromString(CFAllocatorRefallocator, CFDateFormatterRefformatter, CFStringRefstring, CFRange*rangep);
CF_EXPORT
BooleanCFDateFormatterGetAbsoluteTimeFromString(CFDateFormatterRefformatter, CFStringRefstring, CFRange*rangep, CFAbsoluteTime*atp);
// Parse a string representation of a date using the current state
// of the date formatter. The range parameter specifies the range
// of the string in which the parsing should occur in input, and on
// output indicates the extent that was used; this parameter can
// be NULL, in which case the whole string may be used. The
// return value indicates whether some date was computed and
// (if atp is not NULL) stored at the location specified by atp.
CF_EXPORT
voidCFDateFormatterSetProperty(CFDateFormatterRefformatter, CFStringRefkey, CFTypeRefvalue);
CF_EXPORT
CFTypeRefCFDateFormatterCopyProperty(CFDateFormatterRefformatter, CFStringRefkey);
// Set and get various properties of the date formatter, the set of
// which may be expanded in the future.
CF_EXPORTconstCFStringRefkCFDateFormatterIsLenient; // CFBoolean
CF_EXPORTconstCFStringRefkCFDateFormatterTimeZone; // CFTimeZone
CF_EXPORTconstCFStringRefkCFDateFormatterCalendarName; // CFString
CF_EXPORTconstCFStringRefkCFDateFormatterDefaultFormat; // CFString
CF_EXPORTconstCFStringRefkCFDateFormatterTwoDigitStartDate; // CFDate
CF_EXPORTconstCFStringRefkCFDateFormatterDefaultDate; // CFDate
CF_EXPORTconstCFStringRefkCFDateFormatterCalendar; // CFCalendar
CF_EXPORTconstCFStringRefkCFDateFormatterEraSymbols; // CFArray of CFString
CF_EXPORTconstCFStringRefkCFDateFormatterMonthSymbols; // CFArray of CFString
CF_EXPORTconstCFStringRefkCFDateFormatterShortMonthSymbols; // CFArray of CFString
CF_EXPORTconstCFStringRefkCFDateFormatterWeekdaySymbols; // CFArray of CFString
CF_EXPORTconstCFStringRefkCFDateFormatterShortWeekdaySymbols; // CFArray of CFString
CF_EXPORTconstCFStringRefkCFDateFormatterAMSymbol; // CFString
CF_EXPORTconstCFStringRefkCFDateFormatterPMSymbol; // CFString
CF_EXPORTconstCFStringRefkCFDateFormatterLongEraSymbolsCF_AVAILABLE(10_5, 2_0); // CFArray of CFString
CF_EXPORTconstCFStringRefkCFDateFormatterVeryShortMonthSymbolsCF_AVAILABLE(10_5, 2_0); // CFArray of CFString
CF_EXPORTconstCFStringRefkCFDateFormatterStandaloneMonthSymbolsCF_AVAILABLE(10_5, 2_0); // CFArray of CFString
CF_EXPORTconstCFStringRefkCFDateFormatterShortStandaloneMonthSymbolsCF_AVAILABLE(10_5, 2_0); // CFArray of CFString
CF_EXPORTconstCFStringRefkCFDateFormatterVeryShortStandaloneMonthSymbolsCF_AVAILABLE(10_5, 2_0); // CFArray of CFString
CF_EXPORTconstCFStringRefkCFDateFormatterVeryShortWeekdaySymbolsCF_AVAILABLE(10_5, 2_0); // CFArray of CFString
CF_EXPORTconstCFStringRefkCFDateFormatterStandaloneWeekdaySymbolsCF_AVAILABLE(10_5, 2_0); // CFArray of CFString
CF_EXPORTconstCFStringRefkCFDateFormatterShortStandaloneWeekdaySymbolsCF_AVAILABLE(10_5, 2_0); // CFArray of CFString
CF_EXPORTconstCFStringRefkCFDateFormatterVeryShortStandaloneWeekdaySymbolsCF_AVAILABLE(10_5, 2_0); // CFArray of CFString
CF_EXPORTconstCFStringRefkCFDateFormatterQuarterSymbolsCF_AVAILABLE(10_5, 2_0); // CFArray of CFString
CF_EXPORTconstCFStringRefkCFDateFormatterShortQuarterSymbolsCF_AVAILABLE(10_5, 2_0); // CFArray of CFString
CF_EXPORTconstCFStringRefkCFDateFormatterStandaloneQuarterSymbolsCF_AVAILABLE(10_5, 2_0); // CFArray of CFString
CF_EXPORTconstCFStringRefkCFDateFormatterShortStandaloneQuarterSymbolsCF_AVAILABLE(10_5, 2_0); // CFArray of CFString
CF_EXPORTconstCFStringRefkCFDateFormatterGregorianStartDateCF_AVAILABLE(10_5, 2_0); // CFDate
CF_EXPORTconstCFStringRefkCFDateFormatterDoesRelativeDateFormattingKeyCF_AVAILABLE(10_6, 4_0); // CFBoolean
// See CFLocale.h for these calendar constants:
// const CFStringRef kCFCalendarIdentifierGregorian;
// const CFStringRef kCFCalendarIdentifierBuddhist;
// const CFStringRef kCFCalendarIdentifierJapanese;
// const CFStringRef kCFCalendarIdentifierIslamic;
// const CFStringRef kCFCalendarIdentifierIslamicCivil;
// const CFStringRef kCFCalendarIdentifierHebrew;
// const CFStringRef kCFCalendarIdentifierChinese;
// const CFStringRef kCFRepublicOfChinaCalendar;
// const CFStringRef kCFPersianCalendar;
// const CFStringRef kCFIndianCalendar;
// const CFStringRef kCFISO8601Calendar; not yet implemented
CF_EXTERN_C_END
#endif/* ! __COREFOUNDATION_CFDATEFORMATTER__ */