webkit  2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
Typedefs | Enumerations | Functions
udatpg.h File Reference

C API: Wrapper for icu::DateTimePatternGenerator (unicode/dtptngen.h). More...

#include "unicode/utypes.h"
#include "unicode/uenum.h"
#include "unicode/localpointer.h"

Go to the source code of this file.

Typedefs

typedef voidUDateTimePatternGenerator
 
typedef enum UDateTimePatternField UDateTimePatternField
 
typedef enum UDateTimePatternMatchOptions UDateTimePatternMatchOptions
 
typedef enum UDateTimePatternConflict UDateTimePatternConflict
 

Enumerations

enum  UDateTimePatternField {
  UDATPG_ERA_FIELD, UDATPG_YEAR_FIELD, UDATPG_QUARTER_FIELD, UDATPG_MONTH_FIELD,
  UDATPG_WEEK_OF_YEAR_FIELD, UDATPG_WEEK_OF_MONTH_FIELD, UDATPG_WEEKDAY_FIELD, UDATPG_DAY_OF_YEAR_FIELD,
  UDATPG_DAY_OF_WEEK_IN_MONTH_FIELD, UDATPG_DAY_FIELD, UDATPG_DAYPERIOD_FIELD, UDATPG_HOUR_FIELD,
  UDATPG_MINUTE_FIELD, UDATPG_SECOND_FIELD, UDATPG_FRACTIONAL_SECOND_FIELD, UDATPG_ZONE_FIELD,
  UDATPG_FIELD_COUNT
}
 
enum  UDateTimePatternMatchOptions {
  UDATPG_MATCH_NO_OPTIONS = 0, UDATPG_MATCH_HOUR_FIELD_LENGTH = 1 << UDATPG_HOUR_FIELD, UDATPG_MATCH_MINUTE_FIELD_LENGTH = 1 << UDATPG_MINUTE_FIELD, UDATPG_MATCH_SECOND_FIELD_LENGTH = 1 << UDATPG_SECOND_FIELD,
  UDATPG_MATCH_ALL_FIELDS_LENGTH = (1 << UDATPG_FIELD_COUNT) - 1
}
 
enum  UDateTimePatternConflict { UDATPG_NO_CONFLICT, UDATPG_BASE_CONFLICT, UDATPG_CONFLICT, UDATPG_CONFLICT_COUNT }
 

Functions

U_STABLE UDateTimePatternGenerator *U_EXPORT2 udatpg_open (const char *locale, UErrorCode *pErrorCode)
 
U_STABLE UDateTimePatternGenerator *U_EXPORT2 udatpg_openEmpty (UErrorCode *pErrorCode)
 
U_STABLE void U_EXPORT2 udatpg_close (UDateTimePatternGenerator *dtpg)
 
U_STABLE UDateTimePatternGenerator *U_EXPORT2 udatpg_clone (const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode)
 
U_STABLE int32_t U_EXPORT2 udatpg_getBestPattern (UDateTimePatternGenerator *dtpg, const UChar *skeleton, int32_t length, UChar *bestPattern, int32_t capacity, UErrorCode *pErrorCode)
 
U_STABLE int32_t U_EXPORT2 udatpg_getBestPatternWithOptions (UDateTimePatternGenerator *dtpg, const UChar *skeleton, int32_t length, UDateTimePatternMatchOptions options, UChar *bestPattern, int32_t capacity, UErrorCode *pErrorCode)
 
U_STABLE int32_t U_EXPORT2 udatpg_getSkeleton (UDateTimePatternGenerator *dtpg, const UChar *pattern, int32_t length, UChar *skeleton, int32_t capacity, UErrorCode *pErrorCode)
 
U_STABLE int32_t U_EXPORT2 udatpg_getBaseSkeleton (UDateTimePatternGenerator *dtpg, const UChar *pattern, int32_t length, UChar *baseSkeleton, int32_t capacity, UErrorCode *pErrorCode)
 
