]> git.saurik.com Git - apple/icu.git/blob - icuSources/i18n/unicode/udatpg.h
4319aa5108a5d3ba67d18f401f90350126c68500
[apple/icu.git] / icuSources / i18n / unicode / udatpg.h
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 *******************************************************************************
5 *
6 * Copyright (C) 2007-2015, International Business Machines
7 * Corporation and others. All Rights Reserved.
8 *
9 *******************************************************************************
10 * file name: udatpg.h
11 * encoding: UTF-8
12 * tab size: 8 (not used)
13 * indentation:4
14 *
15 * created on: 2007jul30
16 * created by: Markus W. Scherer
17 */
18
19 #ifndef __UDATPG_H__
20 #define __UDATPG_H__
21
22 #include "unicode/utypes.h"
23 #include "unicode/uenum.h"
24 #include "unicode/localpointer.h"
25
26 /**
27 * \file
28 * \brief C API: Wrapper for icu::DateTimePatternGenerator (unicode/dtptngen.h).
29 *
30 * UDateTimePatternGenerator provides flexible generation of date format patterns,
31 * like "yy-MM-dd". The user can build up the generator by adding successive
32 * patterns. Once that is done, a query can be made using a "skeleton", which is
33 * a pattern which just includes the desired fields and lengths. The generator
34 * will return the "best fit" pattern corresponding to that skeleton.
35 * <p>The main method people will use is udatpg_getBestPattern, since normally
36 * UDateTimePatternGenerator is pre-built with data from a particular locale.
37 * However, generators can be built directly from other data as well.
38 * <p><i>Issue: may be useful to also have a function that returns the list of
39 * fields in a pattern, in order, since we have that internally.
40 * That would be useful for getting the UI order of field elements.</i>
41 */
42
43 /**
44 * Opaque type for a date/time pattern generator object.
45 * @stable ICU 3.8
46 */
47 typedef void *UDateTimePatternGenerator;
48
49 /**
50 * Field number constants for udatpg_getAppendItemFormats() and similar functions.
51 * These constants are separate from UDateFormatField despite semantic overlap
52 * because some fields are merged for the date/time pattern generator.
53 * @stable ICU 3.8
54 */
55 typedef enum UDateTimePatternField {
56 /** @stable ICU 3.8 */
57 UDATPG_ERA_FIELD,
58 /** @stable ICU 3.8 */
59 UDATPG_YEAR_FIELD,
60 /** @stable ICU 3.8 */
61 UDATPG_QUARTER_FIELD,
62 /** @stable ICU 3.8 */
63 UDATPG_MONTH_FIELD,
64 /** @stable ICU 3.8 */
65 UDATPG_WEEK_OF_YEAR_FIELD,
66 /** @stable ICU 3.8 */
67 UDATPG_WEEK_OF_MONTH_FIELD,
68 /** @stable ICU 3.8 */
69 UDATPG_WEEKDAY_FIELD,
70 /** @stable ICU 3.8 */
71 UDATPG_DAY_OF_YEAR_FIELD,
72 /** @stable ICU 3.8 */
73 UDATPG_DAY_OF_WEEK_IN_MONTH_FIELD,
74 /** @stable ICU 3.8 */
75 UDATPG_DAY_FIELD,
76 /** @stable ICU 3.8 */
77 UDATPG_DAYPERIOD_FIELD,
78 /** @stable ICU 3.8 */
79 UDATPG_HOUR_FIELD,
80 /** @stable ICU 3.8 */
81 UDATPG_MINUTE_FIELD,
82 /** @stable ICU 3.8 */
83 UDATPG_SECOND_FIELD,
84 /** @stable ICU 3.8 */
85 UDATPG_FRACTIONAL_SECOND_FIELD,
86 /** @stable ICU 3.8 */
87 UDATPG_ZONE_FIELD,
88
89 /* Do not conditionalize the following with #ifndef U_HIDE_DEPRECATED_API,
90 * it is needed for layout of DateTimePatternGenerator object. */
91 #ifndef U_FORCE_HIDE_DEPRECATED_API
92 /**
93 * One more than the highest normal UDateTimePatternField value.
94 * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
95 */
96 UDATPG_FIELD_COUNT
97 #endif // U_FORCE_HIDE_DEPRECATED_API
98 } UDateTimePatternField;
99
100 /**
101 * Field display name width constants for udatpg_getFieldDisplayName().
102 * @stable ICU 61
103 */
104 typedef enum UDateTimePGDisplayWidth {
105 /** @stable ICU 61 */
106 UDATPG_WIDE,
107 /** @stable ICU 61 */
108 UDATPG_ABBREVIATED,
109 /** @stable ICU 61 */
110 UDATPG_NARROW
111 } UDateTimePGDisplayWidth;
112
113 /**
114 * Masks to control forcing the length of specified fields in the returned
115 * pattern to match those in the skeleton (when this would not happen
116 * otherwise). These may be combined to force the length of multiple fields.
117 * Used with udatpg_getBestPatternWithOptions, udatpg_replaceFieldTypesWithOptions.
118 * @stable ICU 4.4
119 */
120 typedef enum UDateTimePatternMatchOptions {
121 /** @stable ICU 4.4 */
122 UDATPG_MATCH_NO_OPTIONS = 0,
123 /** @stable ICU 4.4 */
124 UDATPG_MATCH_HOUR_FIELD_LENGTH = 1 << UDATPG_HOUR_FIELD,
125 #ifndef U_HIDE_INTERNAL_API
126 /** @internal ICU 4.4 */
127 UDATPG_MATCH_MINUTE_FIELD_LENGTH = 1 << UDATPG_MINUTE_FIELD,
128 /** @internal ICU 4.4 */
129 UDATPG_MATCH_SECOND_FIELD_LENGTH = 1 << UDATPG_SECOND_FIELD,
130 #endif /* U_HIDE_INTERNAL_API */
131 /** @stable ICU 4.4 */
132 UDATPG_MATCH_ALL_FIELDS_LENGTH = (1 << UDATPG_FIELD_COUNT) - 1,
133 /** @internal, Apple-specific for now */
134 UADATPG_FORCE_12_HOUR_CYCLE = 1 << 29,
135 /** @internal, Apple-specific for now */
136 UADATPG_FORCE_24_HOUR_CYCLE = 1 << 30,
137 /** @internal, Apple-specific for now */
138 UADATPG_FORCE_HOUR_CYCLE_MASK = 3 << 29,
139 } UDateTimePatternMatchOptions;
140
141 /**
142 * Status return values from udatpg_addPattern().
143 * @stable ICU 3.8
144 */
145 typedef enum UDateTimePatternConflict {
146 /** @stable ICU 3.8 */
147 UDATPG_NO_CONFLICT,
148 /** @stable ICU 3.8 */
149 UDATPG_BASE_CONFLICT,
150 /** @stable ICU 3.8 */
151 UDATPG_CONFLICT,
152 #ifndef U_HIDE_DEPRECATED_API
153 /**
154 * One more than the highest normal UDateTimePatternConflict value.
155 * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
156 */
157 UDATPG_CONFLICT_COUNT
158 #endif // U_HIDE_DEPRECATED_API
159 } UDateTimePatternConflict;
160
161 /**
162 * Open a generator according to a given locale.
163 * @param locale
164 * @param pErrorCode a pointer to the UErrorCode which must not indicate a
165 * failure before the function call.
166 * @return a pointer to UDateTimePatternGenerator.
167 * @stable ICU 3.8
168 */
169 U_STABLE UDateTimePatternGenerator * U_EXPORT2
170 udatpg_open(const char *locale, UErrorCode *pErrorCode);
171
172 /**
173 * Open an empty generator, to be constructed with udatpg_addPattern(...) etc.
174 * @param pErrorCode a pointer to the UErrorCode which must not indicate a
175 * failure before the function call.
176 * @return a pointer to UDateTimePatternGenerator.
177 * @stable ICU 3.8
178 */
179 U_STABLE UDateTimePatternGenerator * U_EXPORT2
180 udatpg_openEmpty(UErrorCode *pErrorCode);
181
182 /**
183 * Close a generator.
184 * @param dtpg a pointer to UDateTimePatternGenerator.
185 * @stable ICU 3.8
186 */
187 U_STABLE void U_EXPORT2
188 udatpg_close(UDateTimePatternGenerator *dtpg);
189
190 #if U_SHOW_CPLUSPLUS_API
191
192 U_NAMESPACE_BEGIN
193
194 /**
195 * \class LocalUDateTimePatternGeneratorPointer
196 * "Smart pointer" class, closes a UDateTimePatternGenerator via udatpg_close().
197 * For most methods see the LocalPointerBase base class.
198 *
199 * @see LocalPointerBase
200 * @see LocalPointer
201 * @stable ICU 4.4
202 */
203 U_DEFINE_LOCAL_OPEN_POINTER(LocalUDateTimePatternGeneratorPointer, UDateTimePatternGenerator, udatpg_close);
204
205 U_NAMESPACE_END
206
207 #endif
208
209 /**
210 * Create a copy pf a generator.
211 * @param dtpg a pointer to UDateTimePatternGenerator to be copied.
212 * @param pErrorCode a pointer to the UErrorCode which must not indicate a
213 * failure before the function call.
214 * @return a pointer to a new UDateTimePatternGenerator.
215 * @stable ICU 3.8
216 */
217 U_STABLE UDateTimePatternGenerator * U_EXPORT2
218 udatpg_clone(const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode);
219
220 /**
221 * Get the best pattern matching the input skeleton. It is guaranteed to
222 * have all of the fields in the skeleton.
223 *
224 * Note that this function uses a non-const UDateTimePatternGenerator:
225 * It uses a stateful pattern parser which is set up for each generator object,
226 * rather than creating one for each function call.
227 * Consecutive calls to this function do not affect each other,
228 * but this function cannot be used concurrently on a single generator object.
229 *
230 * @param dtpg a pointer to UDateTimePatternGenerator.
231 * @param skeleton
232 * The skeleton is a pattern containing only the variable fields.
233 * For example, "MMMdd" and "mmhh" are skeletons.
234 * @param length the length of skeleton
235 * @param bestPattern
236 * The best pattern found from the given skeleton.
237 * @param capacity the capacity of bestPattern.
238 * @param pErrorCode a pointer to the UErrorCode which must not indicate a
239 * failure before the function call.
240 * @return the length of bestPattern.
241 * @stable ICU 3.8
242 */
243 U_STABLE int32_t U_EXPORT2
244 udatpg_getBestPattern(UDateTimePatternGenerator *dtpg,
245 const UChar *skeleton, int32_t length,
246 UChar *bestPattern, int32_t capacity,
247 UErrorCode *pErrorCode);
248
249 /**
250 * Get the best pattern matching the input skeleton. It is guaranteed to
251 * have all of the fields in the skeleton.
252 *
253 * Note that this function uses a non-const UDateTimePatternGenerator:
254 * It uses a stateful pattern parser which is set up for each generator object,
255 * rather than creating one for each function call.
256 * Consecutive calls to this function do not affect each other,
257 * but this function cannot be used concurrently on a single generator object.
258 *
259 * @param dtpg a pointer to UDateTimePatternGenerator.
260 * @param skeleton
261 * The skeleton is a pattern containing only the variable fields.
262 * For example, "MMMdd" and "mmhh" are skeletons.
263 * @param length the length of skeleton
264 * @param options
265 * Options for forcing the length of specified fields in the
266 * returned pattern to match those in the skeleton (when this
267 * would not happen otherwise). For default behavior, use
268 * UDATPG_MATCH_NO_OPTIONS.
269 * @param bestPattern
270 * The best pattern found from the given skeleton.
271 * @param capacity
272 * the capacity of bestPattern.
273 * @param pErrorCode
274 * a pointer to the UErrorCode which must not indicate a
275 * failure before the function call.
276 * @return the length of bestPattern.
277 * @stable ICU 4.4
278 */
279 U_STABLE int32_t U_EXPORT2
280 udatpg_getBestPatternWithOptions(UDateTimePatternGenerator *dtpg,
281 const UChar *skeleton, int32_t length,
282 UDateTimePatternMatchOptions options,
283 UChar *bestPattern, int32_t capacity,
284 UErrorCode *pErrorCode);
285
286 /**
287 * Get a unique skeleton from a given pattern. For example,
288 * both "MMM-dd" and "dd/MMM" produce the skeleton "MMMdd".
289 *
290 * Note that this function uses a non-const UDateTimePatternGenerator:
291 * It uses a stateful pattern parser which is set up for each generator object,
292 * rather than creating one for each function call.
293 * Consecutive calls to this function do not affect each other,
294 * but this function cannot be used concurrently on a single generator object.
295 *
296 * @param unusedDtpg a pointer to UDateTimePatternGenerator.
297 * This parameter is no longer used. Callers may pass NULL.
298 * @param pattern input pattern, such as "dd/MMM".
299 * @param length the length of pattern.
300 * @param skeleton such as "MMMdd"
301 * @param capacity the capacity of skeleton.
302 * @param pErrorCode a pointer to the UErrorCode which must not indicate a
303 * failure before the function call.
304 * @return the length of skeleton.
305 * @stable ICU 3.8
306 */
307 U_STABLE int32_t U_EXPORT2
308 udatpg_getSkeleton(UDateTimePatternGenerator *unusedDtpg,
309 const UChar *pattern, int32_t length,
310 UChar *skeleton, int32_t capacity,
311 UErrorCode *pErrorCode);
312
313 /**
314 * Get a unique base skeleton from a given pattern. This is the same
315 * as the skeleton, except that differences in length are minimized so
316 * as to only preserve the difference between string and numeric form. So
317 * for example, both "MMM-dd" and "d/MMM" produce the skeleton "MMMd"
318 * (notice the single d).
319 *
320 * Note that this function uses a non-const UDateTimePatternGenerator:
321 * It uses a stateful pattern parser which is set up for each generator object,
322 * rather than creating one for each function call.
323 * Consecutive calls to this function do not affect each other,
324 * but this function cannot be used concurrently on a single generator object.
325 *
326 * @param unusedDtpg a pointer to UDateTimePatternGenerator.
327 * This parameter is no longer used. Callers may pass NULL.
328 * @param pattern input pattern, such as "dd/MMM".
329 * @param length the length of pattern.
330 * @param baseSkeleton such as "Md"
331 * @param capacity the capacity of base skeleton.
332 * @param pErrorCode a pointer to the UErrorCode which must not indicate a
333 * failure before the function call.
334 * @return the length of baseSkeleton.
335 * @stable ICU 3.8
336 */
337 U_STABLE int32_t U_EXPORT2
338 udatpg_getBaseSkeleton(UDateTimePatternGenerator *unusedDtpg,
339 const UChar *pattern, int32_t length,
340 UChar *baseSkeleton, int32_t capacity,
341 UErrorCode *pErrorCode);
342
343 /**
344 * Adds a pattern to the generator. If the pattern has the same skeleton as
345 * an existing pattern, and the override parameter is set, then the previous
346 * value is overriden. Otherwise, the previous value is retained. In either
347 * case, the conflicting status is set and previous vale is stored in
348 * conflicting pattern.
349 * <p>
350 * Note that single-field patterns (like "MMM") are automatically added, and
351 * don't need to be added explicitly!
352 *
353 * @param dtpg a pointer to UDateTimePatternGenerator.
354 * @param pattern input pattern, such as "dd/MMM"
355 * @param patternLength the length of pattern.
356 * @param override When existing values are to be overridden use true,
357 * otherwise use false.
358 * @param conflictingPattern Previous pattern with the same skeleton.
359 * @param capacity the capacity of conflictingPattern.
360 * @param pLength a pointer to the length of conflictingPattern.
361 * @param pErrorCode a pointer to the UErrorCode which must not indicate a
362 * failure before the function call.
363 * @return conflicting status. The value could be UDATPG_NO_CONFLICT,
364 * UDATPG_BASE_CONFLICT or UDATPG_CONFLICT.
365 * @stable ICU 3.8
366 */
367 U_STABLE UDateTimePatternConflict U_EXPORT2
368 udatpg_addPattern(UDateTimePatternGenerator *dtpg,
369 const UChar *pattern, int32_t patternLength,
370 UBool override,
371 UChar *conflictingPattern, int32_t capacity, int32_t *pLength,
372 UErrorCode *pErrorCode);
373
374 /**
375 * An AppendItem format is a pattern used to append a field if there is no
376 * good match. For example, suppose that the input skeleton is "GyyyyMMMd",
377 * and there is no matching pattern internally, but there is a pattern
378 * matching "yyyyMMMd", say "d-MM-yyyy". Then that pattern is used, plus the
379 * G. The way these two are conjoined is by using the AppendItemFormat for G
380 * (era). So if that value is, say "{0}, {1}" then the final resulting
381 * pattern is "d-MM-yyyy, G".
382 * <p>
383 * There are actually three available variables: {0} is the pattern so far,
384 * {1} is the element we are adding, and {2} is the name of the element.
385 * <p>
386 * This reflects the way that the CLDR data is organized.
387 *
388 * @param dtpg a pointer to UDateTimePatternGenerator.
389 * @param field UDateTimePatternField, such as UDATPG_ERA_FIELD
390 * @param value pattern, such as "{0}, {1}"
391 * @param length the length of value.
392 * @stable ICU 3.8
393 */
394 U_STABLE void U_EXPORT2
395 udatpg_setAppendItemFormat(UDateTimePatternGenerator *dtpg,
396 UDateTimePatternField field,
397 const UChar *value, int32_t length);
398
399 /**
400 * Getter corresponding to setAppendItemFormat. Values below 0 or at or
401 * above UDATPG_FIELD_COUNT are illegal arguments.
402 *
403 * @param dtpg A pointer to UDateTimePatternGenerator.
404 * @param field UDateTimePatternField, such as UDATPG_ERA_FIELD
405 * @param pLength A pointer that will receive the length of appendItemFormat.
406 * @return appendItemFormat for field.
407 * @stable ICU 3.8
408 */
409 U_STABLE const UChar * U_EXPORT2
410 udatpg_getAppendItemFormat(const UDateTimePatternGenerator *dtpg,
411 UDateTimePatternField field,
412 int32_t *pLength);
413
414 /**
415 * Set the name of field, eg "era" in English for ERA. These are only
416 * used if the corresponding AppendItemFormat is used, and if it contains a
417 * {2} variable.
418 * <p>
419 * This reflects the way that the CLDR data is organized.
420 *
421 * @param dtpg a pointer to UDateTimePatternGenerator.
422 * @param field UDateTimePatternField
423 * @param value name for the field.
424 * @param length the length of value.
425 * @stable ICU 3.8
426 */
427 U_STABLE void U_EXPORT2
428 udatpg_setAppendItemName(UDateTimePatternGenerator *dtpg,
429 UDateTimePatternField field,
430 const UChar *value, int32_t length);
431
432 /**
433 * Getter corresponding to setAppendItemNames. Values below 0 or at or above
434 * UDATPG_FIELD_COUNT are illegal arguments. Note: The more general function
435 * for getting date/time field display names is udatpg_getFieldDisplayName.
436 *
437 * @param dtpg a pointer to UDateTimePatternGenerator.
438 * @param field UDateTimePatternField, such as UDATPG_ERA_FIELD
439 * @param pLength A pointer that will receive the length of the name for field.
440 * @return name for field
441 * @see udatpg_getFieldDisplayName
442 * @stable ICU 3.8
443 */
444 U_STABLE const UChar * U_EXPORT2
445 udatpg_getAppendItemName(const UDateTimePatternGenerator *dtpg,
446 UDateTimePatternField field,
447 int32_t *pLength);
448
449 /**
450 * The general interface to get a display name for a particular date/time field,
451 * in one of several possible display widths.
452 *
453 * @param dtpg
454 * A pointer to the UDateTimePatternGenerator object with the localized
455 * display names.
456 * @param field
457 * The desired UDateTimePatternField, such as UDATPG_ERA_FIELD.
458 * @param width
459 * The desired UDateTimePGDisplayWidth, such as UDATPG_ABBREVIATED.
460 * @param fieldName
461 * A pointer to a buffer to receive the NULL-terminated display name. If the name
462 * fits into fieldName but cannot be NULL-terminated (length == capacity) then
463 * the error code is set to U_STRING_NOT_TERMINATED_WARNING. If the name doesn't
464 * fit into fieldName then the error code is set to U_BUFFER_OVERFLOW_ERROR.
465 * @param capacity
466 * The size of fieldName (in UChars).
467 * @param pErrorCode
468 * A pointer to a UErrorCode to receive any errors
469 * @return
470 * The full length of the name; if greater than capacity, fieldName contains a
471 * truncated result.
472 * @stable ICU 61
473 */
474 U_STABLE int32_t U_EXPORT2
475 udatpg_getFieldDisplayName(const UDateTimePatternGenerator *dtpg,
476 UDateTimePatternField field,
477 UDateTimePGDisplayWidth width,
478 UChar *fieldName, int32_t capacity,
479 UErrorCode *pErrorCode);
480
481 /**
482 * The DateTimeFormat is a message format pattern used to compose date and
483 * time patterns. The default pattern in the root locale is "{1} {0}", where
484 * {1} will be replaced by the date pattern and {0} will be replaced by the
485 * time pattern; however, other locales may specify patterns such as
486 * "{1}, {0}" or "{1} 'at' {0}", etc.
487 * <p>
488 * This is used when the input skeleton contains both date and time fields,
489 * but there is not a close match among the added patterns. For example,
490 * suppose that this object was created by adding "dd-MMM" and "hh:mm", and
491 * its DateTimeFormat is the default "{1} {0}". Then if the input skeleton
492 * is "MMMdhmm", there is not an exact match, so the input skeleton is
493 * broken up into two components "MMMd" and "hmm". There are close matches
494 * for those two skeletons, so the result is put together with this pattern,
495 * resulting in "d-MMM h:mm".
496 *
497 * @param dtpg a pointer to UDateTimePatternGenerator.
498 * @param dtFormat
499 * message format pattern, here {1} will be replaced by the date
500 * pattern and {0} will be replaced by the time pattern.
501 * @param length the length of dtFormat.
502 * @stable ICU 3.8
503 */
504 U_STABLE void U_EXPORT2
505 udatpg_setDateTimeFormat(const UDateTimePatternGenerator *dtpg,
506 const UChar *dtFormat, int32_t length);
507
508 /**
509 * Getter corresponding to setDateTimeFormat.
510 * @param dtpg a pointer to UDateTimePatternGenerator.
511 * @param pLength A pointer that will receive the length of the format
512 * @return dateTimeFormat.
513 * @stable ICU 3.8
514 */
515 U_STABLE const UChar * U_EXPORT2
516 udatpg_getDateTimeFormat(const UDateTimePatternGenerator *dtpg,
517 int32_t *pLength);
518
519 /**
520 * The decimal value is used in formatting fractions of seconds. If the
521 * skeleton contains fractional seconds, then this is used with the
522 * fractional seconds. For example, suppose that the input pattern is
523 * "hhmmssSSSS", and the best matching pattern internally is "H:mm:ss", and
524 * the decimal string is ",". Then the resulting pattern is modified to be
525 * "H:mm:ss,SSSS"
526 *
527 * @param dtpg a pointer to UDateTimePatternGenerator.
528 * @param decimal
529 * @param length the length of decimal.
530 * @stable ICU 3.8
531 */
532 U_STABLE void U_EXPORT2
533 udatpg_setDecimal(UDateTimePatternGenerator *dtpg,
534 const UChar *decimal, int32_t length);
535
536 /**
537 * Getter corresponding to setDecimal.
538 *
539 * @param dtpg a pointer to UDateTimePatternGenerator.
540 * @param pLength A pointer that will receive the length of the decimal string.
541 * @return corresponding to the decimal point.
542 * @stable ICU 3.8
543 */
544 U_STABLE const UChar * U_EXPORT2
545 udatpg_getDecimal(const UDateTimePatternGenerator *dtpg,
546 int32_t *pLength);
547
548 /**
549 * Adjusts the field types (width and subtype) of a pattern to match what is
550 * in a skeleton. That is, if you supply a pattern like "d-M H:m", and a
551 * skeleton of "MMMMddhhmm", then the input pattern is adjusted to be
552 * "dd-MMMM hh:mm". This is used internally to get the best match for the
553 * input skeleton, but can also be used externally.
554 *
555 * Note that this function uses a non-const UDateTimePatternGenerator:
556 * It uses a stateful pattern parser which is set up for each generator object,
557 * rather than creating one for each function call.
558 * Consecutive calls to this function do not affect each other,
559 * but this function cannot be used concurrently on a single generator object.
560 *
561 * @param dtpg a pointer to UDateTimePatternGenerator.
562 * @param pattern Input pattern
563 * @param patternLength the length of input pattern.
564 * @param skeleton
565 * @param skeletonLength the length of input skeleton.
566 * @param dest pattern adjusted to match the skeleton fields widths and subtypes.
567 * @param destCapacity the capacity of dest.
568 * @param pErrorCode a pointer to the UErrorCode which must not indicate a
569 * failure before the function call.
570 * @return the length of dest.
571 * @stable ICU 3.8
572 */
573 U_STABLE int32_t U_EXPORT2
574 udatpg_replaceFieldTypes(UDateTimePatternGenerator *dtpg,
575 const UChar *pattern, int32_t patternLength,
576 const UChar *skeleton, int32_t skeletonLength,
577 UChar *dest, int32_t destCapacity,
578 UErrorCode *pErrorCode);
579
580 /**
581 * Adjusts the field types (width and subtype) of a pattern to match what is
582 * in a skeleton. That is, if you supply a pattern like "d-M H:m", and a
583 * skeleton of "MMMMddhhmm", then the input pattern is adjusted to be
584 * "dd-MMMM hh:mm". This is used internally to get the best match for the
585 * input skeleton, but can also be used externally.
586 *
587 * Note that this function uses a non-const UDateTimePatternGenerator:
588 * It uses a stateful pattern parser which is set up for each generator object,
589 * rather than creating one for each function call.
590 * Consecutive calls to this function do not affect each other,
591 * but this function cannot be used concurrently on a single generator object.
592 *
593 * @param dtpg a pointer to UDateTimePatternGenerator.
594 * @param pattern Input pattern
595 * @param patternLength the length of input pattern.
596 * @param skeleton
597 * @param skeletonLength the length of input skeleton.
598 * @param options
599 * Options controlling whether the length of specified fields in the
600 * pattern are adjusted to match those in the skeleton (when this
601 * would not happen otherwise). For default behavior, use
602 * UDATPG_MATCH_NO_OPTIONS.
603 * @param dest pattern adjusted to match the skeleton fields widths and subtypes.
604 * @param destCapacity the capacity of dest.
605 * @param pErrorCode a pointer to the UErrorCode which must not indicate a
606 * failure before the function call.
607 * @return the length of dest.
608 * @stable ICU 4.4
609 */
610 U_STABLE int32_t U_EXPORT2
611 udatpg_replaceFieldTypesWithOptions(UDateTimePatternGenerator *dtpg,
612 const UChar *pattern, int32_t patternLength,
613 const UChar *skeleton, int32_t skeletonLength,
614 UDateTimePatternMatchOptions options,
615 UChar *dest, int32_t destCapacity,
616 UErrorCode *pErrorCode);
617
618 /**
619 * Return a UEnumeration list of all the skeletons in canonical form.
620 * Call udatpg_getPatternForSkeleton() to get the corresponding pattern.
621 *
622 * @param dtpg a pointer to UDateTimePatternGenerator.
623 * @param pErrorCode a pointer to the UErrorCode which must not indicate a
624 * failure before the function call
625 * @return a UEnumeration list of all the skeletons
626 * The caller must close the object.
627 * @stable ICU 3.8
628 */
629 U_STABLE UEnumeration * U_EXPORT2
630 udatpg_openSkeletons(const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode);
631
632 /**
633 * Return a UEnumeration list of all the base skeletons in canonical form.
634 *
635 * @param dtpg a pointer to UDateTimePatternGenerator.
636 * @param pErrorCode a pointer to the UErrorCode which must not indicate a
637 * failure before the function call.
638 * @return a UEnumeration list of all the base skeletons
639 * The caller must close the object.
640 * @stable ICU 3.8
641 */
642 U_STABLE UEnumeration * U_EXPORT2
643 udatpg_openBaseSkeletons(const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode);
644
645 /**
646 * Get the pattern corresponding to a given skeleton.
647 *
648 * @param dtpg a pointer to UDateTimePatternGenerator.
649 * @param skeleton
650 * @param skeletonLength pointer to the length of skeleton.
651 * @param pLength pointer to the length of return pattern.
652 * @return pattern corresponding to a given skeleton.
653 * @stable ICU 3.8
654 */
655 U_STABLE const UChar * U_EXPORT2
656 udatpg_getPatternForSkeleton(const UDateTimePatternGenerator *dtpg,
657 const UChar *skeleton, int32_t skeletonLength,
658 int32_t *pLength);
659
660 /**
661 * Remap a pattern per the options (Apple-specific for now).
662 * Currently this will only remap the time to force an alternate time
663 * cycle (12-hour instead of 24-hour or vice versa), handling updating
664 * the pattern characters, insertion/removal of AM/PM marker, etc. in
665 * a locale-appropriate way. It calls udatpg_getBestPatternWithOptions
666 * as part of updating the time format.
667 *
668 * @param dtpg a pointer to UDateTimePatternGenerator.
669 * @param pattern
670 * The pattern to remap.
671 * @param patternLength
672 * The length of the pattern (may be -1 to indicate that it
673 * is zero-terminated).
674 * @param options
675 * Options for forcing the hour cycle and for forcing the
676 * length of specified fields in the
677 * returned pattern to match those in the skeleton (when this
678 * would not happen otherwise). For default behavior, use
679 * UDATPG_MATCH_NO_OPTIONS.
680 * @param newPattern
681 * The remapped pattern.
682 * @param newPatternCapacity
683 * The capacity of newPattern.
684 * @param pErrorCode
685 * A pointer to the UErrorCode. If at entry it indicates a
686 * failure, the call will return immediately.
687 * @return
688 * The length of newPattern. If this is greater than
689 * newPatternCapacity an error will be set and the contents of
690 * newPattern are undefined.
691 * @internal
692 */
693 U_INTERNAL int32_t U_EXPORT2
694 uadatpg_remapPatternWithOptions(UDateTimePatternGenerator *dtpg,
695 const UChar *pattern, int32_t patternLength,
696 UDateTimePatternMatchOptions options,
697 UChar *newPattern, int32_t newPatternCapacity,
698 UErrorCode *pErrorCode);
699
700 #endif