michael@0: /* michael@0: ******************************************************************************* michael@0: * michael@0: * Copyright (C) 2007-2012, International Business Machines michael@0: * Corporation and others. All Rights Reserved. michael@0: * michael@0: ******************************************************************************* michael@0: * file name: udatpg.h michael@0: * encoding: US-ASCII michael@0: * tab size: 8 (not used) michael@0: * indentation:4 michael@0: * michael@0: * created on: 2007jul30 michael@0: * created by: Markus W. Scherer michael@0: */ michael@0: michael@0: #ifndef __UDATPG_H__ michael@0: #define __UDATPG_H__ michael@0: michael@0: #include "unicode/utypes.h" michael@0: #include "unicode/uenum.h" michael@0: #include "unicode/localpointer.h" michael@0: michael@0: /** michael@0: * \file michael@0: * \brief C API: Wrapper for icu::DateTimePatternGenerator (unicode/dtptngen.h). michael@0: * michael@0: * UDateTimePatternGenerator provides flexible generation of date format patterns, michael@0: * like "yy-MM-dd". The user can build up the generator by adding successive michael@0: * patterns. Once that is done, a query can be made using a "skeleton", which is michael@0: * a pattern which just includes the desired fields and lengths. The generator michael@0: * will return the "best fit" pattern corresponding to that skeleton. michael@0: *
The main method people will use is udatpg_getBestPattern, since normally michael@0: * UDateTimePatternGenerator is pre-built with data from a particular locale. michael@0: * However, generators can be built directly from other data as well. michael@0: *
Issue: may be useful to also have a function that returns the list of michael@0: * fields in a pattern, in order, since we have that internally. michael@0: * That would be useful for getting the UI order of field elements. michael@0: */ michael@0: michael@0: /** michael@0: * Opaque type for a date/time pattern generator object. michael@0: * @stable ICU 3.8 michael@0: */ michael@0: typedef void *UDateTimePatternGenerator; michael@0: michael@0: /** michael@0: * Field number constants for udatpg_getAppendItemFormats() and similar functions. michael@0: * These constants are separate from UDateFormatField despite semantic overlap michael@0: * because some fields are merged for the date/time pattern generator. michael@0: * @stable ICU 3.8 michael@0: */ michael@0: typedef enum UDateTimePatternField { michael@0: /** @stable ICU 3.8 */ michael@0: UDATPG_ERA_FIELD, michael@0: /** @stable ICU 3.8 */ michael@0: UDATPG_YEAR_FIELD, michael@0: /** @stable ICU 3.8 */ michael@0: UDATPG_QUARTER_FIELD, michael@0: /** @stable ICU 3.8 */ michael@0: UDATPG_MONTH_FIELD, michael@0: /** @stable ICU 3.8 */ michael@0: UDATPG_WEEK_OF_YEAR_FIELD, michael@0: /** @stable ICU 3.8 */ michael@0: UDATPG_WEEK_OF_MONTH_FIELD, michael@0: /** @stable ICU 3.8 */ michael@0: UDATPG_WEEKDAY_FIELD, michael@0: /** @stable ICU 3.8 */ michael@0: UDATPG_DAY_OF_YEAR_FIELD, michael@0: /** @stable ICU 3.8 */ michael@0: UDATPG_DAY_OF_WEEK_IN_MONTH_FIELD, michael@0: /** @stable ICU 3.8 */ michael@0: UDATPG_DAY_FIELD, michael@0: /** @stable ICU 3.8 */ michael@0: UDATPG_DAYPERIOD_FIELD, michael@0: /** @stable ICU 3.8 */ michael@0: UDATPG_HOUR_FIELD, michael@0: /** @stable ICU 3.8 */ michael@0: UDATPG_MINUTE_FIELD, michael@0: /** @stable ICU 3.8 */ michael@0: UDATPG_SECOND_FIELD, michael@0: /** @stable ICU 3.8 */ michael@0: UDATPG_FRACTIONAL_SECOND_FIELD, michael@0: /** @stable ICU 3.8 */ michael@0: UDATPG_ZONE_FIELD, michael@0: /** @stable ICU 3.8 */ michael@0: UDATPG_FIELD_COUNT michael@0: } UDateTimePatternField; michael@0: michael@0: /** michael@0: * Masks to control forcing the length of specified fields in the returned michael@0: * pattern to match those in the skeleton (when this would not happen michael@0: * otherwise). These may be combined to force the length of multiple fields. michael@0: * Used with udatpg_getBestPatternWithOptions, udatpg_replaceFieldTypesWithOptions. michael@0: * @stable ICU 4.4 michael@0: */ michael@0: typedef enum UDateTimePatternMatchOptions { michael@0: /** @stable ICU 4.4 */ michael@0: UDATPG_MATCH_NO_OPTIONS = 0, michael@0: /** @stable ICU 4.4 */ michael@0: UDATPG_MATCH_HOUR_FIELD_LENGTH = 1 << UDATPG_HOUR_FIELD, michael@0: #ifndef U_HIDE_INTERNAL_API michael@0: /** @internal ICU 4.4 */ michael@0: UDATPG_MATCH_MINUTE_FIELD_LENGTH = 1 << UDATPG_MINUTE_FIELD, michael@0: /** @internal ICU 4.4 */ michael@0: UDATPG_MATCH_SECOND_FIELD_LENGTH = 1 << UDATPG_SECOND_FIELD, michael@0: #endif /* U_HIDE_INTERNAL_API */ michael@0: /** @stable ICU 4.4 */ michael@0: UDATPG_MATCH_ALL_FIELDS_LENGTH = (1 << UDATPG_FIELD_COUNT) - 1 michael@0: } UDateTimePatternMatchOptions; michael@0: michael@0: /** michael@0: * Status return values from udatpg_addPattern(). michael@0: * @stable ICU 3.8 michael@0: */ michael@0: typedef enum UDateTimePatternConflict { michael@0: /** @stable ICU 3.8 */ michael@0: UDATPG_NO_CONFLICT, michael@0: /** @stable ICU 3.8 */ michael@0: UDATPG_BASE_CONFLICT, michael@0: /** @stable ICU 3.8 */ michael@0: UDATPG_CONFLICT, michael@0: /** @stable ICU 3.8 */ michael@0: UDATPG_CONFLICT_COUNT michael@0: } UDateTimePatternConflict; michael@0: michael@0: /** michael@0: * Open a generator according to a given locale. michael@0: * @param locale michael@0: * @param pErrorCode a pointer to the UErrorCode which must not indicate a michael@0: * failure before the function call. michael@0: * @return a pointer to UDateTimePatternGenerator. michael@0: * @stable ICU 3.8 michael@0: */ michael@0: U_STABLE UDateTimePatternGenerator * U_EXPORT2 michael@0: udatpg_open(const char *locale, UErrorCode *pErrorCode); michael@0: michael@0: /** michael@0: * Open an empty generator, to be constructed with udatpg_addPattern(...) etc. michael@0: * @param pErrorCode a pointer to the UErrorCode which must not indicate a michael@0: * failure before the function call. michael@0: * @return a pointer to UDateTimePatternGenerator. michael@0: * @stable ICU 3.8 michael@0: */ michael@0: U_STABLE UDateTimePatternGenerator * U_EXPORT2 michael@0: udatpg_openEmpty(UErrorCode *pErrorCode); michael@0: michael@0: /** michael@0: * Close a generator. michael@0: * @param dtpg a pointer to UDateTimePatternGenerator. michael@0: * @stable ICU 3.8 michael@0: */ michael@0: U_STABLE void U_EXPORT2 michael@0: udatpg_close(UDateTimePatternGenerator *dtpg); michael@0: michael@0: #if U_SHOW_CPLUSPLUS_API michael@0: michael@0: U_NAMESPACE_BEGIN michael@0: michael@0: /** michael@0: * \class LocalUDateTimePatternGeneratorPointer michael@0: * "Smart pointer" class, closes a UDateTimePatternGenerator via udatpg_close(). michael@0: * For most methods see the LocalPointerBase base class. michael@0: * michael@0: * @see LocalPointerBase michael@0: * @see LocalPointer michael@0: * @stable ICU 4.4 michael@0: */ michael@0: U_DEFINE_LOCAL_OPEN_POINTER(LocalUDateTimePatternGeneratorPointer, UDateTimePatternGenerator, udatpg_close); michael@0: michael@0: U_NAMESPACE_END michael@0: michael@0: #endif michael@0: michael@0: /** michael@0: * Create a copy pf a generator. michael@0: * @param dtpg a pointer to UDateTimePatternGenerator to be copied. michael@0: * @param pErrorCode a pointer to the UErrorCode which must not indicate a michael@0: * failure before the function call. michael@0: * @return a pointer to a new UDateTimePatternGenerator. michael@0: * @stable ICU 3.8 michael@0: */ michael@0: U_STABLE UDateTimePatternGenerator * U_EXPORT2 michael@0: udatpg_clone(const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode); michael@0: michael@0: /** michael@0: * Get the best pattern matching the input skeleton. It is guaranteed to michael@0: * have all of the fields in the skeleton. michael@0: * michael@0: * Note that this function uses a non-const UDateTimePatternGenerator: michael@0: * It uses a stateful pattern parser which is set up for each generator object, michael@0: * rather than creating one for each function call. michael@0: * Consecutive calls to this function do not affect each other, michael@0: * but this function cannot be used concurrently on a single generator object. michael@0: * michael@0: * @param dtpg a pointer to UDateTimePatternGenerator. michael@0: * @param skeleton michael@0: * The skeleton is a pattern containing only the variable fields. michael@0: * For example, "MMMdd" and "mmhh" are skeletons. michael@0: * @param length the length of skeleton michael@0: * @param bestPattern michael@0: * The best pattern found from the given skeleton. michael@0: * @param capacity the capacity of bestPattern. michael@0: * @param pErrorCode a pointer to the UErrorCode which must not indicate a michael@0: * failure before the function call. michael@0: * @return the length of bestPattern. michael@0: * @stable ICU 3.8 michael@0: */ michael@0: U_STABLE int32_t U_EXPORT2 michael@0: udatpg_getBestPattern(UDateTimePatternGenerator *dtpg, michael@0: const UChar *skeleton, int32_t length, michael@0: UChar *bestPattern, int32_t capacity, michael@0: UErrorCode *pErrorCode); michael@0: michael@0: /** michael@0: * Get the best pattern matching the input skeleton. It is guaranteed to michael@0: * have all of the fields in the skeleton. michael@0: * michael@0: * Note that this function uses a non-const UDateTimePatternGenerator: michael@0: * It uses a stateful pattern parser which is set up for each generator object, michael@0: * rather than creating one for each function call. michael@0: * Consecutive calls to this function do not affect each other, michael@0: * but this function cannot be used concurrently on a single generator object. michael@0: * michael@0: * @param dtpg a pointer to UDateTimePatternGenerator. michael@0: * @param skeleton michael@0: * The skeleton is a pattern containing only the variable fields. michael@0: * For example, "MMMdd" and "mmhh" are skeletons. michael@0: * @param length the length of skeleton michael@0: * @param options michael@0: * Options for forcing the length of specified fields in the michael@0: * returned pattern to match those in the skeleton (when this michael@0: * would not happen otherwise). For default behavior, use michael@0: * UDATPG_MATCH_NO_OPTIONS. michael@0: * @param bestPattern michael@0: * The best pattern found from the given skeleton. michael@0: * @param capacity michael@0: * the capacity of bestPattern. michael@0: * @param pErrorCode michael@0: * a pointer to the UErrorCode which must not indicate a michael@0: * failure before the function call. michael@0: * @return the length of bestPattern. michael@0: * @stable ICU 4.4 michael@0: */ michael@0: U_STABLE int32_t U_EXPORT2 michael@0: udatpg_getBestPatternWithOptions(UDateTimePatternGenerator *dtpg, michael@0: const UChar *skeleton, int32_t length, michael@0: UDateTimePatternMatchOptions options, michael@0: UChar *bestPattern, int32_t capacity, michael@0: UErrorCode *pErrorCode); michael@0: michael@0: /** michael@0: * Get a unique skeleton from a given pattern. For example, michael@0: * both "MMM-dd" and "dd/MMM" produce the skeleton "MMMdd". michael@0: * michael@0: * Note that this function uses a non-const UDateTimePatternGenerator: michael@0: * It uses a stateful pattern parser which is set up for each generator object, michael@0: * rather than creating one for each function call. michael@0: * Consecutive calls to this function do not affect each other, michael@0: * but this function cannot be used concurrently on a single generator object. michael@0: * michael@0: * @param dtpg a pointer to UDateTimePatternGenerator. michael@0: * @param pattern input pattern, such as "dd/MMM". michael@0: * @param length the length of pattern. michael@0: * @param skeleton such as "MMMdd" michael@0: * @param capacity the capacity of skeleton. michael@0: * @param pErrorCode a pointer to the UErrorCode which must not indicate a michael@0: * failure before the function call. michael@0: * @return the length of skeleton. michael@0: * @stable ICU 3.8 michael@0: */ michael@0: U_STABLE int32_t U_EXPORT2 michael@0: udatpg_getSkeleton(UDateTimePatternGenerator *dtpg, michael@0: const UChar *pattern, int32_t length, michael@0: UChar *skeleton, int32_t capacity, michael@0: UErrorCode *pErrorCode); michael@0: michael@0: /** michael@0: * Get a unique base skeleton from a given pattern. This is the same michael@0: * as the skeleton, except that differences in length are minimized so michael@0: * as to only preserve the difference between string and numeric form. So michael@0: * for example, both "MMM-dd" and "d/MMM" produce the skeleton "MMMd" michael@0: * (notice the single d). michael@0: * michael@0: * Note that this function uses a non-const UDateTimePatternGenerator: michael@0: * It uses a stateful pattern parser which is set up for each generator object, michael@0: * rather than creating one for each function call. michael@0: * Consecutive calls to this function do not affect each other, michael@0: * but this function cannot be used concurrently on a single generator object. michael@0: * michael@0: * @param dtpg a pointer to UDateTimePatternGenerator. michael@0: * @param pattern input pattern, such as "dd/MMM". michael@0: * @param length the length of pattern. michael@0: * @param baseSkeleton such as "Md" michael@0: * @param capacity the capacity of base skeleton. michael@0: * @param pErrorCode a pointer to the UErrorCode which must not indicate a michael@0: * failure before the function call. michael@0: * @return the length of baseSkeleton. michael@0: * @stable ICU 3.8 michael@0: */ michael@0: U_STABLE int32_t U_EXPORT2 michael@0: udatpg_getBaseSkeleton(UDateTimePatternGenerator *dtpg, michael@0: const UChar *pattern, int32_t length, michael@0: UChar *baseSkeleton, int32_t capacity, michael@0: UErrorCode *pErrorCode); michael@0: michael@0: /** michael@0: * Adds a pattern to the generator. If the pattern has the same skeleton as michael@0: * an existing pattern, and the override parameter is set, then the previous michael@0: * value is overriden. Otherwise, the previous value is retained. In either michael@0: * case, the conflicting status is set and previous vale is stored in michael@0: * conflicting pattern. michael@0: *
michael@0: * Note that single-field patterns (like "MMM") are automatically added, and michael@0: * don't need to be added explicitly! michael@0: * michael@0: * @param dtpg a pointer to UDateTimePatternGenerator. michael@0: * @param pattern input pattern, such as "dd/MMM" michael@0: * @param patternLength the length of pattern. michael@0: * @param override When existing values are to be overridden use true, michael@0: * otherwise use false. michael@0: * @param conflictingPattern Previous pattern with the same skeleton. michael@0: * @param capacity the capacity of conflictingPattern. michael@0: * @param pLength a pointer to the length of conflictingPattern. michael@0: * @param pErrorCode a pointer to the UErrorCode which must not indicate a michael@0: * failure before the function call. michael@0: * @return conflicting status. The value could be UDATPG_NO_CONFLICT, michael@0: * UDATPG_BASE_CONFLICT or UDATPG_CONFLICT. michael@0: * @stable ICU 3.8 michael@0: */ michael@0: U_STABLE UDateTimePatternConflict U_EXPORT2 michael@0: udatpg_addPattern(UDateTimePatternGenerator *dtpg, michael@0: const UChar *pattern, int32_t patternLength, michael@0: UBool override, michael@0: UChar *conflictingPattern, int32_t capacity, int32_t *pLength, michael@0: UErrorCode *pErrorCode); michael@0: michael@0: /** michael@0: * An AppendItem format is a pattern used to append a field if there is no michael@0: * good match. For example, suppose that the input skeleton is "GyyyyMMMd", michael@0: * and there is no matching pattern internally, but there is a pattern michael@0: * matching "yyyyMMMd", say "d-MM-yyyy". Then that pattern is used, plus the michael@0: * G. The way these two are conjoined is by using the AppendItemFormat for G michael@0: * (era). So if that value is, say "{0}, {1}" then the final resulting michael@0: * pattern is "d-MM-yyyy, G". michael@0: *
michael@0: * There are actually three available variables: {0} is the pattern so far, michael@0: * {1} is the element we are adding, and {2} is the name of the element. michael@0: *
michael@0: * This reflects the way that the CLDR data is organized. michael@0: * michael@0: * @param dtpg a pointer to UDateTimePatternGenerator. michael@0: * @param field UDateTimePatternField, such as UDATPG_ERA_FIELD michael@0: * @param value pattern, such as "{0}, {1}" michael@0: * @param length the length of value. michael@0: * @stable ICU 3.8 michael@0: */ michael@0: U_STABLE void U_EXPORT2 michael@0: udatpg_setAppendItemFormat(UDateTimePatternGenerator *dtpg, michael@0: UDateTimePatternField field, michael@0: const UChar *value, int32_t length); michael@0: michael@0: /** michael@0: * Getter corresponding to setAppendItemFormat. Values below 0 or at or michael@0: * above UDATPG_FIELD_COUNT are illegal arguments. michael@0: * michael@0: * @param dtpg A pointer to UDateTimePatternGenerator. michael@0: * @param field UDateTimePatternField, such as UDATPG_ERA_FIELD michael@0: * @param pLength A pointer that will receive the length of appendItemFormat. michael@0: * @return appendItemFormat for field. michael@0: * @stable ICU 3.8 michael@0: */ michael@0: U_STABLE const UChar * U_EXPORT2 michael@0: udatpg_getAppendItemFormat(const UDateTimePatternGenerator *dtpg, michael@0: UDateTimePatternField field, michael@0: int32_t *pLength); michael@0: michael@0: /** michael@0: * Set the name of field, eg "era" in English for ERA. These are only michael@0: * used if the corresponding AppendItemFormat is used, and if it contains a michael@0: * {2} variable. michael@0: *
michael@0: * This reflects the way that the CLDR data is organized. michael@0: * michael@0: * @param dtpg a pointer to UDateTimePatternGenerator. michael@0: * @param field UDateTimePatternField michael@0: * @param value name for the field. michael@0: * @param length the length of value. michael@0: * @stable ICU 3.8 michael@0: */ michael@0: U_STABLE void U_EXPORT2 michael@0: udatpg_setAppendItemName(UDateTimePatternGenerator *dtpg, michael@0: UDateTimePatternField field, michael@0: const UChar *value, int32_t length); michael@0: michael@0: /** michael@0: * Getter corresponding to setAppendItemNames. Values below 0 or at or above michael@0: * UDATPG_FIELD_COUNT are illegal arguments. michael@0: * michael@0: * @param dtpg a pointer to UDateTimePatternGenerator. michael@0: * @param field UDateTimePatternField, such as UDATPG_ERA_FIELD michael@0: * @param pLength A pointer that will receive the length of the name for field. michael@0: * @return name for field michael@0: * @stable ICU 3.8 michael@0: */ michael@0: U_STABLE const UChar * U_EXPORT2 michael@0: udatpg_getAppendItemName(const UDateTimePatternGenerator *dtpg, michael@0: UDateTimePatternField field, michael@0: int32_t *pLength); michael@0: michael@0: /** michael@0: * The date time format is a message format pattern used to compose date and michael@0: * time patterns. The default value is "{0} {1}", where {0} will be replaced michael@0: * by the date pattern and {1} will be replaced by the time pattern. michael@0: *
michael@0: * This is used when the input skeleton contains both date and time fields, michael@0: * but there is not a close match among the added patterns. For example, michael@0: * suppose that this object was created by adding "dd-MMM" and "hh:mm", and michael@0: * its datetimeFormat is the default "{0} {1}". Then if the input skeleton michael@0: * is "MMMdhmm", there is not an exact match, so the input skeleton is michael@0: * broken up into two components "MMMd" and "hmm". There are close matches michael@0: * for those two skeletons, so the result is put together with this pattern, michael@0: * resulting in "d-MMM h:mm". michael@0: * michael@0: * @param dtpg a pointer to UDateTimePatternGenerator. michael@0: * @param dtFormat michael@0: * message format pattern, here {0} will be replaced by the date michael@0: * pattern and {1} will be replaced by the time pattern. michael@0: * @param length the length of dtFormat. michael@0: * @stable ICU 3.8 michael@0: */ michael@0: U_STABLE void U_EXPORT2 michael@0: udatpg_setDateTimeFormat(const UDateTimePatternGenerator *dtpg, michael@0: const UChar *dtFormat, int32_t length); michael@0: michael@0: /** michael@0: * Getter corresponding to setDateTimeFormat. michael@0: * @param dtpg a pointer to UDateTimePatternGenerator. michael@0: * @param pLength A pointer that will receive the length of the format michael@0: * @return dateTimeFormat. michael@0: * @stable ICU 3.8 michael@0: */ michael@0: U_STABLE const UChar * U_EXPORT2 michael@0: udatpg_getDateTimeFormat(const UDateTimePatternGenerator *dtpg, michael@0: int32_t *pLength); michael@0: michael@0: /** michael@0: * The decimal value is used in formatting fractions of seconds. If the michael@0: * skeleton contains fractional seconds, then this is used with the michael@0: * fractional seconds. For example, suppose that the input pattern is michael@0: * "hhmmssSSSS", and the best matching pattern internally is "H:mm:ss", and michael@0: * the decimal string is ",". Then the resulting pattern is modified to be michael@0: * "H:mm:ss,SSSS" michael@0: * michael@0: * @param dtpg a pointer to UDateTimePatternGenerator. michael@0: * @param decimal michael@0: * @param length the length of decimal. michael@0: * @stable ICU 3.8 michael@0: */ michael@0: U_STABLE void U_EXPORT2 michael@0: udatpg_setDecimal(UDateTimePatternGenerator *dtpg, michael@0: const UChar *decimal, int32_t length); michael@0: michael@0: /** michael@0: * Getter corresponding to setDecimal. michael@0: * michael@0: * @param dtpg a pointer to UDateTimePatternGenerator. michael@0: * @param pLength A pointer that will receive the length of the decimal string. michael@0: * @return corresponding to the decimal point. michael@0: * @stable ICU 3.8 michael@0: */ michael@0: U_STABLE const UChar * U_EXPORT2 michael@0: udatpg_getDecimal(const UDateTimePatternGenerator *dtpg, michael@0: int32_t *pLength); michael@0: michael@0: /** michael@0: * Adjusts the field types (width and subtype) of a pattern to match what is michael@0: * in a skeleton. That is, if you supply a pattern like "d-M H:m", and a michael@0: * skeleton of "MMMMddhhmm", then the input pattern is adjusted to be michael@0: * "dd-MMMM hh:mm". This is used internally to get the best match for the michael@0: * input skeleton, but can also be used externally. michael@0: * michael@0: * Note that this function uses a non-const UDateTimePatternGenerator: michael@0: * It uses a stateful pattern parser which is set up for each generator object, michael@0: * rather than creating one for each function call. michael@0: * Consecutive calls to this function do not affect each other, michael@0: * but this function cannot be used concurrently on a single generator object. michael@0: * michael@0: * @param dtpg a pointer to UDateTimePatternGenerator. michael@0: * @param pattern Input pattern michael@0: * @param patternLength the length of input pattern. michael@0: * @param skeleton michael@0: * @param skeletonLength the length of input skeleton. michael@0: * @param dest pattern adjusted to match the skeleton fields widths and subtypes. michael@0: * @param destCapacity the capacity of dest. michael@0: * @param pErrorCode a pointer to the UErrorCode which must not indicate a michael@0: * failure before the function call. michael@0: * @return the length of dest. michael@0: * @stable ICU 3.8 michael@0: */ michael@0: U_STABLE int32_t U_EXPORT2 michael@0: udatpg_replaceFieldTypes(UDateTimePatternGenerator *dtpg, michael@0: const UChar *pattern, int32_t patternLength, michael@0: const UChar *skeleton, int32_t skeletonLength, michael@0: UChar *dest, int32_t destCapacity, michael@0: UErrorCode *pErrorCode); michael@0: michael@0: /** michael@0: * Adjusts the field types (width and subtype) of a pattern to match what is michael@0: * in a skeleton. That is, if you supply a pattern like "d-M H:m", and a michael@0: * skeleton of "MMMMddhhmm", then the input pattern is adjusted to be michael@0: * "dd-MMMM hh:mm". This is used internally to get the best match for the michael@0: * input skeleton, but can also be used externally. michael@0: * michael@0: * Note that this function uses a non-const UDateTimePatternGenerator: michael@0: * It uses a stateful pattern parser which is set up for each generator object, michael@0: * rather than creating one for each function call. michael@0: * Consecutive calls to this function do not affect each other, michael@0: * but this function cannot be used concurrently on a single generator object. michael@0: * michael@0: * @param dtpg a pointer to UDateTimePatternGenerator. michael@0: * @param pattern Input pattern michael@0: * @param patternLength the length of input pattern. michael@0: * @param skeleton michael@0: * @param skeletonLength the length of input skeleton. michael@0: * @param options michael@0: * Options controlling whether the length of specified fields in the michael@0: * pattern are adjusted to match those in the skeleton (when this michael@0: * would not happen otherwise). For default behavior, use michael@0: * UDATPG_MATCH_NO_OPTIONS. michael@0: * @param dest pattern adjusted to match the skeleton fields widths and subtypes. michael@0: * @param destCapacity the capacity of dest. michael@0: * @param pErrorCode a pointer to the UErrorCode which must not indicate a michael@0: * failure before the function call. michael@0: * @return the length of dest. michael@0: * @stable ICU 4.4 michael@0: */ michael@0: U_STABLE int32_t U_EXPORT2 michael@0: udatpg_replaceFieldTypesWithOptions(UDateTimePatternGenerator *dtpg, michael@0: const UChar *pattern, int32_t patternLength, michael@0: const UChar *skeleton, int32_t skeletonLength, michael@0: UDateTimePatternMatchOptions options, michael@0: UChar *dest, int32_t destCapacity, michael@0: UErrorCode *pErrorCode); michael@0: michael@0: /** michael@0: * Return a UEnumeration list of all the skeletons in canonical form. michael@0: * Call udatpg_getPatternForSkeleton() to get the corresponding pattern. michael@0: * michael@0: * @param dtpg a pointer to UDateTimePatternGenerator. michael@0: * @param pErrorCode a pointer to the UErrorCode which must not indicate a michael@0: * failure before the function call michael@0: * @return a UEnumeration list of all the skeletons michael@0: * The caller must close the object. michael@0: * @stable ICU 3.8 michael@0: */ michael@0: U_STABLE UEnumeration * U_EXPORT2 michael@0: udatpg_openSkeletons(const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode); michael@0: michael@0: /** michael@0: * Return a UEnumeration list of all the base skeletons in canonical form. michael@0: * michael@0: * @param dtpg a pointer to UDateTimePatternGenerator. michael@0: * @param pErrorCode a pointer to the UErrorCode which must not indicate a michael@0: * failure before the function call. michael@0: * @return a UEnumeration list of all the base skeletons michael@0: * The caller must close the object. michael@0: * @stable ICU 3.8 michael@0: */ michael@0: U_STABLE UEnumeration * U_EXPORT2 michael@0: udatpg_openBaseSkeletons(const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode); michael@0: michael@0: /** michael@0: * Get the pattern corresponding to a given skeleton. michael@0: * michael@0: * @param dtpg a pointer to UDateTimePatternGenerator. michael@0: * @param skeleton michael@0: * @param skeletonLength pointer to the length of skeleton. michael@0: * @param pLength pointer to the length of return pattern. michael@0: * @return pattern corresponding to a given skeleton. michael@0: * @stable ICU 3.8 michael@0: */ michael@0: U_STABLE const UChar * U_EXPORT2 michael@0: udatpg_getPatternForSkeleton(const UDateTimePatternGenerator *dtpg, michael@0: const UChar *skeleton, int32_t skeletonLength, michael@0: int32_t *pLength); michael@0: michael@0: #endif