OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1997-2013, International Business Machines Corporation and | 2 * Copyright (C) 1997-2014, International Business Machines Corporation and |
3 * others. All Rights Reserved. | 3 * others. All Rights Reserved. |
4 ******************************************************************************* | 4 ******************************************************************************* |
5 * | 5 * |
6 * File SMPDTFMT.H | 6 * File SMPDTFMT.H |
7 * | 7 * |
8 * Modification History: | 8 * Modification History: |
9 * | 9 * |
10 * Date Name Description | 10 * Date Name Description |
11 * 02/19/97 aliu Converted from java. | 11 * 02/19/97 aliu Converted from java. |
12 * 07/09/97 helena Make ParsePosition into a class. | 12 * 07/09/97 helena Make ParsePosition into a class. |
(...skipping 15 matching lines...) Expand all Loading... |
28 | 28 |
29 /** | 29 /** |
30 * \file | 30 * \file |
31 * \brief C++ API: Format and parse dates in a language-independent manner. | 31 * \brief C++ API: Format and parse dates in a language-independent manner. |
32 */ | 32 */ |
33 | 33 |
34 #if !UCONFIG_NO_FORMATTING | 34 #if !UCONFIG_NO_FORMATTING |
35 | 35 |
36 #include "unicode/datefmt.h" | 36 #include "unicode/datefmt.h" |
37 #include "unicode/udisplaycontext.h" | 37 #include "unicode/udisplaycontext.h" |
| 38 #include "unicode/tzfmt.h" /* for UTimeZoneFormatTimeType */ |
| 39 #include "unicode/brkiter.h" |
38 | 40 |
39 U_NAMESPACE_BEGIN | 41 U_NAMESPACE_BEGIN |
40 | 42 |
41 class DateFormatSymbols; | 43 class DateFormatSymbols; |
42 class DateFormat; | 44 class DateFormat; |
43 class MessageFormat; | 45 class MessageFormat; |
44 class FieldPositionHandler; | 46 class FieldPositionHandler; |
45 class TimeZoneFormat; | 47 class TimeZoneFormat; |
46 | 48 |
47 /** | 49 /** |
(...skipping 14 matching lines...) Expand all Loading... |
62 * | 64 * |
63 * <p><strong>Date and Time Patterns:</strong></p> | 65 * <p><strong>Date and Time Patterns:</strong></p> |
64 * | 66 * |
65 * <p>Date and time formats are specified by <em>date and time pattern</em> stri
ngs. | 67 * <p>Date and time formats are specified by <em>date and time pattern</em> stri
ngs. |
66 * Within date and time pattern strings, all unquoted ASCII letters [A-Za-z] are
reserved | 68 * Within date and time pattern strings, all unquoted ASCII letters [A-Za-z] are
reserved |
67 * as pattern letters representing calendar fields. <code>SimpleDateFormat</code
> supports | 69 * as pattern letters representing calendar fields. <code>SimpleDateFormat</code
> supports |
68 * the date and time formatting algorithm and pattern letters defined by | 70 * the date and time formatting algorithm and pattern letters defined by |
69 * <a href="http://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbo
l_Table">UTS#35 | 71 * <a href="http://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbo
l_Table">UTS#35 |
70 * Unicode Locale Data Markup Language (LDML)</a> and further documented for ICU
in the | 72 * Unicode Locale Data Markup Language (LDML)</a> and further documented for ICU
in the |
71 * <a href="https://sites.google.com/site/icuprojectuserguide/formatparse/dateti
me?pli=1#TOC-Date-Field-Symbol-Table">ICU | 73 * <a href="https://sites.google.com/site/icuprojectuserguide/formatparse/dateti
me?pli=1#TOC-Date-Field-Symbol-Table">ICU |
72 * User Guide</a>. The following pattern letters are currently available:</p> | 74 * User Guide</a>. The following pattern letters are currently available (note t
hat the actual |
| 75 * values depend on CLDR and may change from the examples shown here):</p> |
73 * | 76 * |
74 * <table border="1"> | 77 * <table border="1"> |
75 * <tr> | 78 * <tr> |
76 * <th>Field</th> | 79 * <th>Field</th> |
77 * <th style="text-align: center">Sym.</th> | 80 * <th style="text-align: center">Sym.</th> |
78 * <th style="text-align: center">No.</th> | 81 * <th style="text-align: center">No.</th> |
79 * <th>Example</th> | 82 * <th>Example</th> |
80 * <th>Description</th> | 83 * <th>Description</th> |
81 * </tr> | 84 * </tr> |
82 * <tr> | 85 * <tr> |
83 * <th rowspan="3">era</th> | 86 * <th rowspan="3">era</th> |
84 * <td style="text-align: center" rowspan="3">G</td> | 87 * <td style="text-align: center" rowspan="3">G</td> |
85 * <td style="text-align: center">1..3</td> | 88 * <td style="text-align: center">1..3</td> |
86 * <td>AD</td> | 89 * <td>AD</td> |
87 * <td rowspan="3">Era - Replaced with the Era string for the current da
te. One to three letters for the | 90 * <td rowspan="3">Era - Replaced with the Era string for the current da
te. One to three letters for the |
88 * abbreviated form, four letters for the long form, five for the narrow
form.</td> | 91 * abbreviated form, four letters for the long (wide) form, five for the
narrow form.</td> |
89 * </tr> | 92 * </tr> |
90 * <tr> | 93 * <tr> |
91 * <td style="text-align: center">4</td> | 94 * <td style="text-align: center">4</td> |
92 * <td>Anno Domini</td> | 95 * <td>Anno Domini</td> |
93 * </tr> | 96 * </tr> |
94 * <tr> | 97 * <tr> |
95 * <td style="text-align: center">5</td> | 98 * <td style="text-align: center">5</td> |
96 * <td>A</td> | 99 * <td>A</td> |
97 * </tr> | 100 * </tr> |
98 * <tr> | 101 * <tr> |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 * all supra-year fields. For example, for the Julian calendar system, y
ear numbers are positive, with an | 176 * all supra-year fields. For example, for the Julian calendar system, y
ear numbers are positive, with an |
174 * era of BCE or CE. An extended year value for the Julian calendar syst
em assigns positive values to CE | 177 * era of BCE or CE. An extended year value for the Julian calendar syst
em assigns positive values to CE |
175 * years and negative values to BCE years, with 1 BCE being year 0.</td> | 178 * years and negative values to BCE years, with 1 BCE being year 0.</td> |
176 * </tr> | 179 * </tr> |
177 * <tr> | 180 * <tr> |
178 * <td style="text-align: center" rowspan="3">U</td> | 181 * <td style="text-align: center" rowspan="3">U</td> |
179 * <td style="text-align: center">1..3</td> | 182 * <td style="text-align: center">1..3</td> |
180 * <td>甲子</td> | 183 * <td>甲子</td> |
181 * <td rowspan="3">Cyclic year name. Calendars such as the Chinese lunar
calendar (and related calendars) | 184 * <td rowspan="3">Cyclic year name. Calendars such as the Chinese lunar
calendar (and related calendars) |
182 * and the Hindu calendars use 60-year cycles of year names. Use one thr
ough three letters for the abbreviated | 185 * and the Hindu calendars use 60-year cycles of year names. Use one thr
ough three letters for the abbreviated |
183 * name, four for the full name, or five for the narrow name (currently
the data only provides abbreviated names, | 186 * name, four for the full (wide) name, or five for the narrow name (cur
rently the data only provides abbreviated names, |
184 * which will be used for all requested name widths). If the calendar do
es not provide cyclic year name data, | 187 * which will be used for all requested name widths). If the calendar do
es not provide cyclic year name data, |
185 * or if the year value to be formatted is out of the range of years for
which cyclic name data is provided, | 188 * or if the year value to be formatted is out of the range of years for
which cyclic name data is provided, |
186 * then numeric formatting is used (behaves like 'y').</td> | 189 * then numeric formatting is used (behaves like 'y').</td> |
187 * </tr> | 190 * </tr> |
188 * <tr> | 191 * <tr> |
189 * <td style="text-align: center">4</td> | 192 * <td style="text-align: center">4</td> |
190 * <td>(currently also 甲子)</td> | 193 * <td>(currently also 甲子)</td> |
191 * </tr> | 194 * </tr> |
192 * <tr> | 195 * <tr> |
193 * <td style="text-align: center">5</td> | 196 * <td style="text-align: center">5</td> |
194 * <td>(currently also 甲子)</td> | 197 * <td>(currently also 甲子)</td> |
195 * </tr> | 198 * </tr> |
196 * <tr> | 199 * <tr> |
197 * <th rowspan="6">quarter</th> | 200 * <th rowspan="6">quarter</th> |
198 * <td rowspan="3" style="text-align: center">Q</td> | 201 * <td rowspan="3" style="text-align: center">Q</td> |
199 * <td style="text-align: center">1..2</td> | 202 * <td style="text-align: center">1..2</td> |
200 * <td>02</td> | 203 * <td>02</td> |
201 * <td rowspan="3">Quarter - Use one or two for the numerical quarter, t
hree for the abbreviation, or four | 204 * <td rowspan="3">Quarter - Use one or two for the numerical quarter, t
hree for the abbreviation, or four for the |
202 * for the full name.</td> | 205 * full (wide) name (five for the narrow name is not yet supported).</td
> |
203 * </tr> | 206 * </tr> |
204 * <tr> | 207 * <tr> |
205 * <td style="text-align: center">3</td> | 208 * <td style="text-align: center">3</td> |
206 * <td>Q2</td> | 209 * <td>Q2</td> |
207 * </tr> | 210 * </tr> |
208 * <tr> | 211 * <tr> |
209 * <td style="text-align: center">4</td> | 212 * <td style="text-align: center">4</td> |
210 * <td>2nd quarter</td> | 213 * <td>2nd quarter</td> |
211 * </tr> | 214 * </tr> |
212 * <tr> | 215 * <tr> |
213 * <td rowspan="3" style="text-align: center">q</td> | 216 * <td rowspan="3" style="text-align: center">q</td> |
214 * <td style="text-align: center">1..2</td> | 217 * <td style="text-align: center">1..2</td> |
215 * <td>02</td> | 218 * <td>02</td> |
216 * <td rowspan="3"><b>Stand-Alone</b> Quarter - Use one or two for the n
umerical quarter, three for the abbreviation, | 219 * <td rowspan="3"><b>Stand-Alone</b> Quarter - Use one or two for the n
umerical quarter, three for the abbreviation, |
217 * or four for the full name.</td> | 220 * or four for the full name (five for the narrow name is not yet suppor
ted).</td> |
218 * </tr> | 221 * </tr> |
219 * <tr> | 222 * <tr> |
220 * <td style="text-align: center">3</td> | 223 * <td style="text-align: center">3</td> |
221 * <td>Q2</td> | 224 * <td>Q2</td> |
222 * </tr> | 225 * </tr> |
223 * <tr> | 226 * <tr> |
224 * <td style="text-align: center">4</td> | 227 * <td style="text-align: center">4</td> |
225 * <td>2nd quarter</td> | 228 * <td>2nd quarter</td> |
226 * </tr> | 229 * </tr> |
227 * <tr> | 230 * <tr> |
228 * <th rowspan="8">month</th> | 231 * <th rowspan="8">month</th> |
229 * <td rowspan="4" style="text-align: center">M</td> | 232 * <td rowspan="4" style="text-align: center">M</td> |
230 * <td style="text-align: center">1..2</td> | 233 * <td style="text-align: center">1..2</td> |
231 * <td>09</td> | 234 * <td>09</td> |
232 * <td rowspan="4">Month - Use one or two for the numerical month, three
for the abbreviation, four for | 235 * <td rowspan="4">Month - Use one or two for the numerical month, three
for the abbreviation, four for |
233 * the full name, or five for the narrow name.</td> | 236 * the full (wide) name, or five for the narrow name. With two ("MM"), t
he month number is zero-padded |
| 237 * if necessary (e.g. "08")</td> |
234 * </tr> | 238 * </tr> |
235 * <tr> | 239 * <tr> |
236 * <td style="text-align: center">3</td> | 240 * <td style="text-align: center">3</td> |
237 * <td>Sept</td> | 241 * <td>Sep</td> |
238 * </tr> | 242 * </tr> |
239 * <tr> | 243 * <tr> |
240 * <td style="text-align: center">4</td> | 244 * <td style="text-align: center">4</td> |
241 * <td>September</td> | 245 * <td>September</td> |
242 * </tr> | 246 * </tr> |
243 * <tr> | 247 * <tr> |
244 * <td style="text-align: center">5</td> | 248 * <td style="text-align: center">5</td> |
245 * <td>S</td> | 249 * <td>S</td> |
246 * </tr> | 250 * </tr> |
247 * <tr> | 251 * <tr> |
248 * <td rowspan="4" style="text-align: center">L</td> | 252 * <td rowspan="4" style="text-align: center">L</td> |
249 * <td style="text-align: center">1..2</td> | 253 * <td style="text-align: center">1..2</td> |
250 * <td>09</td> | 254 * <td>09</td> |
251 * <td rowspan="4"><b>Stand-Alone</b> Month - Use one or two for the num
erical month, three for the abbreviation, | 255 * <td rowspan="4"><b>Stand-Alone</b> Month - Use one or two for the num
erical month, three for the abbreviation, |
252 * or four for the full name, or 5 for the narrow name.</td> | 256 * four for the full (wide) name, or 5 for the narrow name. With two ("L
L"), the month number is zero-padded if |
| 257 * necessary (e.g. "08")</td> |
253 * </tr> | 258 * </tr> |
254 * <tr> | 259 * <tr> |
255 * <td style="text-align: center">3</td> | 260 * <td style="text-align: center">3</td> |
256 * <td>Sept</td> | 261 * <td>Sep</td> |
257 * </tr> | 262 * </tr> |
258 * <tr> | 263 * <tr> |
259 * <td style="text-align: center">4</td> | 264 * <td style="text-align: center">4</td> |
260 * <td>September</td> | 265 * <td>September</td> |
261 * </tr> | 266 * </tr> |
262 * <tr> | 267 * <tr> |
263 * <td style="text-align: center">5</td> | 268 * <td style="text-align: center">5</td> |
264 * <td>S</td> | 269 * <td>S</td> |
265 * </tr> | 270 * </tr> |
266 * <tr> | 271 * <tr> |
267 * <th rowspan="2">week</th> | 272 * <th rowspan="2">week</th> |
268 * <td style="text-align: center">w</td> | 273 * <td style="text-align: center">w</td> |
269 * <td style="text-align: center">1..2</td> | 274 * <td style="text-align: center">1..2</td> |
270 * <td>27</td> | 275 * <td>27</td> |
271 * <td>Week of Year.</td> | 276 * <td>Week of Year. Use "w" to show the minimum number of digits, or "w
w" to always show two digits |
| 277 * (zero-padding if necessary, e.g. "08").</td> |
272 * </tr> | 278 * </tr> |
273 * <tr> | 279 * <tr> |
274 * <td style="text-align: center">W</td> | 280 * <td style="text-align: center">W</td> |
275 * <td style="text-align: center">1</td> | 281 * <td style="text-align: center">1</td> |
276 * <td>3</td> | 282 * <td>3</td> |
277 * <td>Week of Month</td> | 283 * <td>Week of Month</td> |
278 * </tr> | 284 * </tr> |
279 * <tr> | 285 * <tr> |
280 * <th rowspan="4">day</th> | 286 * <th rowspan="4">day</th> |
281 * <td style="text-align: center">d</td> | 287 * <td style="text-align: center">d</td> |
282 * <td style="text-align: center">1..2</td> | 288 * <td style="text-align: center">1..2</td> |
283 * <td>1</td> | 289 * <td>1</td> |
284 * <td>Date - Day of the month</td> | 290 * <td>Date - Day of the month. Use "d" to show the minimum number of di
gits, or "dd" to always show |
| 291 * two digits (zero-padding if necessary, e.g. "08").</td> |
285 * </tr> | 292 * </tr> |
286 * <tr> | 293 * <tr> |
287 * <td style="text-align: center">D</td> | 294 * <td style="text-align: center">D</td> |
288 * <td style="text-align: center">1..3</td> | 295 * <td style="text-align: center">1..3</td> |
289 * <td>345</td> | 296 * <td>345</td> |
290 * <td>Day of year</td> | 297 * <td>Day of year</td> |
291 * </tr> | 298 * </tr> |
292 * <tr> | 299 * <tr> |
293 * <td style="text-align: center">F</td> | 300 * <td style="text-align: center">F</td> |
294 * <td style="text-align: center">1</td> | 301 * <td style="text-align: center">1</td> |
295 * <td>2</td> | 302 * <td>2</td> |
296 * <td>Day of Week in Month. The example is for the 2nd Wed in July</td> | 303 * <td>Day of Week in Month. The example is for the 2nd Wed in July</td> |
297 * </tr> | 304 * </tr> |
298 * <tr> | 305 * <tr> |
299 * <td style="text-align: center">g</td> | 306 * <td style="text-align: center">g</td> |
300 * <td style="text-align: center">1..n</td> | 307 * <td style="text-align: center">1..n</td> |
301 * <td>2451334</td> | 308 * <td>2451334</td> |
302 * <td>Modified Julian day. This is different from the conventional Juli
an day number in two regards. | 309 * <td>Modified Julian day. This is different from the conventional Juli
an day number in two regards. |
303 * First, it demarcates days at local zone midnight, rather than noon GM
T. Second, it is a local number; | 310 * First, it demarcates days at local zone midnight, rather than noon GM
T. Second, it is a local number; |
304 * that is, it depends on the local time zone. It can be thought of as a
single number that encompasses | 311 * that is, it depends on the local time zone. It can be thought of as a
single number that encompasses |
305 * all the date-related fields.</td> | 312 * all the date-related fields.</td> |
306 * </tr> | 313 * </tr> |
307 * <tr> | 314 * <tr> |
308 * <th rowspan="14">week<br> | 315 * <th rowspan="14">week<br> |
309 * day</th> | 316 * day</th> |
310 * <td rowspan="4" style="text-align: center">E</td> | 317 * <td rowspan="4" style="text-align: center">E</td> |
311 * <td style="text-align: center">1..3</td> | 318 * <td style="text-align: center">1..3</td> |
312 * <td>Tues</td> | 319 * <td>Tue</td> |
313 * <td rowspan="4">Day of week - Use one through three letters for the s
hort day, or four for the full name, | 320 * <td rowspan="4">Day of week - Use one through three letters for the s
hort day, four for the full (wide) name, |
314 * five for the narrow name, or six for the short name.</td> | 321 * five for the narrow name, or six for the short name.</td> |
315 * </tr> | 322 * </tr> |
316 * <tr> | 323 * <tr> |
317 * <td style="text-align: center">4</td> | 324 * <td style="text-align: center">4</td> |
318 * <td>Tuesday</td> | 325 * <td>Tuesday</td> |
319 * </tr> | 326 * </tr> |
320 * <tr> | 327 * <tr> |
321 * <td style="text-align: center">5</td> | 328 * <td style="text-align: center">5</td> |
322 * <td>T</td> | 329 * <td>T</td> |
323 * </tr> | 330 * </tr> |
324 * <tr> | 331 * <tr> |
325 * <td style="text-align: center">6</td> | 332 * <td style="text-align: center">6</td> |
326 * <td>Tu</td> | 333 * <td>Tu</td> |
327 * </tr> | 334 * </tr> |
328 * <tr> | 335 * <tr> |
329 * <td rowspan="5" style="text-align: center">e</td> | 336 * <td rowspan="5" style="text-align: center">e</td> |
330 * <td style="text-align: center">1..2</td> | 337 * <td style="text-align: center">1..2</td> |
331 * <td>2</td> | 338 * <td>2</td> |
332 * <td rowspan="5">Local day of week. Same as E except adds a numeric va
lue that will depend on the local | 339 * <td rowspan="5">Local day of week. Same as E except adds a numeric va
lue that will depend on the local |
333 * starting day of the week, using one or two letters. For this example,
Monday is the first day of the week.</td> | 340 * starting day of the week, using one or two letters. For this example,
Monday is the first day of the week.</td> |
334 * </tr> | 341 * </tr> |
335 * <tr> | 342 * <tr> |
336 * <td style="text-align: center">3</td> | 343 * <td style="text-align: center">3</td> |
337 * <td>Tues</td> | 344 * <td>Tue</td> |
338 * </tr> | 345 * </tr> |
339 * <tr> | 346 * <tr> |
340 * <td style="text-align: center">4</td> | 347 * <td style="text-align: center">4</td> |
341 * <td>Tuesday</td> | 348 * <td>Tuesday</td> |
342 * </tr> | 349 * </tr> |
343 * <tr> | 350 * <tr> |
344 * <td style="text-align: center">5</td> | 351 * <td style="text-align: center">5</td> |
345 * <td>T</td> | 352 * <td>T</td> |
346 * </tr> | 353 * </tr> |
347 * <tr> | 354 * <tr> |
348 * <td style="text-align: center">6</td> | 355 * <td style="text-align: center">6</td> |
349 * <td>Tu</td> | 356 * <td>Tu</td> |
350 * </tr> | 357 * </tr> |
351 * <tr> | 358 * <tr> |
352 * <td rowspan="5" style="text-align: center">c</td> | 359 * <td rowspan="5" style="text-align: center">c</td> |
353 * <td style="text-align: center">1</td> | 360 * <td style="text-align: center">1</td> |
354 * <td>2</td> | 361 * <td>2</td> |
355 * <td rowspan="5"><b>Stand-Alone</b> local day of week - Use one letter
for the local numeric value (same | 362 * <td rowspan="5"><b>Stand-Alone</b> local day of week - Use one letter
for the local numeric value (same |
356 * as 'e'), three for the short day, four for the full name, five for th
e narrow name, or six for | 363 * as 'e'), three for the short day, four for the full (wide) name, five
for the narrow name, or six for |
357 * the short name.</td> | 364 * the short name.</td> |
358 * </tr> | 365 * </tr> |
359 * <tr> | 366 * <tr> |
360 * <td style="text-align: center">3</td> | 367 * <td style="text-align: center">3</td> |
361 * <td>Tues</td> | 368 * <td>Tue</td> |
362 * </tr> | 369 * </tr> |
363 * <tr> | 370 * <tr> |
364 * <td style="text-align: center">4</td> | 371 * <td style="text-align: center">4</td> |
365 * <td>Tuesday</td> | 372 * <td>Tuesday</td> |
366 * </tr> | 373 * </tr> |
367 * <tr> | 374 * <tr> |
368 * <td style="text-align: center">5</td> | 375 * <td style="text-align: center">5</td> |
369 * <td>T</td> | 376 * <td>T</td> |
370 * </tr> | 377 * </tr> |
371 * <tr> | 378 * <tr> |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 * <td style="text-align: center">k</td> | 413 * <td style="text-align: center">k</td> |
407 * <td style="text-align: center">1..2</td> | 414 * <td style="text-align: center">1..2</td> |
408 * <td>24</td> | 415 * <td>24</td> |
409 * <td>Hour [1-24]. When used in a skeleton, only matches k or H, see ab
ove. Use kk for zero padding.</td> | 416 * <td>Hour [1-24]. When used in a skeleton, only matches k or H, see ab
ove. Use kk for zero padding.</td> |
410 * </tr> | 417 * </tr> |
411 * <tr> | 418 * <tr> |
412 * <th>minute</th> | 419 * <th>minute</th> |
413 * <td style="text-align: center">m</td> | 420 * <td style="text-align: center">m</td> |
414 * <td style="text-align: center">1..2</td> | 421 * <td style="text-align: center">1..2</td> |
415 * <td>59</td> | 422 * <td>59</td> |
416 * <td>Minute. Use one or two for zero padding.</td> | 423 * <td>Minute. Use "m" to show the minimum number of digits, or "mm" to
always show two digits |
| 424 * (zero-padding if necessary, e.g. "08").</td> |
417 * </tr> | 425 * </tr> |
418 * <tr> | 426 * <tr> |
419 * <th rowspan="3">second</th> | 427 * <th rowspan="3">second</th> |
420 * <td style="text-align: center">s</td> | 428 * <td style="text-align: center">s</td> |
421 * <td style="text-align: center">1..2</td> | 429 * <td style="text-align: center">1..2</td> |
422 * <td>12</td> | 430 * <td>12</td> |
423 * <td>Second. Use one or two for zero padding.</td> | 431 * <td>Second. Use "s" to show the minimum number of digits, or "ss" to
always show two digits |
| 432 * (zero-padding if necessary, e.g. "08").</td> |
424 * </tr> | 433 * </tr> |
425 * <tr> | 434 * <tr> |
426 * <td style="text-align: center">S</td> | 435 * <td style="text-align: center">S</td> |
427 * <td style="text-align: center">1..n</td> | 436 * <td style="text-align: center">1..n</td> |
428 * <td>3456</td> | 437 * <td>3450</td> |
429 * <td>Fractional Second - truncates (like other time fields) to the cou
nt of letters. | 438 * <td>Fractional Second - truncates (like other time fields) to the cou
nt of letters when formatting. |
| 439 * Appends zeros if more than 3 letters specified. Truncates at three si
gnificant digits when parsing. |
430 * (example shows display using pattern SSSS for seconds value 12.34567)
</td> | 440 * (example shows display using pattern SSSS for seconds value 12.34567)
</td> |
431 * </tr> | 441 * </tr> |
432 * <tr> | 442 * <tr> |
433 * <td style="text-align: center">A</td> | 443 * <td style="text-align: center">A</td> |
434 * <td style="text-align: center">1..n</td> | 444 * <td style="text-align: center">1..n</td> |
435 * <td>69540000</td> | 445 * <td>69540000</td> |
436 * <td>Milliseconds in day. This field behaves <i>exactly</i> like a com
posite of all time-related fields, | 446 * <td>Milliseconds in day. This field behaves <i>exactly</i> like a com
posite of all time-related fields, |
437 * not including the zone fields. As such, it also reflects discontinuit
ies of those fields on DST transition | 447 * not including the zone fields. As such, it also reflects discontinuit
ies of those fields on DST transition |
438 * days. On a day of DST onset, it will jump forward. On a day of DST ce
ssation, it will jump backward. This | 448 * days. On a day of DST onset, it will jump forward. On a day of DST ce
ssation, it will jump backward. This |
439 * reflects the fact that is must be combined with the offset field to o
btain a unique local time value.</td> | 449 * reflects the fact that is must be combined with the offset field to o
btain a unique local time value.</td> |
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1076 * Set the calendar to be used by this date format. Initially, the default | 1086 * Set the calendar to be used by this date format. Initially, the default |
1077 * calendar for the specified or default locale is used. The caller should | 1087 * calendar for the specified or default locale is used. The caller should |
1078 * not delete the Calendar object after it is adopted by this call. | 1088 * not delete the Calendar object after it is adopted by this call. |
1079 * Adopting a new calendar will change to the default symbols. | 1089 * Adopting a new calendar will change to the default symbols. |
1080 * | 1090 * |
1081 * @param calendarToAdopt Calendar object to be adopted. | 1091 * @param calendarToAdopt Calendar object to be adopted. |
1082 * @stable ICU 2.0 | 1092 * @stable ICU 2.0 |
1083 */ | 1093 */ |
1084 virtual void adoptCalendar(Calendar* calendarToAdopt); | 1094 virtual void adoptCalendar(Calendar* calendarToAdopt); |
1085 | 1095 |
1086 /* Cannot use #ifndef U_HIDE_DRAFT_API for the following draft method since
it is virtual */ | |
1087 /** | |
1088 * Set a particular UDisplayContext value in the formatter, such as | |
1089 * UDISPCTX_CAPITALIZATION_FOR_STANDALONE. | |
1090 * @param value The UDisplayContext value to set. | |
1091 * @param status Input/output status. If at entry this indicates a failure | |
1092 * status, the function will do nothing; otherwise this will b
e | |
1093 * updated with any new status from the function. | |
1094 * @draft ICU 51 | |
1095 */ | |
1096 virtual void setContext(UDisplayContext value, UErrorCode& status); | |
1097 | |
1098 /* Cannot use #ifndef U_HIDE_DRAFT_API for the following draft method since
it is virtual */ | |
1099 /** | |
1100 * Get the formatter's UDisplayContext value for the specified UDisplayConte
xtType, | |
1101 * such as UDISPCTX_TYPE_CAPITALIZATION. | |
1102 * @param type The UDisplayContextType whose value to return | |
1103 * @param status Input/output status. If at entry this indicates a failure | |
1104 * status, the function will do nothing; otherwise this will b
e | |
1105 * updated with any new status from the function. | |
1106 * @return The UDisplayContextValue for the specified type. | |
1107 * @draft ICU 51 | |
1108 */ | |
1109 virtual UDisplayContext getContext(UDisplayContextType type, UErrorCode& sta
tus) const; | |
1110 | |
1111 /* Cannot use #ifndef U_HIDE_INTERNAL_API for the following methods since th
ey are virtual */ | 1096 /* Cannot use #ifndef U_HIDE_INTERNAL_API for the following methods since th
ey are virtual */ |
1112 /** | 1097 /** |
1113 * Sets the TimeZoneFormat to be used by this date/time formatter. | 1098 * Sets the TimeZoneFormat to be used by this date/time formatter. |
1114 * The caller should not delete the TimeZoneFormat object after | 1099 * The caller should not delete the TimeZoneFormat object after |
1115 * it is adopted by this call. | 1100 * it is adopted by this call. |
1116 * @param timeZoneFormatToAdopt The TimeZoneFormat object to be adopted. | 1101 * @param timeZoneFormatToAdopt The TimeZoneFormat object to be adopted. |
1117 * @internal ICU 49 technology preview | 1102 * @internal ICU 49 technology preview |
1118 */ | 1103 */ |
1119 virtual void adoptTimeZoneFormat(TimeZoneFormat* timeZoneFormatToAdopt); | 1104 virtual void adoptTimeZoneFormat(TimeZoneFormat* timeZoneFormatToAdopt); |
1120 | 1105 |
1121 /** | 1106 /** |
1122 * Sets the TimeZoneFormat to be used by this date/time formatter. | 1107 * Sets the TimeZoneFormat to be used by this date/time formatter. |
1123 * @param newTimeZoneFormat The TimeZoneFormat object to copy. | 1108 * @param newTimeZoneFormat The TimeZoneFormat object to copy. |
1124 * @internal ICU 49 technology preview | 1109 * @internal ICU 49 technology preview |
1125 */ | 1110 */ |
1126 virtual void setTimeZoneFormat(const TimeZoneFormat& newTimeZoneFormat); | 1111 virtual void setTimeZoneFormat(const TimeZoneFormat& newTimeZoneFormat); |
1127 | 1112 |
1128 /** | 1113 /** |
1129 * Gets the time zone format object associated with this date/time formatter
. | 1114 * Gets the time zone format object associated with this date/time formatter
. |
1130 * @return the time zone format associated with this date/time formatter. | 1115 * @return the time zone format associated with this date/time formatter. |
1131 * @internal ICU 49 technology preview | 1116 * @internal ICU 49 technology preview |
1132 */ | 1117 */ |
1133 virtual const TimeZoneFormat* getTimeZoneFormat(void) const; | 1118 virtual const TimeZoneFormat* getTimeZoneFormat(void) const; |
1134 | 1119 |
| 1120 /* Cannot use #ifndef U_HIDE_DRAFT_API for the following draft method since
it is virtual */ |
| 1121 /** |
| 1122 * Set a particular UDisplayContext value in the formatter, such as |
| 1123 * UDISPCTX_CAPITALIZATION_FOR_STANDALONE. Note: For getContext, see |
| 1124 * DateFormat. |
| 1125 * @param value The UDisplayContext value to set. |
| 1126 * @param status Input/output status. If at entry this indicates a failure |
| 1127 * status, the function will do nothing; otherwise this will b
e |
| 1128 * updated with any new status from the function. |
| 1129 * @draft ICU 53 |
| 1130 */ |
| 1131 virtual void setContext(UDisplayContext value, UErrorCode& status); |
| 1132 |
| 1133 #ifndef U_HIDE_DRAFT_API |
| 1134 /** |
| 1135 * Overrides base class method and |
| 1136 * This method clears per field NumberFormat instances |
| 1137 * previously set by {@see adoptNumberFormat(const UnicodeString&, NumberFor
mat*, UErrorCode)} |
| 1138 * @param adoptNF the NumbeferFormat used |
| 1139 * @draft ICU 54 |
| 1140 */ |
| 1141 void adoptNumberFormat(NumberFormat *formatToAdopt); |
| 1142 |
| 1143 /** |
| 1144 * Allow the user to set the NumberFormat for several fields |
| 1145 * It can be a single field like: "y"(year) or "M"(month) |
| 1146 * It can be several field combined together: "yM"(year and month) |
| 1147 * Note: |
| 1148 * 1 symbol field is enough for multiple symbol field (so "y" will override
"yy", "yyy") |
| 1149 * If the field is not numeric, then override has no effect (like "MMM" will
use abbreviation, not numerical field) |
| 1150 * Per field NumberFormat can also be cleared in {@see DateFormat::setNumber
Format(const NumberFormat& newNumberFormat)} |
| 1151 * |
| 1152 * @param fields the fields to override(like y) |
| 1153 * @param adoptNF the NumbeferFormat used |
| 1154 * @param status Receives a status code, which will be U_ZERO_ERROR |
| 1155 * if the operation succeeds. |
| 1156 * @draft ICU 54 |
| 1157 */ |
| 1158 void adoptNumberFormat(const UnicodeString& fields, NumberFormat *formatToAd
opt, UErrorCode &status); |
| 1159 |
| 1160 /** |
| 1161 * Get the numbering system to be used for a particular field. |
| 1162 * @param field The UDateFormatField to get |
| 1163 * @draft ICU 54 |
| 1164 */ |
| 1165 const NumberFormat * getNumberFormatForField(UChar field) const; |
| 1166 #endif /* U_HIDE_DRAFT_API */ |
| 1167 |
1135 #ifndef U_HIDE_INTERNAL_API | 1168 #ifndef U_HIDE_INTERNAL_API |
1136 /** | 1169 /** |
1137 * This is for ICU internal use only. Please do not use. | 1170 * This is for ICU internal use only. Please do not use. |
1138 * Check whether the 'field' is smaller than all the fields covered in | 1171 * Check whether the 'field' is smaller than all the fields covered in |
1139 * pattern, return TRUE if it is. The sequence of calendar field, | 1172 * pattern, return TRUE if it is. The sequence of calendar field, |
1140 * from large to small is: ERA, YEAR, MONTH, DATE, AM_PM, HOUR, MINUTE,... | 1173 * from large to small is: ERA, YEAR, MONTH, DATE, AM_PM, HOUR, MINUTE,... |
1141 * @param field the calendar field need to check against | 1174 * @param field the calendar field need to check against |
1142 * @return TRUE if the 'field' is smaller than all the fields | 1175 * @return TRUE if the 'field' is smaller than all the fields |
1143 * covered in pattern. FALSE otherwise. | 1176 * covered in pattern. FALSE otherwise. |
1144 * @internal ICU 4.0 | 1177 * @internal ICU 4.0 |
(...skipping 24 matching lines...) Expand all Loading... |
1169 * @internal ICU 4.0 | 1202 * @internal ICU 4.0 |
1170 */ | 1203 */ |
1171 const Locale& getSmpFmtLocale(void) const; | 1204 const Locale& getSmpFmtLocale(void) const; |
1172 #endif /* U_HIDE_INTERNAL_API */ | 1205 #endif /* U_HIDE_INTERNAL_API */ |
1173 | 1206 |
1174 private: | 1207 private: |
1175 friend class DateFormat; | 1208 friend class DateFormat; |
1176 | 1209 |
1177 void initializeDefaultCentury(void); | 1210 void initializeDefaultCentury(void); |
1178 | 1211 |
| 1212 void initializeBooleanAttributes(void); |
| 1213 |
1179 SimpleDateFormat(); // default constructor not implemented | 1214 SimpleDateFormat(); // default constructor not implemented |
1180 | 1215 |
1181 /** | 1216 /** |
1182 * Used by the DateFormat factory methods to construct a SimpleDateFormat. | 1217 * Used by the DateFormat factory methods to construct a SimpleDateFormat. |
1183 * @param timeStyle the time style. | 1218 * @param timeStyle the time style. |
1184 * @param dateStyle the date style. | 1219 * @param dateStyle the date style. |
1185 * @param locale the given locale. | 1220 * @param locale the given locale. |
1186 * @param status Output param set to success/failure code on | 1221 * @param status Output param set to success/failure code on |
1187 * exit. | 1222 * exit. |
1188 */ | 1223 */ |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1333 | 1368 |
1334 /** | 1369 /** |
1335 * Private function used by subParse to match literal pattern text. | 1370 * Private function used by subParse to match literal pattern text. |
1336 * | 1371 * |
1337 * @param pattern the pattern string | 1372 * @param pattern the pattern string |
1338 * @param patternOffset the starting offset into the pattern text. On | 1373 * @param patternOffset the starting offset into the pattern text. On |
1339 * outupt will be set the offset of the first non-literal character i
n the pattern | 1374 * outupt will be set the offset of the first non-literal character i
n the pattern |
1340 * @param text the text being parsed | 1375 * @param text the text being parsed |
1341 * @param textOffset the starting offset into the text. On output | 1376 * @param textOffset the starting offset into the text. On output |
1342 * will be set to the offset of the character after the ma
tch | 1377 * will be set to the offset of the character after the ma
tch |
1343 * @param lenient <code>TRUE</code> if the parse is lenient, <code>FALSE</co
de> otherwise. | 1378 * @param whitespaceLenient <code>TRUE</code> if whitespace parse is lenient
, <code>FALSE</code> otherwise. |
| 1379 * @param partialMatchLenient <code>TRUE</code> if partial match parse is le
nient, <code>FALSE</code> otherwise. |
| 1380 * @param oldLeniency <code>TRUE</code> if old leniency control is lenient,
<code>FALSE</code> otherwise. |
1344 * | 1381 * |
1345 * @return <code>TRUE</code> if the literal text could be matched, <code>FAL
SE</code> otherwise. | 1382 * @return <code>TRUE</code> if the literal text could be matched, <code>FAL
SE</code> otherwise. |
1346 */ | 1383 */ |
1347 static UBool matchLiterals(const UnicodeString &pattern, int32_t &patternOff
set, | 1384 static UBool matchLiterals(const UnicodeString &pattern, int32_t &patternOff
set, |
1348 const UnicodeString &text, int32_t &textOffset, U
Bool lenient); | 1385 const UnicodeString &text, int32_t &textOffset, |
| 1386 UBool whitespaceLenient, UBool partialMatchLenien
t, UBool oldLeniency); |
1349 | 1387 |
1350 /** | 1388 /** |
1351 * Private member function that converts the parsed date strings into | 1389 * Private member function that converts the parsed date strings into |
1352 * timeFields. Returns -start (for ParsePosition) if failed. | 1390 * timeFields. Returns -start (for ParsePosition) if failed. |
1353 * @param text the time text to be parsed. | 1391 * @param text the time text to be parsed. |
1354 * @param start where to start parsing. | 1392 * @param start where to start parsing. |
1355 * @param ch the pattern character for the date field text to be parsed. | 1393 * @param ch the pattern character for the date field text to be parsed. |
1356 * @param count the count of a pattern character. | 1394 * @param count the count of a pattern character. |
1357 * @param obeyCount if true then the count is strictly obeyed. | 1395 * @param obeyCount if true then the count is strictly obeyed. |
1358 * @param allowNegative | 1396 * @param allowNegative |
1359 * @param ambiguousYear If true then the two-digit year == the default start
year. | 1397 * @param ambiguousYear If true then the two-digit year == the default start
year. |
1360 * @param saveHebrewMonth Used to hang onto month until year is known. | 1398 * @param saveHebrewMonth Used to hang onto month until year is known. |
1361 * @param cal a Calendar set to the date and time to be formatted | 1399 * @param cal a Calendar set to the date and time to be formatted |
1362 * into a date/time string. | 1400 * into a date/time string. |
1363 * @param patLoc | 1401 * @param patLoc |
1364 * @param numericLeapMonthFormatter If non-null, used to parse numeric leap
months. | 1402 * @param numericLeapMonthFormatter If non-null, used to parse numeric leap
months. |
| 1403 * @param tzTimeType the type of parsed time zone - standard, daylight or un
known (output). |
| 1404 * This parameter can be NULL if caller does not need the information. |
1365 * @return the new start position if matching succeeded; a negative number | 1405 * @return the new start position if matching succeeded; a negative number |
1366 * indicating matching failure, otherwise. | 1406 * indicating matching failure, otherwise. |
1367 */ | 1407 */ |
1368 int32_t subParse(const UnicodeString& text, int32_t& start, UChar ch, int32_
t count, | 1408 int32_t subParse(const UnicodeString& text, int32_t& start, UChar ch, int32_
t count, |
1369 UBool obeyCount, UBool allowNegative, UBool ambiguousYear[]
, int32_t& saveHebrewMonth, Calendar& cal, | 1409 UBool obeyCount, UBool allowNegative, UBool ambiguousYear[]
, int32_t& saveHebrewMonth, Calendar& cal, |
1370 int32_t patLoc, MessageFormat * numericLeapMonthFormatter)
const; | 1410 int32_t patLoc, MessageFormat * numericLeapMonthFormatter,
UTimeZoneFormatTimeType *tzTimeType) const; |
1371 | 1411 |
1372 void parseInt(const UnicodeString& text, | 1412 void parseInt(const UnicodeString& text, |
1373 Formattable& number, | 1413 Formattable& number, |
1374 ParsePosition& pos, | 1414 ParsePosition& pos, |
1375 UBool allowNegative, | 1415 UBool allowNegative, |
1376 NumberFormat *fmt) const; | 1416 NumberFormat *fmt) const; |
1377 | 1417 |
1378 void parseInt(const UnicodeString& text, | 1418 void parseInt(const UnicodeString& text, |
1379 Formattable& number, | 1419 Formattable& number, |
1380 int32_t maxDigits, | 1420 int32_t maxDigits, |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1516 * defaultCenturyStartYear are only used if explicitly set by the user | 1556 * defaultCenturyStartYear are only used if explicitly set by the user |
1517 * through the API method parseAmbiguousDatesAsAfter(). | 1557 * through the API method parseAmbiguousDatesAsAfter(). |
1518 */ | 1558 */ |
1519 UDate fDefaultCenturyStart; | 1559 UDate fDefaultCenturyStart; |
1520 | 1560 |
1521 /** | 1561 /** |
1522 * See documentation for defaultCenturyStart. | 1562 * See documentation for defaultCenturyStart. |
1523 */ | 1563 */ |
1524 /*transient*/ int32_t fDefaultCenturyStartYear; | 1564 /*transient*/ int32_t fDefaultCenturyStartYear; |
1525 | 1565 |
1526 int32_t tztype; // here to avoid api change | |
1527 | |
1528 typedef struct NSOverride { | 1566 typedef struct NSOverride { |
1529 NumberFormat *nf; | 1567 NumberFormat *nf; |
1530 int32_t hash; | 1568 int32_t hash; |
1531 NSOverride *next; | 1569 NSOverride *next; |
1532 } NSOverride; | 1570 } NSOverride; |
1533 | 1571 |
1534 NumberFormat **fNumberFormatters; | 1572 NumberFormat **fNumberFormatters; |
1535 | 1573 |
1536 NSOverride *fOverrideList; | 1574 NSOverride *fOverrideList; |
1537 | 1575 |
1538 UBool fHaveDefaultCentury; | 1576 UBool fHaveDefaultCentury; |
1539 | 1577 |
1540 UDisplayContext fCapitalizationContext; | 1578 BreakIterator* fCapitalizationBrkIter; |
1541 }; | 1579 }; |
1542 | 1580 |
1543 inline UDate | 1581 inline UDate |
1544 SimpleDateFormat::get2DigitYearStart(UErrorCode& /*status*/) const | 1582 SimpleDateFormat::get2DigitYearStart(UErrorCode& /*status*/) const |
1545 { | 1583 { |
1546 return fDefaultCenturyStart; | 1584 return fDefaultCenturyStart; |
1547 } | 1585 } |
1548 | 1586 |
1549 U_NAMESPACE_END | 1587 U_NAMESPACE_END |
1550 | 1588 |
1551 #endif /* #if !UCONFIG_NO_FORMATTING */ | 1589 #endif /* #if !UCONFIG_NO_FORMATTING */ |
1552 | 1590 |
1553 #endif // _SMPDTFMT | 1591 #endif // _SMPDTFMT |
1554 //eof | 1592 //eof |
OLD | NEW |