U_STABLE UDateTimePatternConflict U_EXPORT2 udatpg_addPattern (UDateTimePatternGenerator *dtpg, const UChar *pattern, int32_t patternLength, UBool override, UChar *conflictingPattern, int32_t capacity, int32_t *pLength, UErrorCode *pErrorCode)
 
U_STABLE void U_EXPORT2 udatpg_setAppendItemFormat (UDateTimePatternGenerator *dtpg, UDateTimePatternField field, const UChar *value, int32_t length)
 
U_STABLE const UChar *U_EXPORT2 udatpg_getAppendItemFormat (const UDateTimePatternGenerator *dtpg, UDateTimePatternField field, int32_t *pLength)
 
U_STABLE void U_EXPORT2 udatpg_setAppendItemName (UDateTimePatternGenerator *dtpg, UDateTimePatternField field, const UChar *value, int32_t length)
 
U_STABLE const UChar *U_EXPORT2 udatpg_getAppendItemName (const UDateTimePatternGenerator *dtpg, UDateTimePatternField field, int32_t *pLength)
 
U_STABLE void U_EXPORT2 udatpg_setDateTimeFormat (const UDateTimePatternGenerator *dtpg, const UChar *dtFormat, int32_t length)
 
U_STABLE const UChar *U_EXPORT2 udatpg_getDateTimeFormat (const UDateTimePatternGenerator *dtpg, int32_t *pLength)
 
U_STABLE void U_EXPORT2 udatpg_setDecimal (UDateTimePatternGenerator *dtpg, const UChar *decimal, int32_t length)
 
U_STABLE const UChar *U_EXPORT2 udatpg_getDecimal (const UDateTimePatternGenerator *dtpg, int32_t *pLength)
 
U_STABLE int32_t U_EXPORT2 udatpg_replaceFieldTypes (UDateTimePatternGenerator *dtpg, const UChar *pattern, int32_t patternLength, const UChar *skeleton, int32_t skeletonLength, UChar *dest, int32_t destCapacity, UErrorCode *pErrorCode)
 
U_STABLE int32_t U_EXPORT2 udatpg_replaceFieldTypesWithOptions (UDateTimePatternGenerator *dtpg, const UChar *pattern, int32_t patternLength, const UChar *skeleton, int32_t skeletonLength, UDateTimePatternMatchOptions options, UChar *dest, int32_t destCapacity, UErrorCode *pErrorCode)
 
U_STABLE UEnumeration *U_EXPORT2 udatpg_openSkeletons (const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode)
 
U_STABLE UEnumeration *U_EXPORT2 udatpg_openBaseSkeletons (const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode)
 
U_STABLE const UChar *U_EXPORT2 udatpg_getPatternForSkeleton (const UDateTimePatternGenerator *dtpg, const UChar *skeleton, int32_t skeletonLength, int32_t *pLength)
 

Detailed Description

C API: Wrapper for icu::DateTimePatternGenerator (unicode/dtptngen.h).

UDateTimePatternGenerator provides flexible generation of date format patterns, like "yy-MM-dd". The user can build up the generator by adding successive patterns. Once that is done, a query can be made using a "skeleton", which is a pattern which just includes the desired fields and lengths. The generator will return the "best fit" pattern corresponding to that skeleton.

The main method people will use is udatpg_getBestPattern, since normally UDateTimePatternGenerator is pre-built with data from a particular locale. However, generators can be built directly from other data as well.

Issue: may be useful to also have a function that returns the list of fields in a pattern, in order, since we have that internally. That would be useful for getting the UI order of field elements.

Typedef Documentation

◆ UDateTimePatternConflict

Status return values from udatpg_addPattern(). ICU 3.8

◆ UDateTimePatternField

Field number constants for udatpg_getAppendItemFormats() and similar functions. These constants are separate from UDateFormatField despite semantic overlap because some fields are merged for the date/time pattern generator. ICU 3.8

◆ UDateTimePatternGenerator

Opaque type for a date/time pattern generator object. ICU 3.8

◆ UDateTimePatternMatchOptions

Masks to control forcing the length of specified fields in the returned pattern to match those in the skeleton (when this would not happen otherwise). These may be combined to force the length of multiple fields. Used with udatpg_getBestPatternWithOptions, udatpg_replaceFieldTypesWithOptions. ICU 4.4

Enumeration Type Documentation

◆ UDateTimePatternConflict

Status return values from udatpg_addPattern(). ICU 3.8

Enumerator
UDATPG_NO_CONFLICT 

ICU 3.8

UDATPG_BASE_CONFLICT 

ICU 3.8

UDATPG_CONFLICT 

ICU 3.8

UDATPG_CONFLICT_COUNT 

ICU 3.8

◆ UDateTimePatternField

Field number constants for udatpg_getAppendItemFormats() and similar functions. These constants are separate from UDateFormatField despite semantic overlap because some fields are merged for the date/time pattern generator. ICU 3.8

Enumerator
UDATPG_ERA_FIELD 

ICU 3.8

UDATPG_YEAR_FIELD 

ICU 3.8

UDATPG_QUARTER_FIELD 

ICU 3.8

UDATPG_MONTH_FIELD 

ICU 3.8

UDATPG_WEEK_OF_YEAR_FIELD 

ICU 3.8

UDATPG_WEEK_OF_MONTH_FIELD 

ICU 3.8

UDATPG_WEEKDAY_FIELD 

ICU 3.8

UDATPG_DAY_OF_YEAR_FIELD 

ICU 3.8

UDATPG_DAY_OF_WEEK_IN_MONTH_FIELD 

ICU 3.8

UDATPG_DAY_FIELD 

ICU 3.8

UDATPG_DAYPERIOD_FIELD 

ICU 3.8

UDATPG_HOUR_FIELD 

ICU 3.8

UDATPG_MINUTE_FIELD 

ICU 3.8

UDATPG_SECOND_FIELD 

ICU 3.8

UDATPG_FRACTIONAL_SECOND_FIELD 

ICU 3.8

UDATPG_ZONE_FIELD 

ICU 3.8

UDATPG_FIELD_COUNT 

ICU 3.8

◆ UDateTimePatternMatchOptions

Masks to control forcing the length of specified fields in the returned pattern to match those in the skeleton (when this would not happen otherwise). These may be combined to force the length of multiple fields. Used with udatpg_getBestPatternWithOptions, udatpg_replaceFieldTypesWithOptions. ICU 4.4

Enumerator
UDATPG_MATCH_NO_OPTIONS 

ICU 4.4

UDATPG_MATCH_HOUR_FIELD_LENGTH 

ICU 4.4

UDATPG_MATCH_MINUTE_FIELD_LENGTH 
UDATPG_MATCH_SECOND_FIELD_LENGTH 
UDATPG_MATCH_ALL_FIELDS_LENGTH 

ICU 4.4

Function Documentation

◆ udatpg_addPattern()

U_STABLE UDateTimePatternConflict U_EXPORT2 udatpg_addPattern ( UDateTimePatternGenerator dtpg,
const UChar pattern,
int32_t  patternLength,
UBool  override,
UChar conflictingPattern,
int32_t  capacity,
int32_t pLength,
UErrorCode pErrorCode 
)

Adds a pattern to the generator. If the pattern has the same skeleton as an existing pattern, and the override parameter is set, then the previous value is overriden. Otherwise, the previous value is retained. In either case, the conflicting status is set and previous vale is stored in conflicting pattern.

Note that single-field patterns (like "MMM") are automatically added, and don't need to be added explicitly!

Parameters
dtpga pointer to UDateTimePatternGenerator.
patterninput pattern, such as "dd/MMM"
patternLengththe length of pattern.
overrideWhen existing values are to be overridden use true, otherwise use false.
conflictingPatternPrevious pattern with the same skeleton.
capacitythe capacity of conflictingPattern.
pLengtha pointer to the length of conflictingPattern.
pErrorCodea pointer to the UErrorCode which must not indicate a failure before the function call.
Returns
conflicting status. The value could be UDATPG_NO_CONFLICT, UDATPG_BASE_CONFLICT or UDATPG_CONFLICT. ICU 3.8

