|
||||
File indexing completed on 2025-01-18 10:13:11
0001 // © 2016 and later: Unicode, Inc. and others. 0002 // License & terms of use: http://www.unicode.org/copyright.html 0003 /* 0004 ******************************************************************************* 0005 * 0006 * Copyright (C) 2007-2015, International Business Machines 0007 * Corporation and others. All Rights Reserved. 0008 * 0009 ******************************************************************************* 0010 * file name: udatpg.h 0011 * encoding: UTF-8 0012 * tab size: 8 (not used) 0013 * indentation:4 0014 * 0015 * created on: 2007jul30 0016 * created by: Markus W. Scherer 0017 */ 0018 0019 #ifndef __UDATPG_H__ 0020 #define __UDATPG_H__ 0021 0022 #include "unicode/utypes.h" 0023 #include "unicode/udat.h" 0024 #include "unicode/uenum.h" 0025 0026 #if U_SHOW_CPLUSPLUS_API 0027 #include "unicode/localpointer.h" 0028 #endif // U_SHOW_CPLUSPLUS_API 0029 0030 /** 0031 * \file 0032 * \brief C API: Wrapper for icu::DateTimePatternGenerator (unicode/dtptngen.h). 0033 * 0034 * UDateTimePatternGenerator provides flexible generation of date format patterns, 0035 * like "yy-MM-dd". The user can build up the generator by adding successive 0036 * patterns. Once that is done, a query can be made using a "skeleton", which is 0037 * a pattern which just includes the desired fields and lengths. The generator 0038 * will return the "best fit" pattern corresponding to that skeleton. 0039 * <p>The main method people will use is udatpg_getBestPattern, since normally 0040 * UDateTimePatternGenerator is pre-built with data from a particular locale. 0041 * However, generators can be built directly from other data as well. 0042 * <p><i>Issue: may be useful to also have a function that returns the list of 0043 * fields in a pattern, in order, since we have that internally. 0044 * That would be useful for getting the UI order of field elements.</i> 0045 */ 0046 0047 /** 0048 * Opaque type for a date/time pattern generator object. 0049 * @stable ICU 3.8 0050 */ 0051 typedef void *UDateTimePatternGenerator; 0052 0053 /** 0054 * Field number constants for udatpg_getAppendItemFormats() and similar functions. 0055 * These constants are separate from UDateFormatField despite semantic overlap 0056 * because some fields are merged for the date/time pattern generator. 0057 * @stable ICU 3.8 0058 */ 0059 typedef enum UDateTimePatternField { 0060 /** @stable ICU 3.8 */ 0061 UDATPG_ERA_FIELD, 0062 /** @stable ICU 3.8 */ 0063 UDATPG_YEAR_FIELD, 0064 /** @stable ICU 3.8 */ 0065 UDATPG_QUARTER_FIELD, 0066 /** @stable ICU 3.8 */ 0067 UDATPG_MONTH_FIELD, 0068 /** @stable ICU 3.8 */ 0069 UDATPG_WEEK_OF_YEAR_FIELD, 0070 /** @stable ICU 3.8 */ 0071 UDATPG_WEEK_OF_MONTH_FIELD, 0072 /** @stable ICU 3.8 */ 0073 UDATPG_WEEKDAY_FIELD, 0074 /** @stable ICU 3.8 */ 0075 UDATPG_DAY_OF_YEAR_FIELD, 0076 /** @stable ICU 3.8 */ 0077 UDATPG_DAY_OF_WEEK_IN_MONTH_FIELD, 0078 /** @stable ICU 3.8 */ 0079 UDATPG_DAY_FIELD, 0080 /** @stable ICU 3.8 */ 0081 UDATPG_DAYPERIOD_FIELD, 0082 /** @stable ICU 3.8 */ 0083 UDATPG_HOUR_FIELD, 0084 /** @stable ICU 3.8 */ 0085 UDATPG_MINUTE_FIELD, 0086 /** @stable ICU 3.8 */ 0087 UDATPG_SECOND_FIELD, 0088 /** @stable ICU 3.8 */ 0089 UDATPG_FRACTIONAL_SECOND_FIELD, 0090 /** @stable ICU 3.8 */ 0091 UDATPG_ZONE_FIELD, 0092 0093 /* Do not conditionalize the following with #ifndef U_HIDE_DEPRECATED_API, 0094 * it is needed for layout of DateTimePatternGenerator object. */ 0095 #ifndef U_FORCE_HIDE_DEPRECATED_API 0096 /** 0097 * One more than the highest normal UDateTimePatternField value. 0098 * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420. 0099 */ 0100 UDATPG_FIELD_COUNT 0101 #endif // U_FORCE_HIDE_DEPRECATED_API 0102 } UDateTimePatternField; 0103 0104 /** 0105 * Field display name width constants for udatpg_getFieldDisplayName(). 0106 * @stable ICU 61 0107 */ 0108 typedef enum UDateTimePGDisplayWidth { 0109 /** @stable ICU 61 */ 0110 UDATPG_WIDE, 0111 /** @stable ICU 61 */ 0112 UDATPG_ABBREVIATED, 0113 /** @stable ICU 61 */ 0114 UDATPG_NARROW 0115 } UDateTimePGDisplayWidth; 0116 0117 /** 0118 * Masks to control forcing the length of specified fields in the returned 0119 * pattern to match those in the skeleton (when this would not happen 0120 * otherwise). These may be combined to force the length of multiple fields. 0121 * Used with udatpg_getBestPatternWithOptions, udatpg_replaceFieldTypesWithOptions. 0122 * @stable ICU 4.4 0123 */ 0124 typedef enum UDateTimePatternMatchOptions { 0125 /** @stable ICU 4.4 */ 0126 UDATPG_MATCH_NO_OPTIONS = 0, 0127 /** @stable ICU 4.4 */ 0128 UDATPG_MATCH_HOUR_FIELD_LENGTH = 1 << UDATPG_HOUR_FIELD, 0129 #ifndef U_HIDE_INTERNAL_API 0130 /** @internal ICU 4.4 */ 0131 UDATPG_MATCH_MINUTE_FIELD_LENGTH = 1 << UDATPG_MINUTE_FIELD, 0132 /** @internal ICU 4.4 */ 0133 UDATPG_MATCH_SECOND_FIELD_LENGTH = 1 << UDATPG_SECOND_FIELD, 0134 #endif /* U_HIDE_INTERNAL_API */ 0135 /** @stable ICU 4.4 */ 0136 UDATPG_MATCH_ALL_FIELDS_LENGTH = (1 << UDATPG_FIELD_COUNT) - 1 0137 } UDateTimePatternMatchOptions; 0138 0139 /** 0140 * Status return values from udatpg_addPattern(). 0141 * @stable ICU 3.8 0142 */ 0143 typedef enum UDateTimePatternConflict { 0144 /** @stable ICU 3.8 */ 0145 UDATPG_NO_CONFLICT, 0146 /** @stable ICU 3.8 */ 0147 UDATPG_BASE_CONFLICT, 0148 /** @stable ICU 3.8 */ 0149 UDATPG_CONFLICT, 0150 #ifndef U_HIDE_DEPRECATED_API 0151 /** 0152 * One more than the highest normal UDateTimePatternConflict value. 0153 * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420. 0154 */ 0155 UDATPG_CONFLICT_COUNT 0156 #endif // U_HIDE_DEPRECATED_API 0157 } UDateTimePatternConflict; 0158 0159 /** 0160 * Open a generator according to a given locale. 0161 * @param locale 0162 * @param pErrorCode a pointer to the UErrorCode which must not indicate a 0163 * failure before the function call. 0164 * @return a pointer to UDateTimePatternGenerator. 0165 * @stable ICU 3.8 0166 */ 0167 U_CAPI UDateTimePatternGenerator * U_EXPORT2 0168 udatpg_open(const char *locale, UErrorCode *pErrorCode); 0169 0170 /** 0171 * Open an empty generator, to be constructed with udatpg_addPattern(...) etc. 0172 * @param pErrorCode a pointer to the UErrorCode which must not indicate a 0173 * failure before the function call. 0174 * @return a pointer to UDateTimePatternGenerator. 0175 * @stable ICU 3.8 0176 */ 0177 U_CAPI UDateTimePatternGenerator * U_EXPORT2 0178 udatpg_openEmpty(UErrorCode *pErrorCode); 0179 0180 /** 0181 * Close a generator. 0182 * @param dtpg a pointer to UDateTimePatternGenerator. 0183 * @stable ICU 3.8 0184 */ 0185 U_CAPI void U_EXPORT2 0186 udatpg_close(UDateTimePatternGenerator *dtpg); 0187 0188 #if U_SHOW_CPLUSPLUS_API 0189 0190 U_NAMESPACE_BEGIN 0191 0192 /** 0193 * \class LocalUDateTimePatternGeneratorPointer 0194 * "Smart pointer" class, closes a UDateTimePatternGenerator via udatpg_close(). 0195 * For most methods see the LocalPointerBase base class. 0196 * 0197 * @see LocalPointerBase 0198 * @see LocalPointer 0199 * @stable ICU 4.4 0200 */ 0201 U_DEFINE_LOCAL_OPEN_POINTER(LocalUDateTimePatternGeneratorPointer, UDateTimePatternGenerator, udatpg_close); 0202 0203 U_NAMESPACE_END 0204 0205 #endif 0206 0207 /** 0208 * Create a copy pf a generator. 0209 * @param dtpg a pointer to UDateTimePatternGenerator to be copied. 0210 * @param pErrorCode a pointer to the UErrorCode which must not indicate a 0211 * failure before the function call. 0212 * @return a pointer to a new UDateTimePatternGenerator. 0213 * @stable ICU 3.8 0214 */ 0215 U_CAPI UDateTimePatternGenerator * U_EXPORT2 0216 udatpg_clone(const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode); 0217 0218 /** 0219 * Get the best pattern matching the input skeleton. It is guaranteed to 0220 * have all of the fields in the skeleton. 0221 * 0222 * Note that this function uses a non-const UDateTimePatternGenerator: 0223 * It uses a stateful pattern parser which is set up for each generator object, 0224 * rather than creating one for each function call. 0225 * Consecutive calls to this function do not affect each other, 0226 * but this function cannot be used concurrently on a single generator object. 0227 * 0228 * @param dtpg a pointer to UDateTimePatternGenerator. 0229 * @param skeleton 0230 * The skeleton is a pattern containing only the variable fields. 0231 * For example, "MMMdd" and "mmhh" are skeletons. 0232 * @param length the length of skeleton 0233 * @param bestPattern 0234 * The best pattern found from the given skeleton. 0235 * @param capacity the capacity of bestPattern. 0236 * @param pErrorCode a pointer to the UErrorCode which must not indicate a 0237 * failure before the function call. 0238 * @return the length of bestPattern. 0239 * @stable ICU 3.8 0240 */ 0241 U_CAPI int32_t U_EXPORT2 0242 udatpg_getBestPattern(UDateTimePatternGenerator *dtpg, 0243 const UChar *skeleton, int32_t length, 0244 UChar *bestPattern, int32_t capacity, 0245 UErrorCode *pErrorCode); 0246 0247 /** 0248 * Get the best pattern matching the input skeleton. It is guaranteed to 0249 * have all of the fields in the skeleton. 0250 * 0251 * Note that this function uses a non-const UDateTimePatternGenerator: 0252 * It uses a stateful pattern parser which is set up for each generator object, 0253 * rather than creating one for each function call. 0254 * Consecutive calls to this function do not affect each other, 0255 * but this function cannot be used concurrently on a single generator object. 0256 * 0257 * @param dtpg a pointer to UDateTimePatternGenerator. 0258 * @param skeleton 0259 * The skeleton is a pattern containing only the variable fields. 0260 * For example, "MMMdd" and "mmhh" are skeletons. 0261 * @param length the length of skeleton 0262 * @param options 0263 * Options for forcing the length of specified fields in the 0264 * returned pattern to match those in the skeleton (when this 0265 * would not happen otherwise). For default behavior, use 0266 * UDATPG_MATCH_NO_OPTIONS. 0267 * @param bestPattern 0268 * The best pattern found from the given skeleton. 0269 * @param capacity 0270 * the capacity of bestPattern. 0271 * @param pErrorCode 0272 * a pointer to the UErrorCode which must not indicate a 0273 * failure before the function call. 0274 * @return the length of bestPattern. 0275 * @stable ICU 4.4 0276 */ 0277 U_CAPI int32_t U_EXPORT2 0278 udatpg_getBestPatternWithOptions(UDateTimePatternGenerator *dtpg, 0279 const UChar *skeleton, int32_t length, 0280 UDateTimePatternMatchOptions options, 0281 UChar *bestPattern, int32_t capacity, 0282 UErrorCode *pErrorCode); 0283 0284 /** 0285 * Get a unique skeleton from a given pattern. For example, 0286 * both "MMM-dd" and "dd/MMM" produce the skeleton "MMMdd". 0287 * 0288 * Note that this function uses a non-const UDateTimePatternGenerator: 0289 * It uses a stateful pattern parser which is set up for each generator object, 0290 * rather than creating one for each function call. 0291 * Consecutive calls to this function do not affect each other, 0292 * but this function cannot be used concurrently on a single generator object. 0293 * 0294 * @param unusedDtpg a pointer to UDateTimePatternGenerator. 0295 * This parameter is no longer used. Callers may pass NULL. 0296 * @param pattern input pattern, such as "dd/MMM". 0297 * @param length the length of pattern. 0298 * @param skeleton such as "MMMdd" 0299 * @param capacity the capacity of skeleton. 0300 * @param pErrorCode a pointer to the UErrorCode which must not indicate a 0301 * failure before the function call. 0302 * @return the length of skeleton. 0303 * @stable ICU 3.8 0304 */ 0305 U_CAPI int32_t U_EXPORT2 0306 udatpg_getSkeleton(UDateTimePatternGenerator *unusedDtpg, 0307 const UChar *pattern, int32_t length, 0308 UChar *skeleton, int32_t capacity, 0309 UErrorCode *pErrorCode); 0310 0311 /** 0312 * Get a unique base skeleton from a given pattern. This is the same 0313 * as the skeleton, except that differences in length are minimized so 0314 * as to only preserve the difference between string and numeric form. So 0315 * for example, both "MMM-dd" and "d/MMM" produce the skeleton "MMMd" 0316 * (notice the single d). 0317 * 0318 * Note that this function uses a non-const UDateTimePatternGenerator: 0319 * It uses a stateful pattern parser which is set up for each generator object, 0320 * rather than creating one for each function call. 0321 * Consecutive calls to this function do not affect each other, 0322 * but this function cannot be used concurrently on a single generator object. 0323 * 0324 * @param unusedDtpg a pointer to UDateTimePatternGenerator. 0325 * This parameter is no longer used. Callers may pass NULL. 0326 * @param pattern input pattern, such as "dd/MMM". 0327 * @param length the length of pattern. 0328 * @param baseSkeleton such as "Md" 0329 * @param capacity the capacity of base skeleton. 0330 * @param pErrorCode a pointer to the UErrorCode which must not indicate a 0331 * failure before the function call. 0332 * @return the length of baseSkeleton. 0333 * @stable ICU 3.8 0334 */ 0335 U_CAPI int32_t U_EXPORT2 0336 udatpg_getBaseSkeleton(UDateTimePatternGenerator *unusedDtpg, 0337 const UChar *pattern, int32_t length, 0338 UChar *baseSkeleton, int32_t capacity, 0339 UErrorCode *pErrorCode); 0340 0341 /** 0342 * Adds a pattern to the generator. If the pattern has the same skeleton as 0343 * an existing pattern, and the override parameter is set, then the previous 0344 * value is overridden. Otherwise, the previous value is retained. In either 0345 * case, the conflicting status is set and previous vale is stored in 0346 * conflicting pattern. 0347 * <p> 0348 * Note that single-field patterns (like "MMM") are automatically added, and 0349 * don't need to be added explicitly! 0350 * 0351 * @param dtpg a pointer to UDateTimePatternGenerator. 0352 * @param pattern input pattern, such as "dd/MMM" 0353 * @param patternLength the length of pattern. 0354 * @param override When existing values are to be overridden use true, 0355 * otherwise use false. 0356 * @param conflictingPattern Previous pattern with the same skeleton. 0357 * @param capacity the capacity of conflictingPattern. 0358 * @param pLength a pointer to the length of conflictingPattern. 0359 * @param pErrorCode a pointer to the UErrorCode which must not indicate a 0360 * failure before the function call. 0361 * @return conflicting status. The value could be UDATPG_NO_CONFLICT, 0362 * UDATPG_BASE_CONFLICT or UDATPG_CONFLICT. 0363 * @stable ICU 3.8 0364 */ 0365 U_CAPI UDateTimePatternConflict U_EXPORT2 0366 udatpg_addPattern(UDateTimePatternGenerator *dtpg, 0367 const UChar *pattern, int32_t patternLength, 0368 UBool override, 0369 UChar *conflictingPattern, int32_t capacity, int32_t *pLength, 0370 UErrorCode *pErrorCode); 0371 0372 /** 0373 * An AppendItem format is a pattern used to append a field if there is no 0374 * good match. For example, suppose that the input skeleton is "GyyyyMMMd", 0375 * and there is no matching pattern internally, but there is a pattern 0376 * matching "yyyyMMMd", say "d-MM-yyyy". Then that pattern is used, plus the 0377 * G. The way these two are conjoined is by using the AppendItemFormat for G 0378 * (era). So if that value is, say "{0}, {1}" then the final resulting 0379 * pattern is "d-MM-yyyy, G". 0380 * <p> 0381 * There are actually three available variables: {0} is the pattern so far, 0382 * {1} is the element we are adding, and {2} is the name of the element. 0383 * <p> 0384 * This reflects the way that the CLDR data is organized. 0385 * 0386 * @param dtpg a pointer to UDateTimePatternGenerator. 0387 * @param field UDateTimePatternField, such as UDATPG_ERA_FIELD 0388 * @param value pattern, such as "{0}, {1}" 0389 * @param length the length of value. 0390 * @stable ICU 3.8 0391 */ 0392 U_CAPI void U_EXPORT2 0393 udatpg_setAppendItemFormat(UDateTimePatternGenerator *dtpg, 0394 UDateTimePatternField field, 0395 const UChar *value, int32_t length); 0396 0397 /** 0398 * Getter corresponding to setAppendItemFormat. Values below 0 or at or 0399 * above UDATPG_FIELD_COUNT are illegal arguments. 0400 * 0401 * @param dtpg A pointer to UDateTimePatternGenerator. 0402 * @param field UDateTimePatternField, such as UDATPG_ERA_FIELD 0403 * @param pLength A pointer that will receive the length of appendItemFormat. 0404 * @return appendItemFormat for field. 0405 * @stable ICU 3.8 0406 */ 0407 U_CAPI const UChar * U_EXPORT2 0408 udatpg_getAppendItemFormat(const UDateTimePatternGenerator *dtpg, 0409 UDateTimePatternField field, 0410 int32_t *pLength); 0411 0412 /** 0413 * Set the name of field, eg "era" in English for ERA. These are only 0414 * used if the corresponding AppendItemFormat is used, and if it contains a 0415 * {2} variable. 0416 * <p> 0417 * This reflects the way that the CLDR data is organized. 0418 * 0419 * @param dtpg a pointer to UDateTimePatternGenerator. 0420 * @param field UDateTimePatternField 0421 * @param value name for the field. 0422 * @param length the length of value. 0423 * @stable ICU 3.8 0424 */ 0425 U_CAPI void U_EXPORT2 0426 udatpg_setAppendItemName(UDateTimePatternGenerator *dtpg, 0427 UDateTimePatternField field, 0428 const UChar *value, int32_t length); 0429 0430 /** 0431 * Getter corresponding to setAppendItemNames. Values below 0 or at or above 0432 * UDATPG_FIELD_COUNT are illegal arguments. Note: The more general function 0433 * for getting date/time field display names is udatpg_getFieldDisplayName. 0434 * 0435 * @param dtpg a pointer to UDateTimePatternGenerator. 0436 * @param field UDateTimePatternField, such as UDATPG_ERA_FIELD 0437 * @param pLength A pointer that will receive the length of the name for field. 0438 * @return name for field 0439 * @see udatpg_getFieldDisplayName 0440 * @stable ICU 3.8 0441 */ 0442 U_CAPI const UChar * U_EXPORT2 0443 udatpg_getAppendItemName(const UDateTimePatternGenerator *dtpg, 0444 UDateTimePatternField field, 0445 int32_t *pLength); 0446 0447 /** 0448 * The general interface to get a display name for a particular date/time field, 0449 * in one of several possible display widths. 0450 * 0451 * @param dtpg 0452 * A pointer to the UDateTimePatternGenerator object with the localized 0453 * display names. 0454 * @param field 0455 * The desired UDateTimePatternField, such as UDATPG_ERA_FIELD. 0456 * @param width 0457 * The desired UDateTimePGDisplayWidth, such as UDATPG_ABBREVIATED. 0458 * @param fieldName 0459 * A pointer to a buffer to receive the NULL-terminated display name. If the name 0460 * fits into fieldName but cannot be NULL-terminated (length == capacity) then 0461 * the error code is set to U_STRING_NOT_TERMINATED_WARNING. If the name doesn't 0462 * fit into fieldName then the error code is set to U_BUFFER_OVERFLOW_ERROR. 0463 * @param capacity 0464 * The size of fieldName (in UChars). 0465 * @param pErrorCode 0466 * A pointer to a UErrorCode to receive any errors 0467 * @return 0468 * The full length of the name; if greater than capacity, fieldName contains a 0469 * truncated result. 0470 * @stable ICU 61 0471 */ 0472 U_CAPI int32_t U_EXPORT2 0473 udatpg_getFieldDisplayName(const UDateTimePatternGenerator *dtpg, 0474 UDateTimePatternField field, 0475 UDateTimePGDisplayWidth width, 0476 UChar *fieldName, int32_t capacity, 0477 UErrorCode *pErrorCode); 0478 0479 /** 0480 * The DateTimeFormat is a message format pattern used to compose date and 0481 * time patterns. The default pattern in the root locale is "{1} {0}", where 0482 * {1} will be replaced by the date pattern and {0} will be replaced by the 0483 * time pattern; however, other locales may specify patterns such as 0484 * "{1}, {0}" or "{1} 'at' {0}", etc. 0485 * <p> 0486 * This is used when the input skeleton contains both date and time fields, 0487 * but there is not a close match among the added patterns. For example, 0488 * suppose that this object was created by adding "dd-MMM" and "hh:mm", and 0489 * its DateTimeFormat is the default "{1} {0}". Then if the input skeleton 0490 * is "MMMdhmm", there is not an exact match, so the input skeleton is 0491 * broken up into two components "MMMd" and "hmm". There are close matches 0492 * for those two skeletons, so the result is put together with this pattern, 0493 * resulting in "d-MMM h:mm". 0494 * 0495 * There are four DateTimeFormats in a UDateTimePatternGenerator object, 0496 * corresponding to date styles UDAT_FULL..UDAT_SHORT. This method sets 0497 * all of them to the specified pattern. To set them individually, see 0498 * udatpg_setDateTimeFormatForStyle. 0499 * 0500 * @param dtpg a pointer to UDateTimePatternGenerator. 0501 * @param dtFormat 0502 * message format pattern, here {1} will be replaced by the date 0503 * pattern and {0} will be replaced by the time pattern. 0504 * @param length the length of dtFormat. 0505 * @stable ICU 3.8 0506 */ 0507 U_CAPI void U_EXPORT2 0508 udatpg_setDateTimeFormat(const UDateTimePatternGenerator *dtpg, 0509 const UChar *dtFormat, int32_t length); 0510 0511 /** 0512 * Getter corresponding to setDateTimeFormat. 0513 * 0514 * There are four DateTimeFormats in a UDateTimePatternGenerator object, 0515 * corresponding to date styles UDAT_FULL..UDAT_SHORT. This method gets 0516 * the style for UDAT_MEDIUM (the default). To get them individually, see 0517 * udatpg_getDateTimeFormatForStyle. 0518 * 0519 * @param dtpg a pointer to UDateTimePatternGenerator. 0520 * @param pLength A pointer that will receive the length of the format 0521 * @return dateTimeFormat. 0522 * @stable ICU 3.8 0523 */ 0524 U_CAPI const UChar * U_EXPORT2 0525 udatpg_getDateTimeFormat(const UDateTimePatternGenerator *dtpg, 0526 int32_t *pLength); 0527 0528 #if !UCONFIG_NO_FORMATTING 0529 /** 0530 * dateTimeFormats are message patterns used to compose combinations of date 0531 * and time patterns. There are four length styles, corresponding to the 0532 * inferred style of the date pattern; these are UDateFormatStyle values: 0533 * - UDAT_FULL (for date pattern with weekday and long month), else 0534 * - UDAT_LONG (for a date pattern with long month), else 0535 * - UDAT_MEDIUM (for a date pattern with abbreviated month), else 0536 * - UDAT_SHORT (for any other date pattern). 0537 * For details on dateTimeFormats, see 0538 * https://www.unicode.org/reports/tr35/tr35-dates.html#dateTimeFormats. 0539 * The default pattern in the root locale for all styles is "{1} {0}". 0540 * 0541 * @param udtpg 0542 * a pointer to the UDateTimePatternGenerator 0543 * @param style 0544 * one of UDAT_FULL..UDAT_SHORT. Error if out of range. 0545 * @param dateTimeFormat 0546 * the new dateTimeFormat to set for the the specified style 0547 * @param length 0548 * the length of dateTimeFormat, or -1 if unknown and pattern 0549 * is null-terminated 0550 * @param pErrorCode 0551 * a pointer to the UErrorCode (in/out parameter); if no failure 0552 * status is already set, it will be set according to result of the 0553 * function (e.g. U_ILLEGAL_ARGUMENT_ERROR for style out of range). 0554 * @stable ICU 71 0555 */ 0556 U_CAPI void U_EXPORT2 0557 udatpg_setDateTimeFormatForStyle(UDateTimePatternGenerator *udtpg, 0558 UDateFormatStyle style, 0559 const UChar *dateTimeFormat, int32_t length, 0560 UErrorCode *pErrorCode); 0561 0562 /** 0563 * Getter corresponding to udatpg_setDateTimeFormatForStyle. 0564 * 0565 * @param udtpg 0566 * a pointer to the UDateTimePatternGenerator 0567 * @param style 0568 * one of UDAT_FULL..UDAT_SHORT. Error if out of range. 0569 * @param pLength 0570 * a pointer that will receive the length of the format. May be NULL 0571 * if length is not desired. 0572 * @param pErrorCode 0573 * a pointer to the UErrorCode (in/out parameter); if no failure 0574 * status is already set, it will be set according to result of the 0575 * function (e.g. U_ILLEGAL_ARGUMENT_ERROR for style out of range). 0576 * @return 0577 * pointer to the current dateTimeFormat (0 terminated) for the specified 0578 * style, or empty string in case of error. The pointer and its contents 0579 * may no longer be valid if udatpg_setDateTimeFormat is called, or 0580 * udatpg_setDateTimeFormatForStyle for the same style is called, or the 0581 * UDateTimePatternGenerator object is closed. 0582 * @stable ICU 71 0583 */ 0584 U_CAPI const UChar* U_EXPORT2 0585 udatpg_getDateTimeFormatForStyle(const UDateTimePatternGenerator *udtpg, 0586 UDateFormatStyle style, int32_t *pLength, 0587 UErrorCode *pErrorCode); 0588 #endif /* #if !UCONFIG_NO_FORMATTING */ 0589 0590 /** 0591 * The decimal value is used in formatting fractions of seconds. If the 0592 * skeleton contains fractional seconds, then this is used with the 0593 * fractional seconds. For example, suppose that the input pattern is 0594 * "hhmmssSSSS", and the best matching pattern internally is "H:mm:ss", and 0595 * the decimal string is ",". Then the resulting pattern is modified to be 0596 * "H:mm:ss,SSSS" 0597 * 0598 * @param dtpg a pointer to UDateTimePatternGenerator. 0599 * @param decimal 0600 * @param length the length of decimal. 0601 * @stable ICU 3.8 0602 */ 0603 U_CAPI void U_EXPORT2 0604 udatpg_setDecimal(UDateTimePatternGenerator *dtpg, 0605 const UChar *decimal, int32_t length); 0606 0607 /** 0608 * Getter corresponding to setDecimal. 0609 * 0610 * @param dtpg a pointer to UDateTimePatternGenerator. 0611 * @param pLength A pointer that will receive the length of the decimal string. 0612 * @return corresponding to the decimal point. 0613 * @stable ICU 3.8 0614 */ 0615 U_CAPI const UChar * U_EXPORT2 0616 udatpg_getDecimal(const UDateTimePatternGenerator *dtpg, 0617 int32_t *pLength); 0618 0619 /** 0620 * Adjusts the field types (width and subtype) of a pattern to match what is 0621 * in a skeleton. That is, if you supply a pattern like "d-M H:m", and a 0622 * skeleton of "MMMMddhhmm", then the input pattern is adjusted to be 0623 * "dd-MMMM hh:mm". This is used internally to get the best match for the 0624 * input skeleton, but can also be used externally. 0625 * 0626 * Note that this function uses a non-const UDateTimePatternGenerator: 0627 * It uses a stateful pattern parser which is set up for each generator object, 0628 * rather than creating one for each function call. 0629 * Consecutive calls to this function do not affect each other, 0630 * but this function cannot be used concurrently on a single generator object. 0631 * 0632 * @param dtpg a pointer to UDateTimePatternGenerator. 0633 * @param pattern Input pattern 0634 * @param patternLength the length of input pattern. 0635 * @param skeleton 0636 * @param skeletonLength the length of input skeleton. 0637 * @param dest pattern adjusted to match the skeleton fields widths and subtypes. 0638 * @param destCapacity the capacity of dest. 0639 * @param pErrorCode a pointer to the UErrorCode which must not indicate a 0640 * failure before the function call. 0641 * @return the length of dest. 0642 * @stable ICU 3.8 0643 */ 0644 U_CAPI int32_t U_EXPORT2 0645 udatpg_replaceFieldTypes(UDateTimePatternGenerator *dtpg, 0646 const UChar *pattern, int32_t patternLength, 0647 const UChar *skeleton, int32_t skeletonLength, 0648 UChar *dest, int32_t destCapacity, 0649 UErrorCode *pErrorCode); 0650 0651 /** 0652 * Adjusts the field types (width and subtype) of a pattern to match what is 0653 * in a skeleton. That is, if you supply a pattern like "d-M H:m", and a 0654 * skeleton of "MMMMddhhmm", then the input pattern is adjusted to be 0655 * "dd-MMMM hh:mm". This is used internally to get the best match for the 0656 * input skeleton, but can also be used externally. 0657 * 0658 * Note that this function uses a non-const UDateTimePatternGenerator: 0659 * It uses a stateful pattern parser which is set up for each generator object, 0660 * rather than creating one for each function call. 0661 * Consecutive calls to this function do not affect each other, 0662 * but this function cannot be used concurrently on a single generator object. 0663 * 0664 * @param dtpg a pointer to UDateTimePatternGenerator. 0665 * @param pattern Input pattern 0666 * @param patternLength the length of input pattern. 0667 * @param skeleton 0668 * @param skeletonLength the length of input skeleton. 0669 * @param options 0670 * Options controlling whether the length of specified fields in the 0671 * pattern are adjusted to match those in the skeleton (when this 0672 * would not happen otherwise). For default behavior, use 0673 * UDATPG_MATCH_NO_OPTIONS. 0674 * @param dest pattern adjusted to match the skeleton fields widths and subtypes. 0675 * @param destCapacity the capacity of dest. 0676 * @param pErrorCode a pointer to the UErrorCode which must not indicate a 0677 * failure before the function call. 0678 * @return the length of dest. 0679 * @stable ICU 4.4 0680 */ 0681 U_CAPI int32_t U_EXPORT2 0682 udatpg_replaceFieldTypesWithOptions(UDateTimePatternGenerator *dtpg, 0683 const UChar *pattern, int32_t patternLength, 0684 const UChar *skeleton, int32_t skeletonLength, 0685 UDateTimePatternMatchOptions options, 0686 UChar *dest, int32_t destCapacity, 0687 UErrorCode *pErrorCode); 0688 0689 /** 0690 * Return a UEnumeration list of all the skeletons in canonical form. 0691 * Call udatpg_getPatternForSkeleton() to get the corresponding pattern. 0692 * 0693 * @param dtpg a pointer to UDateTimePatternGenerator. 0694 * @param pErrorCode a pointer to the UErrorCode which must not indicate a 0695 * failure before the function call 0696 * @return a UEnumeration list of all the skeletons 0697 * The caller must close the object. 0698 * @stable ICU 3.8 0699 */ 0700 U_CAPI UEnumeration * U_EXPORT2 0701 udatpg_openSkeletons(const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode); 0702 0703 /** 0704 * Return a UEnumeration list of all the base skeletons in canonical form. 0705 * 0706 * @param dtpg a pointer to UDateTimePatternGenerator. 0707 * @param pErrorCode a pointer to the UErrorCode which must not indicate a 0708 * failure before the function call. 0709 * @return a UEnumeration list of all the base skeletons 0710 * The caller must close the object. 0711 * @stable ICU 3.8 0712 */ 0713 U_CAPI UEnumeration * U_EXPORT2 0714 udatpg_openBaseSkeletons(const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode); 0715 0716 /** 0717 * Get the pattern corresponding to a given skeleton. 0718 * 0719 * @param dtpg a pointer to UDateTimePatternGenerator. 0720 * @param skeleton 0721 * @param skeletonLength pointer to the length of skeleton. 0722 * @param pLength pointer to the length of return pattern. 0723 * @return pattern corresponding to a given skeleton. 0724 * @stable ICU 3.8 0725 */ 0726 U_CAPI const UChar * U_EXPORT2 0727 udatpg_getPatternForSkeleton(const UDateTimePatternGenerator *dtpg, 0728 const UChar *skeleton, int32_t skeletonLength, 0729 int32_t *pLength); 0730 0731 #if !UCONFIG_NO_FORMATTING 0732 0733 /** 0734 * Return the default hour cycle for a locale. Uses the locale that the 0735 * UDateTimePatternGenerator was initially created with. 0736 * 0737 * Cannot be used on an empty UDateTimePatternGenerator instance. 0738 * 0739 * @param dtpg a pointer to UDateTimePatternGenerator. 0740 * @param pErrorCode a pointer to the UErrorCode which must not indicate a 0741 * failure before the function call. Set to U_UNSUPPORTED_ERROR 0742 * if used on an empty instance. 0743 * @return the default hour cycle. 0744 * @stable ICU 67 0745 */ 0746 U_CAPI UDateFormatHourCycle U_EXPORT2 0747 udatpg_getDefaultHourCycle(const UDateTimePatternGenerator *dtpg, UErrorCode* pErrorCode); 0748 0749 #endif /* #if !UCONFIG_NO_FORMATTING */ 0750 0751 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |