ICU 76.1 76.1
|
C API: Wrapper for icu::DateTimePatternGenerator (unicode/dtptngen.h). More...
#include "unicode/utypes.h"
#include "unicode/udat.h"
#include "unicode/uenum.h"
#include "unicode/localpointer.h"
Go to the source code of this file.
Namespaces | |
namespace | icu |
File coll.h. | |
Typedefs | |
typedef void * | UDateTimePatternGenerator |
Opaque type for a date/time pattern generator object. | |
typedef enum UDateTimePatternField | UDateTimePatternField |
Field number constants for udatpg_getAppendItemFormats() and similar functions. | |
typedef enum UDateTimePGDisplayWidth | UDateTimePGDisplayWidth |
Field display name width constants for udatpg_getFieldDisplayName(). | |
typedef enum UDateTimePatternMatchOptions | 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). | |
typedef enum UDateTimePatternConflict | UDateTimePatternConflict |
Status return values from udatpg_addPattern(). | |
Functions | |
U_CAPI UDateTimePatternGenerator * | udatpg_open (const char *locale, UErrorCode *pErrorCode) |
Open a generator according to a given locale. | |
U_CAPI UDateTimePatternGenerator * | udatpg_openEmpty (UErrorCode *pErrorCode) |
Open an empty generator, to be constructed with udatpg_addPattern(...) etc. | |
U_CAPI void | udatpg_close (UDateTimePatternGenerator *dtpg) |
Close a generator. | |
U_CAPI UDateTimePatternGenerator * | udatpg_clone (const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode) |
Create a copy pf a generator. | |
U_CAPI int32_t | 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. | |
U_CAPI int32_t | 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. | |
U_CAPI int32_t | udatpg_getSkeleton (UDateTimePatternGenerator *unusedDtpg, const UChar *pattern, int32_t length, UChar *skeleton, int32_t capacity, UErrorCode *pErrorCode) |
Get a unique skeleton from a given pattern. | |
U_CAPI int32_t | udatpg_getBaseSkeleton (UDateTimePatternGenerator *unusedDtpg, const UChar *pattern, int32_t length, UChar *baseSkeleton, int32_t capacity, UErrorCode *pErrorCode) |
Get a unique base skeleton from a given pattern. | |
U_CAPI UDateTimePatternConflict | 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. | |
U_CAPI void | 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. | |
U_CAPI const UChar * | udatpg_getAppendItemFormat (const UDateTimePatternGenerator *dtpg, UDateTimePatternField field, int32_t *pLength) |
Getter corresponding to setAppendItemFormat. | |
U_CAPI void | udatpg_setAppendItemName (UDateTimePatternGenerator *dtpg, UDateTimePatternField field, const UChar *value, int32_t length) |
Set the name of field, eg "era" in English for ERA. | |
U_CAPI const UChar * | udatpg_getAppendItemName (const UDateTimePatternGenerator *dtpg, UDateTimePatternField field, int32_t *pLength) |
Getter corresponding to setAppendItemNames. | |
U_CAPI int32_t | udatpg_getFieldDisplayName (const UDateTimePatternGenerator *dtpg, UDateTimePatternField field, UDateTimePGDisplayWidth width, UChar *fieldName, int32_t capacity, UErrorCode *pErrorCode) |
The general interface to get a display name for a particular date/time field, in one of several possible display widths. | |
U_CAPI void | udatpg_setDateTimeFormat (const UDateTimePatternGenerator *dtpg, const UChar *dtFormat, int32_t length) |
The DateTimeFormat is a message format pattern used to compose date and time patterns. | |
U_CAPI const UChar * | udatpg_getDateTimeFormat (const UDateTimePatternGenerator *dtpg, int32_t *pLength) |
Getter corresponding to setDateTimeFormat. | |
U_CAPI void | udatpg_setDateTimeFormatForStyle (UDateTimePatternGenerator *udtpg, UDateFormatStyle style, const UChar *dateTimeFormat, int32_t length, UErrorCode *pErrorCode) |
dateTimeFormats are message patterns used to compose combinations of date and time patterns. | |
U_CAPI const UChar * | udatpg_getDateTimeFormatForStyle (const UDateTimePatternGenerator *udtpg, UDateFormatStyle style, int32_t *pLength, UErrorCode *pErrorCode) |
Getter corresponding to udatpg_setDateTimeFormatForStyle. | |
U_CAPI void | udatpg_setDecimal (UDateTimePatternGenerator *dtpg, const UChar *decimal, int32_t length) |
The decimal value is used in formatting fractions of seconds. | |
U_CAPI const UChar * | udatpg_getDecimal (const UDateTimePatternGenerator *dtpg, int32_t *pLength) |
Getter corresponding to setDecimal. | |
U_CAPI int32_t | 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. | |
U_CAPI int32_t | 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. | |
U_CAPI UEnumeration * | udatpg_openSkeletons (const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode) |
Return a UEnumeration list of all the skeletons in canonical form. | |
U_CAPI UEnumeration * | udatpg_openBaseSkeletons (const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode) |
Return a UEnumeration list of all the base skeletons in canonical form. | |
U_CAPI const UChar * | udatpg_getPatternForSkeleton (const UDateTimePatternGenerator *dtpg, const UChar *skeleton, int32_t skeletonLength, int32_t *pLength) |
Get the pattern corresponding to a given skeleton. | |
U_CAPI UDateFormatHourCycle | udatpg_getDefaultHourCycle (const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode) |
Return the default hour cycle for a locale. | |
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.
Definition in file udatpg.h.
typedef enum UDateTimePatternConflict UDateTimePatternConflict |
Status return values from udatpg_addPattern().
typedef enum UDateTimePatternField 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.
typedef void* UDateTimePatternGenerator |
typedef enum UDateTimePatternMatchOptions 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.
typedef enum UDateTimePGDisplayWidth UDateTimePGDisplayWidth |
Field display name width constants for udatpg_getFieldDisplayName().
Status return values from udatpg_addPattern().
Enumerator | |
---|---|
UDATPG_NO_CONFLICT |
|
UDATPG_BASE_CONFLICT |
|
UDATPG_CONFLICT |
|
UDATPG_CONFLICT_COUNT | One more than the highest normal UDateTimePatternConflict value.
|
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.
Enumerator | |
---|---|
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 | One more than the highest normal UDateTimePatternField value.
|
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.
Enumerator | |
---|---|
UDATPG_MATCH_NO_OPTIONS |
|
UDATPG_MATCH_HOUR_FIELD_LENGTH |
|
UDATPG_MATCH_MINUTE_FIELD_LENGTH |
|
UDATPG_MATCH_SECOND_FIELD_LENGTH |
|
UDATPG_MATCH_ALL_FIELDS_LENGTH |
|
U_CAPI UDateTimePatternConflict 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 overridden. 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!
dtpg | a pointer to UDateTimePatternGenerator. |
pattern | input pattern, such as "dd/MMM" |
patternLength | the length of pattern. |
override | When existing values are to be overridden use true, otherwise use false. |
conflictingPattern | Previous pattern with the same skeleton. |
capacity | the capacity of conflictingPattern. |
pLength | a pointer to the length of conflictingPattern. |
pErrorCode | a pointer to the UErrorCode which must not indicate a failure before the function call. |
U_CAPI UDateTimePatternGenerator * udatpg_clone | ( | const UDateTimePatternGenerator * | dtpg, |
UErrorCode * | pErrorCode | ||
) |
Create a copy pf a generator.
dtpg | a pointer to UDateTimePatternGenerator to be copied. |
pErrorCode | a pointer to the UErrorCode which must not indicate a failure before the function call. |
U_CAPI void udatpg_close | ( | UDateTimePatternGenerator * | dtpg | ) |
U_CAPI const UChar * 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.
dtpg | A pointer to UDateTimePatternGenerator. |
field | UDateTimePatternField, such as UDATPG_ERA_FIELD |
pLength | A pointer that will receive the length of appendItemFormat. |
U_CAPI const UChar * 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. Note: The more general function for getting date/time field display names is udatpg_getFieldDisplayName.
dtpg | a pointer to UDateTimePatternGenerator. |
field | UDateTimePatternField, such as UDATPG_ERA_FIELD |
pLength | A pointer that will receive the length of the name for field. |
U_CAPI int32_t udatpg_getBaseSkeleton | ( | UDateTimePatternGenerator * | unusedDtpg, |
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.
unusedDtpg | a pointer to UDateTimePatternGenerator. This parameter is no longer used. Callers may pass NULL. |
pattern | input pattern, such as "dd/MMM". |
length | the length of pattern. |
baseSkeleton | such as "Md" |
capacity | the capacity of base skeleton. |
pErrorCode | a pointer to the UErrorCode which must not indicate a failure before the function call. |
U_CAPI int32_t 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.
dtpg | a pointer to UDateTimePatternGenerator. |
skeleton | The skeleton is a pattern containing only the variable fields. For example, "MMMdd" and "mmhh" are skeletons. |
length | the length of skeleton |
bestPattern | The best pattern found from the given skeleton. |
capacity | the capacity of bestPattern. |
pErrorCode | a pointer to the UErrorCode which must not indicate a failure before the function call. |
U_CAPI int32_t 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.
dtpg | a pointer to UDateTimePatternGenerator. |
skeleton | The skeleton is a pattern containing only the variable fields. For example, "MMMdd" and "mmhh" are skeletons. |
length | the length of skeleton |
options | Options 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. |
bestPattern | The best pattern found from the given skeleton. |
capacity | the capacity of bestPattern. |
pErrorCode | a pointer to the UErrorCode which must not indicate a failure before the function call. |
U_CAPI const UChar * udatpg_getDateTimeFormat | ( | const UDateTimePatternGenerator * | dtpg, |
int32_t * | pLength | ||
) |
Getter corresponding to setDateTimeFormat.
There are four DateTimeFormats in a UDateTimePatternGenerator object, corresponding to date styles UDAT_FULL..UDAT_SHORT. This method gets the style for UDAT_MEDIUM (the default). To get them individually, see udatpg_getDateTimeFormatForStyle.
dtpg | a pointer to UDateTimePatternGenerator. |
pLength | A pointer that will receive the length of the format |
U_CAPI const UChar * udatpg_getDateTimeFormatForStyle | ( | const UDateTimePatternGenerator * | udtpg, |
UDateFormatStyle | style, | ||
int32_t * | pLength, | ||
UErrorCode * | pErrorCode | ||
) |
Getter corresponding to udatpg_setDateTimeFormatForStyle.
udtpg | a pointer to the UDateTimePatternGenerator |
style | one of UDAT_FULL..UDAT_SHORT. Error if out of range. |
pLength | a pointer that will receive the length of the format. May be NULL if length is not desired. |
pErrorCode | a pointer to the UErrorCode (in/out parameter); if no failure status is already set, it will be set according to result of the function (e.g. U_ILLEGAL_ARGUMENT_ERROR for style out of range). |
U_CAPI const UChar * udatpg_getDecimal | ( | const UDateTimePatternGenerator * | dtpg, |
int32_t * | pLength | ||
) |
Getter corresponding to setDecimal.
dtpg | a pointer to UDateTimePatternGenerator. |
pLength | A pointer that will receive the length of the decimal string. |
U_CAPI UDateFormatHourCycle udatpg_getDefaultHourCycle | ( | const UDateTimePatternGenerator * | dtpg, |
UErrorCode * | pErrorCode | ||
) |
Return the default hour cycle for a locale.
Uses the locale that the UDateTimePatternGenerator was initially created with.
Cannot be used on an empty UDateTimePatternGenerator instance.
dtpg | a pointer to UDateTimePatternGenerator. |
pErrorCode | a pointer to the UErrorCode which must not indicate a failure before the function call. Set to U_UNSUPPORTED_ERROR if used on an empty instance. |
U_CAPI int32_t udatpg_getFieldDisplayName | ( | const UDateTimePatternGenerator * | dtpg, |
UDateTimePatternField | field, | ||
UDateTimePGDisplayWidth | width, | ||
UChar * | fieldName, | ||
int32_t | capacity, | ||
UErrorCode * | pErrorCode | ||
) |
The general interface to get a display name for a particular date/time field, in one of several possible display widths.
dtpg | A pointer to the UDateTimePatternGenerator object with the localized display names. |
field | The desired UDateTimePatternField, such as UDATPG_ERA_FIELD. |
width | The desired UDateTimePGDisplayWidth, such as UDATPG_ABBREVIATED. |
fieldName | A pointer to a buffer to receive the NULL-terminated display name. If the name fits into fieldName but cannot be NULL-terminated (length == capacity) then the error code is set to U_STRING_NOT_TERMINATED_WARNING. If the name doesn't fit into fieldName then the error code is set to U_BUFFER_OVERFLOW_ERROR. |
capacity | The size of fieldName (in UChars). |
pErrorCode | A pointer to a UErrorCode to receive any errors |
U_CAPI const UChar * udatpg_getPatternForSkeleton | ( | const UDateTimePatternGenerator * | dtpg, |
const UChar * | skeleton, | ||
int32_t | skeletonLength, | ||
int32_t * | pLength | ||
) |
Get the pattern corresponding to a given skeleton.
dtpg | a pointer to UDateTimePatternGenerator. |
skeleton | |
skeletonLength | pointer to the length of skeleton. |
pLength | pointer to the length of return pattern. |
U_CAPI int32_t udatpg_getSkeleton | ( | UDateTimePatternGenerator * | unusedDtpg, |
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.
unusedDtpg | a pointer to UDateTimePatternGenerator. This parameter is no longer used. Callers may pass NULL. |
pattern | input pattern, such as "dd/MMM". |
length | the length of pattern. |
skeleton | such as "MMMdd" |
capacity | the capacity of skeleton. |
pErrorCode | a pointer to the UErrorCode which must not indicate a failure before the function call. |
U_CAPI UDateTimePatternGenerator * udatpg_open | ( | const char * | locale, |
UErrorCode * | pErrorCode | ||
) |
Open a generator according to a given locale.
locale | |
pErrorCode | a pointer to the UErrorCode which must not indicate a failure before the function call. |
U_CAPI UEnumeration * udatpg_openBaseSkeletons | ( | const UDateTimePatternGenerator * | dtpg, |
UErrorCode * | pErrorCode | ||
) |
Return a UEnumeration list of all the base skeletons in canonical form.
dtpg | a pointer to UDateTimePatternGenerator. |
pErrorCode | a pointer to the UErrorCode which must not indicate a failure before the function call. |
U_CAPI UDateTimePatternGenerator * udatpg_openEmpty | ( | UErrorCode * | pErrorCode | ) |
Open an empty generator, to be constructed with udatpg_addPattern(...) etc.
pErrorCode | a pointer to the UErrorCode which must not indicate a failure before the function call. |
U_CAPI UEnumeration * 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.
dtpg | a pointer to UDateTimePatternGenerator. |
pErrorCode | a pointer to the UErrorCode which must not indicate a failure before the function call |
U_CAPI int32_t 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.
dtpg | a pointer to UDateTimePatternGenerator. |
pattern | Input pattern |
patternLength | the length of input pattern. |
skeleton | |
skeletonLength | the length of input skeleton. |
dest | pattern adjusted to match the skeleton fields widths and subtypes. |
destCapacity | the capacity of dest. |
pErrorCode | a pointer to the UErrorCode which must not indicate a failure before the function call. |
U_CAPI int32_t 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.
dtpg | a pointer to UDateTimePatternGenerator. |
pattern | Input pattern |
patternLength | the length of input pattern. |
skeleton | |
skeletonLength | the length of input skeleton. |
options | Options 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. |
dest | pattern adjusted to match the skeleton fields widths and subtypes. |
destCapacity | the capacity of dest. |
pErrorCode | a pointer to the UErrorCode which must not indicate a failure before the function call. |
U_CAPI void 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.
dtpg | a pointer to UDateTimePatternGenerator. |
field | UDateTimePatternField, such as UDATPG_ERA_FIELD |
value | pattern, such as "{0}, {1}" |
length | the length of value. |
U_CAPI void 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.
dtpg | a pointer to UDateTimePatternGenerator. |
field | UDateTimePatternField |
value | name for the field. |
length | the length of value. |
U_CAPI void udatpg_setDateTimeFormat | ( | const UDateTimePatternGenerator * | dtpg, |
const UChar * | dtFormat, | ||
int32_t | length | ||
) |
The DateTimeFormat is a message format pattern used to compose date and time patterns.
The default pattern in the root locale is "{1} {0}", where {1} will be replaced by the date pattern and {0} will be replaced by the time pattern; however, other locales may specify patterns such as "{1}, {0}" or "{1} 'at' {0}", etc.
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 "{1} {0}". 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".
There are four DateTimeFormats in a UDateTimePatternGenerator object, corresponding to date styles UDAT_FULL..UDAT_SHORT. This method sets all of them to the specified pattern. To set them individually, see udatpg_setDateTimeFormatForStyle.
dtpg | a pointer to UDateTimePatternGenerator. |
dtFormat | message format pattern, here {1} will be replaced by the date pattern and {0} will be replaced by the time pattern. |
length | the length of dtFormat. |
U_CAPI void udatpg_setDateTimeFormatForStyle | ( | UDateTimePatternGenerator * | udtpg, |
UDateFormatStyle | style, | ||
const UChar * | dateTimeFormat, | ||
int32_t | length, | ||
UErrorCode * | pErrorCode | ||
) |
dateTimeFormats are message patterns used to compose combinations of date and time patterns.
There are four length styles, corresponding to the inferred style of the date pattern; these are UDateFormatStyle values:
udtpg | a pointer to the UDateTimePatternGenerator |
style | one of UDAT_FULL..UDAT_SHORT. Error if out of range. |
dateTimeFormat | the new dateTimeFormat to set for the the specified style |
length | the length of dateTimeFormat, or -1 if unknown and pattern is null-terminated |
pErrorCode | a pointer to the UErrorCode (in/out parameter); if no failure status is already set, it will be set according to result of the function (e.g. U_ILLEGAL_ARGUMENT_ERROR for style out of range). |
U_CAPI void 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"
dtpg | a pointer to UDateTimePatternGenerator. |
decimal | |
length | the length of decimal. |