◆ udatpg_clone()

U_STABLE UDateTimePatternGenerator* U_EXPORT2 udatpg_clone ( const UDateTimePatternGenerator dtpg,
UErrorCode pErrorCode 
)

Create a copy pf a generator.

Parameters
dtpga pointer to UDateTimePatternGenerator to be copied.
pErrorCodea pointer to the UErrorCode which must not indicate a failure before the function call.
Returns
a pointer to a new UDateTimePatternGenerator. ICU 3.8

◆ udatpg_close()

Close a generator.

Parameters
dtpga pointer to UDateTimePatternGenerator. ICU 3.8

◆ udatpg_getAppendItemFormat()

U_STABLE const UChar* U_EXPORT2 udatpg_getAppendItemFormat ( const UDateTimePatternGenerator dtpg,
UDateTimePatternField  field,
int32_t pLength 
)

Getter corresponding to setAppendItemFormat. Values below 0 or at or above UDATPG_FIELD_COUNT are illegal arguments.

Parameters
dtpgA pointer to UDateTimePatternGenerator.
fieldUDateTimePatternField, such as UDATPG_ERA_FIELD
pLengthA pointer that will receive the length of appendItemFormat.
Returns
appendItemFormat for field. ICU 3.8

◆ udatpg_getAppendItemName()

U_STABLE const UChar* U_EXPORT2 udatpg_getAppendItemName ( const UDateTimePatternGenerator dtpg,
UDateTimePatternField  field,
int32_t pLength 
)

Getter corresponding to setAppendItemNames. Values below 0 or at or above UDATPG_FIELD_COUNT are illegal arguments.

Parameters
dtpga pointer to UDateTimePatternGenerator.
fieldUDateTimePatternField, such as UDATPG_ERA_FIELD
pLengthA pointer that will receive the length of the name for field.
Returns
name for field ICU 3.8

◆ udatpg_getBaseSkeleton()

U_STABLE int32_t U_EXPORT2 udatpg_getBaseSkeleton ( UDateTimePatternGenerator dtpg,
const UChar pattern,
int32_t  length,
UChar baseSkeleton,
int32_t  capacity,
UErrorCode pErrorCode 
)

Get a unique base skeleton from a given pattern. This is the same as the skeleton, except that differences in length are minimized so as to only preserve the difference between string and numeric form. So for example, both "MMM-dd" and "d/MMM" produce the skeleton "MMMd" (notice the single d).

Note that this function uses a non-const UDateTimePatternGenerator: It uses a stateful pattern parser which is set up for each generator object, rather than creating one for each function call. Consecutive calls to this function do not affect each other, but this function cannot be used concurrently on a single generator object.

Parameters
dtpga pointer to UDateTimePatternGenerator.
patterninput pattern, such as "dd/MMM".
lengththe length of pattern.
baseSkeletonsuch as "Md"
capacitythe capacity of base skeleton.
pErrorCodea pointer to the UErrorCode which must not indicate a failure before the function call.
Returns
the length of baseSkeleton. ICU 3.8

◆ udatpg_getBestPattern()

U_STABLE int32_t U_EXPORT2 udatpg_getBestPattern ( UDateTimePatternGenerator dtpg,
const UChar skeleton,
int32_t  length,
UChar bestPattern,
int32_t  capacity,
UErrorCode pErrorCode 
)

Get the best pattern matching the input skeleton. It is guaranteed to have all of the fields in the skeleton.

Note that this function uses a non-const UDateTimePatternGenerator: It uses a stateful pattern parser which is set up for each generator object, rather than creating one for each function call. Consecutive calls to this function do not affect each other, but this function cannot be used concurrently on a single generator object.

Parameters
dtpga pointer to UDateTimePatternGenerator.
skeletonThe skeleton is a pattern containing only the variable fields. For example, "MMMdd" and "mmhh" are skeletons.
lengththe length of skeleton
bestPatternThe best pattern found from the given skeleton.
capacitythe capacity of bestPattern.
pErrorCodea pointer to the UErrorCode which must not indicate a failure before the function call.
Returns
the length of bestPattern. ICU 3.8

◆ udatpg_getBestPatternWithOptions()

U_STABLE int32_t U_EXPORT2 udatpg_getBestPatternWithOptions ( UDateTimePatternGenerator dtpg,
const UChar skeleton,
int32_t  length,
UDateTimePatternMatchOptions  options,
UChar bestPattern,
int32_t  capacity,
UErrorCode pErrorCode 
)

Get the best pattern matching the input skeleton. It is guaranteed to have all of the fields in the skeleton.

Note that this function uses a non-const UDateTimePatternGenerator: It uses a stateful pattern parser which is set up for each generator object, rather than creating one for each function call. Consecutive calls to this function do not affect each other, but this function cannot be used concurrently on a single generator object.

Parameters
dtpga pointer to UDateTimePatternGenerator.
skeletonThe skeleton is a pattern containing only the variable fields. For example, "MMMdd" and "mmhh" are skeletons.
lengththe length of skeleton
optionsOptions for forcing the length of specified fields in the returned pattern to match those in the skeleton (when this would not happen otherwise). For default behavior, use UDATPG_MATCH_NO_OPTIONS.
bestPatternThe best pattern found from the given skeleton.
capacitythe capacity of bestPattern.
pErrorCodea pointer to the UErrorCode which must not indicate a failure before the function call.
Returns
the length of bestPattern. ICU 4.4

◆ udatpg_getDateTimeFormat()

U_STABLE const UChar* U_EXPORT2 udatpg_getDateTimeFormat ( const UDateTimePatternGenerator dtpg,
int32_t pLength 
)

Getter corresponding to setDateTimeFormat.

Parameters
dtpga pointer to UDateTimePatternGenerator.
pLengthA pointer that will receive the length of the format
Returns
dateTimeFormat. ICU 3.8

◆ udatpg_getDecimal()

U_STABLE const UChar* U_EXPORT2 udatpg_getDecimal ( const UDateTimePatternGenerator dtpg,
int32_t pLength 
)

Getter corresponding to setDecimal.

Parameters
dtpga pointer to UDateTimePatternGenerator.
pLengthA pointer that will receive the length of the decimal string.
Returns
corresponding to the decimal point. ICU 3.8

◆ udatpg_getPatternForSkeleton()

U_STABLE const UChar* U_EXPORT2 udatpg_getPatternForSkeleton ( const UDateTimePatternGenerator dtpg,
const UChar skeleton,
int32_t  skeletonLength,
int32_t pLength 
)

Get the pattern corresponding to a given skeleton.

Parameters
dtpga pointer to UDateTimePatternGenerator.
skeleton
skeletonLengthpointer to the length of skeleton.
pLengthpointer to the length of return pattern.
Returns
pattern corresponding to a given skeleton. ICU 3.8

◆ udatpg_getSkeleton()

U_STABLE int32_t U_EXPORT2 udatpg_getSkeleton ( UDateTimePatternGenerator dtpg,
const UChar pattern,
int32_t  length,
UChar skeleton,
int32_t  capacity,
UErrorCode pErrorCode 
)

Get a unique skeleton from a given pattern. For example, both "MMM-dd" and "dd/MMM" produce the skeleton "MMMdd".

Note that this function uses a non-const UDateTimePatternGenerator: It uses a stateful pattern parser which is set up for each generator object, rather than creating one for each function call. Consecutive calls to this function do not affect each other, but this function cannot be used concurrently on a single generator object.

Parameters
dtpga pointer to UDateTimePatternGenerator.
patterninput pattern, such as "dd/MMM".
lengththe length of pattern.
skeletonsuch as "MMMdd"
capacitythe capacity of skeleton.
pErrorCodea pointer to the UErrorCode which must not indicate a failure before the function call.
Returns
the length of skeleton. ICU 3.8

◆ udatpg_open()

U_STABLE UDateTimePatternGenerator* U_EXPORT2 udatpg_open ( const char *  locale,
UErrorCode pErrorCode 
)

Open a generator according to a given locale.

Parameters
locale
pErrorCodea pointer to the UErrorCode which must not indicate a failure before the function call.
Returns
a pointer to UDateTimePatternGenerator. ICU 3.8

◆ udatpg_openBaseSkeletons()

U_STABLE UEnumeration* U_EXPORT2 udatpg_openBaseSkeletons ( const UDateTimePatternGenerator dtpg,
UErrorCode pErrorCode 
)

Return a UEnumeration list of all the base skeletons in canonical form.

Parameters
dtpga pointer to UDateTimePatternGenerator.
pErrorCodea pointer to the UErrorCode which must not indicate a failure before the function call.
Returns
a UEnumeration list of all the base skeletons The caller must close the object. ICU 3.8

◆ udatpg_openEmpty()

U_STABLE UDateTimePatternGenerator* U_EXPORT2 udatpg_openEmpty ( UErrorCode pErrorCode)

Open an empty generator, to be constructed with udatpg_addPattern(...) etc.

Parameters
pErrorCodea pointer to the UErrorCode which must not indicate a failure before the function call.
Returns
a pointer to UDateTimePatternGenerator. ICU 3.8

◆ udatpg_openSkeletons()

U_STABLE UEnumeration* U_EXPORT2 udatpg_openSkeletons ( const UDateTimePatternGenerator dtpg,
UErrorCode pErrorCode 
)

Return a UEnumeration list of all the skeletons in canonical form. Call udatpg_getPatternForSkeleton() to get the corresponding pattern.

Parameters
dtpga pointer to UDateTimePatternGenerator.
pErrorCodea pointer to the UErrorCode which must not indicate a failure before the function call
Returns
a UEnumeration list of all the skeletons The caller must close the object. ICU 3.8

◆ udatpg_replaceFieldTypes()

U_STABLE int32_t U_EXPORT2 udatpg_replaceFieldTypes ( UDateTimePatternGenerator dtpg,
const UChar pattern,
int32_t  patternLength,
const UChar skeleton,
int32_t  skeletonLength,
UChar dest,
int32_t  destCapacity,
UErrorCode pErrorCode 
)

Adjusts the field types (width and subtype) of a pattern to match what is in a skeleton. That is, if you supply a pattern like "d-M H:m", and a skeleton of "MMMMddhhmm", then the input pattern is adjusted to be "dd-MMMM hh:mm". This is used internally to get the best match for the input skeleton, but can also be used externally.

Note that this function uses a non-const UDateTimePatternGenerator: It uses a stateful pattern parser which is set up for each generator object, rather than creating one for each function call. Consecutive calls to this function do not affect each other, but this function cannot be used concurrently on a single generator object.

Parameters
dtpga pointer to UDateTimePatternGenerator.
patternInput pattern
patternLengththe length of input pattern.
skeleton
skeletonLengththe length of input skeleton.
destpattern adjusted to match the skeleton fields widths and subtypes.
destCapacitythe capacity of dest.
pErrorCodea pointer to the UErrorCode which must not indicate a failure before the function call.
Returns
the length of dest. ICU 3.8

◆ udatpg_replaceFieldTypesWithOptions()

U_STABLE int32_t U_EXPORT2 udatpg_replaceFieldTypesWithOptions ( UDateTimePatternGenerator dtpg,
const UChar pattern,
int32_t  patternLength,
const UChar skeleton,
int32_t  skeletonLength,
UDateTimePatternMatchOptions  options,
UChar dest,
int32_t  destCapacity,
UErrorCode pErrorCode 
)

Adjusts the field types (width and subtype) of a pattern to match what is in a skeleton. That is, if you supply a pattern like "d-M H:m", and a skeleton of "MMMMddhhmm", then the input pattern is adjusted to be "dd-MMMM hh:mm". This is used internally to get the best match for the input skeleton, but can also be used externally.

Note that this function uses a non-const UDateTimePatternGenerator: It uses a stateful pattern parser which is set up for each generator object, rather than creating one for each function call. Consecutive calls to this function do not affect each other, but this function cannot be used concurrently on a single generator object.

Parameters
dtpga pointer to UDateTimePatternGenerator.
patternInput pattern
patternLengththe length of input pattern.
skeleton
skeletonLengththe length of input skeleton.
optionsOptions controlling whether the length of specified fields in the pattern are adjusted to match those in the skeleton (when this would not happen otherwise). For default behavior, use UDATPG_MATCH_NO_OPTIONS.
destpattern adjusted to match the skeleton fields widths and subtypes.
destCapacitythe capacity of dest.
pErrorCodea pointer to the UErrorCode which must not indicate a failure before the function call.
Returns
the length of dest. ICU 4.4

◆ udatpg_setAppendItemFormat()

U_STABLE void U_EXPORT2 udatpg_setAppendItemFormat ( UDateTimePatternGenerator dtpg,
UDateTimePatternField  field,
const UChar value,
int32_t  length 
)

An AppendItem format is a pattern used to append a field if there is no good match. For example, suppose that the input skeleton is "GyyyyMMMd", and there is no matching pattern internally, but there is a pattern matching "yyyyMMMd", say "d-MM-yyyy". Then that pattern is used, plus the G. The way these two are conjoined is by using the AppendItemFormat for G (era). So if that value is, say "{0}, {1}" then the final resulting pattern is "d-MM-yyyy, G".

There are actually three available variables: {0} is the pattern so far, {1} is the element we are adding, and {2} is the name of the element.

This reflects the way that the CLDR data is organized.

Parameters
dtpga pointer to UDateTimePatternGenerator.
fieldUDateTimePatternField, such as UDATPG_ERA_FIELD
valuepattern, such as "{0}, {1}"
lengththe length of value. ICU 3.8

◆ udatpg_setAppendItemName()

U_STABLE void U_EXPORT2 udatpg_setAppendItemName ( UDateTimePatternGenerator dtpg,
UDateTimePatternField  field,
const UChar value,
int32_t  length 
)

Set the name of field, eg "era" in English for ERA. These are only used if the corresponding AppendItemFormat is used, and if it contains a {2} variable.

This reflects the way that the CLDR data is organized.

Parameters
dtpga pointer to UDateTimePatternGenerator.
fieldUDateTimePatternField
valuename for the field.
lengththe length of value. ICU 3.8

◆ udatpg_setDateTimeFormat()

U_STABLE void U_EXPORT2 udatpg_setDateTimeFormat ( const UDateTimePatternGenerator dtpg,
const UChar dtFormat,
int32_t  length 
)

The date time format is a message format pattern used to compose date and time patterns. The default value is "{0} {1}", where {0} will be replaced by the date pattern and {1} will be replaced by the time pattern.

This is used when the input skeleton contains both date and time fields, but there is not a close match among the added patterns. For example, suppose that this object was created by adding "dd-MMM" and "hh:mm", and its datetimeFormat is the default "{0} {1}". Then if the input skeleton is "MMMdhmm", there is not an exact match, so the input skeleton is broken up into two components "MMMd" and "hmm". There are close matches for those two skeletons, so the result is put together with this pattern, resulting in "d-MMM h:mm".

Parameters
dtpga pointer to UDateTimePatternGenerator.
dtFormatmessage format pattern, here {0} will be replaced by the date pattern and {1} will be replaced by the time pattern.
lengththe length of dtFormat. ICU 3.8

◆ udatpg_setDecimal()

U_STABLE void U_EXPORT2 udatpg_setDecimal ( UDateTimePatternGenerator dtpg,
const UChar decimal,
int32_t  length 
)

The decimal value is used in formatting fractions of seconds. If the skeleton contains fractional seconds, then this is used with the fractional seconds. For example, suppose that the input pattern is "hhmmssSSSS", and the best matching pattern internally is "H:mm:ss", and the decimal string is ",". Then the resulting pattern is modified to be "H:mm:ss,SSSS"

Parameters
dtpga pointer to UDateTimePatternGenerator.
decimal
lengththe length of decimal. ICU 3.8