Tizen Native API
7.0
|
The Udate module consists of functions that convert dates and time from their internal representations to textual form and back again in a language-independent manner.
Required Header
#include <utils_i18n.h>
Overview
The Udate module consists of functions that convert dates and time from their internal representations to textual form and back again in a language-independent manner. Converting from the internal representation (milliseconds since midnight, January 1, 1970) to text is known as "formatting," and converting from text to milliseconds is known as "parsing". We currently define only one concrete handle i18n_udate_format_h, which can handle pretty much all normal date formatting and parsing actions.
The Udate module helps you format and parse dates for any locale. Your code can be completely independent of the locale conventions for months, days of the week, or even the calendar format: lunar vs. solar.
Sample Code 1
Gets the best pattern according to a given locale and formats a current date and time using a locale_udate_format_h
i18n_udatepg_h pattern_generator = NULL; char *locale = I18N_ULOCALE_US; dlog_print(DLOG_INFO, LOG_TAG, "pattern_generator\n"); if(!pattern_generator) { // create a pattern generator according to a given locale i18n_udatepg_create(locale, &pattern_generator); } if(!pattern_generator) { dlog_print(DLOG_INFO, LOG_TAG, "i18n_udatepg_create fail"); return ; } i18n_uchar bestPattern[64] = {0,}; char bestPatternString[64] = {0,}; int bestPatternLength, len; const char *custom_format = "yyyy.MM.dd G 'at' HH:mm:ss zzz"; i18n_uchar uch_custom_format[64]; int ret = I18N_ERROR_NONE; dlog_print(DLOG_INFO, LOG_TAG, "getBestPattern\n"); i18n_ustring_copy_ua(uch_custom_format, custom_format); len = i18n_ustring_get_length(uch_custom_format); // gets the best pattern that matches the given custom_format i18n_udatepg_get_best_pattern(pattern_generator, uch_custom_format, len, bestPattern, 64, &bestPatternLength); i18n_ustring_copy_au_n(bestPatternString, bestPattern, 64); // gets "MM/dd/yyyy G h:mm:ss a zzz" as the best pattern dlog_print(DLOG_INFO, LOG_TAG, "getBestPattern(char[]) : %s \n", bestPatternString); // closes a generator i18n_udatepg_destroy(pattern_generator); i18n_udate_format_h formatter_KR = NULL; i18n_udate_format_h formatter_LA = NULL; i18n_udate_format_h formatter_SaoPaulo = NULL; i18n_uchar formatted[64] = {0,}; char result[64] = {0,}; int formattedLength; i18n_udate date; const char *timezone_KR = "GMT+9:00"; // TimeZone for Korea/Seoul const char *timezone_LA = "America/Los_Angeles"; const char *timezone_SaoPaulo = "America/Sao_Paulo"; // Brazil/East i18n_uchar utf16_timezone_KR[64] = {0,}; i18n_uchar utf16_timezone_LA[64] = {0,}; i18n_uchar utf16_timezone_SaoPaulo[64] = {0,}; i18n_ustring_copy_ua_n(utf16_timezone_KR, timezone_KR, strlen(timezone_KR)); i18n_ustring_copy_ua_n(utf16_timezone_LA, timezone_LA, strlen(timezone_LA)); i18n_ustring_copy_ua_n(utf16_timezone_SaoPaulo, timezone_SaoPaulo, strlen(timezone_SaoPaulo)); // creates new i18n_udate_format_h to format dates and times ret = i18n_udate_create(I18N_UDATE_FULL , I18N_UDATE_FULL , locale, utf16_timezone_KR, -1, bestPattern, -1, &formatter_KR); if (ret != I18N_ERROR_NONE) { dlog_print(DLOG_INFO, LOG_TAG, "i18n_udate_create failed !!! \n"); } if (!formatter_KR) { dlog_print(DLOG_INFO, LOG_TAG, "formatter is NULL\n"); } ret = i18n_udate_create(I18N_UDATE_FULL , I18N_UDATE_FULL , locale, utf16_timezone_LA, -1, bestPattern, -1, &formatter_LA); if (ret != I18N_ERROR_NONE) { dlog_print(DLOG_INFO, LOG_TAG, "i18n_udate_create failed !!! \n"); } if (!formatter_LA) { dlog_print(DLOG_INFO, LOG_TAG, "formatter is NULL\n"); } ret = i18n_udate_create(I18N_UDATE_PATTERN , I18N_UDATE_PATTERN , locale, utf16_timezone_SaoPaulo, -1, bestPattern, -1, &formatter_SaoPaulo); if (ret != I18N_ERROR_NONE) { dlog_print(DLOG_INFO, LOG_TAG, "i18n_udate_create failed !!! \n"); } if (!formatter_SaoPaulo) { dlog_print(DLOG_INFO, LOG_TAG, "formatter is NULL\n"); } dlog_print(DLOG_INFO, LOG_TAG, "i18n_udate_format_date\n"); // gets the current date and time i18n_ucalendar_get_now(&date); // formats a date using i18n_udate_format_h i18n_udate_format_date(formatter_KR, date, formatted, 64, NULL, &formattedLength); i18n_ustring_copy_au_n(result, formatted, 64); //ex) KOREA/Seoul - Current date : Wednesday, June 18, 2014 1:34:54 PM GMT+09:00 dlog_print(DLOG_INFO, LOG_TAG, "KOREA/Seoul - Current date : %s\n",result); // formats a date using i18n_udate_format i18n_udate_format_date(formatter_LA, date, formatted, 64, NULL, &formattedLength); i18n_ustring_copy_au_n(result, formatted, 64); //ex) America/LOS Angeles - Current date : Tuesday, June 17, 2014 9:34:54 PM Pacific Daylight Time dlog_print(DLOG_INFO, LOG_TAG, "America/LOS Angeles - Current date : %s\n",result); // formats a date using i18n_udate_format_h i18n_udate_format_date(formatter_SaoPaulo, date, formatted, 64, NULL, &formattedLength); i18n_ustring_copy_au_n(result, formatted, 64); //ex) Brazil/Sao Paulo - Current date : 6 18, 2014 AD, 1:34:54 PM GMT-2 dlog_print(DLOG_INFO, LOG_TAG, "Brazil/Sao Paulo - Current date : %s\n",result); dlog_print(DLOG_INFO, LOG_TAG, "i18n_udate_destroy\n"); // destroy an i18n_udate_format_h i18n_udate_destroy(formatter_KR); i18n_udate_destroy(formatter_LA); i18n_udate_destroy(formatter_SaoPaulo);
Functions | |
int | i18n_udate_create (i18n_udate_format_style_e time_style, i18n_udate_format_style_e date_style, const char *locale, const i18n_uchar *tz_id, int32_t tz_id_len, const i18n_uchar *pattern, int pattern_len, i18n_udate_format_h *format) |
Creates a new i18n_udate_format_h for formatting and parsing dates and times. | |
int | i18n_udate_destroy (i18n_udate_format_h format) |
Destroys an i18n_udate_format_h. | |
int | i18n_udate_format_date (const i18n_udate_format_h format, i18n_udate date_to_format, i18n_uchar *result, int32_t result_len, i18n_ufield_position_h pos, int32_t *buf_size_needed) |
Formats a date using an i18n_udate_format_h. | |
int | i18n_udate_to_calendar_date_field (i18n_udate_format_field_e field, i18n_ucalendar_date_fields_e *date_field_type) |
Maps from an i18n_udate_format_h to the corresponding i18n_ucalendar_date_fields_e. | |
int | i18n_udate_clone (const i18n_udate_format_h format, i18n_udate_format_h *format_clone) |
Creates a copy of an i18n_udate_format_h. | |
int | i18n_udate_parse (const i18n_udate_format_h format, const i18n_uchar *text, int32_t text_length, int32_t *parse_pos, i18n_udate *parsed_date) |
Parses a string into an date/time using an i18n_udate_format_h. | |
int | i18n_udate_parse_calendar (const i18n_udate_format_h format, i18n_ucalendar_h *calendar, const i18n_uchar *text, int32_t text_length, int32_t *parse_pos) |
Parses a string into an date/time using an i18n_udate_format_h. | |
i18n_ubool | i18n_udate_is_lenient (const i18n_udate_format_h format) |
Determines if an i18n_udate_format_h will perform lenient parsing. | |
int | i18n_udate_set_lenient (i18n_udate_format_h format, i18n_ubool is_lenient) |
Specifies whether an i18n_udate_format_h will perform lenient parsing. | |
int | i18n_udate_get_calendar (const i18n_udate_format_h format, i18n_ucalendar_h *calendar) |
Gets the i18n_ucalendar_h associated with an i18n_udate_format_h. | |
int | i18n_udate_set_calendar (i18n_udate_format_h format, const i18n_ucalendar_h calendar_to_set) |
Sets the i18n_ucalendar_h associated with an i18n_udate_format_h. | |
int | i18n_udate_get_number_format (const i18n_udate_format_h format, i18n_unumber_format_h *number_format) |
Gets the i18n_unumber_format_h associated with an i18n_udate_format_h. | |
int | i18n_udate_set_number_format (i18n_udate_format_h format, const i18n_unumber_format_h number_format_to_set) |
Sets the i18n_unumber_format_h associated with an i18n_udate_format_h. | |
const char * | i18n_udate_get_available (int32_t locale_index) |
Gets a locale for which date/time formatting patterns are available. | |
int32_t | i18n_udate_count_available (void) |
Determines how many locales have date/time formatting patterns available. | |
int | i18n_udate_get_2digit_year_start (const i18n_udate_format_h format, i18n_udate *year) |
Gets the year relative to which all 2-digit years are interpreted. | |
int | i18n_udate_set_2digit_year_start (i18n_udate_format_h format, i18n_udate date) |
Sets the year relative to which all 2-digit years will be interpreted. | |
int32_t | i18n_udate_to_pattern (const i18n_udate_format_h format, i18n_ubool localized, i18n_uchar *result, int32_t result_length) |
Extracts the pattern from an i18n_udate_format_h. | |
int | i18n_udate_apply_pattern (i18n_udate_format_h format, i18n_ubool localized, const i18n_uchar *pattern, int32_t pattern_length) |
Sets the pattern used by an i18n_udate_format_h. | |
int32_t | i18n_udate_get_symbols (const i18n_udate_format_h format, i18n_udate_format_symbol_type_e type, int32_t symbol_index, i18n_uchar *result, int32_t result_length) |
Gets the symbols associated with an i18n_udate_format_h. | |
int32_t | i18n_udate_count_symbols (const i18n_udate_format_h format, i18n_udate_format_symbol_type_e type) |
Counts the number of particular symbols for an i18n_udate_format_h. | |
int | i18n_udate_set_symbols (i18n_udate_format_h format, i18n_udate_format_symbol_type_e type, int32_t symbol_index, i18n_uchar *value, int32_t value_length) |
Sets the symbols associated with an i18n_udate_format_h. | |
const char * | i18n_udate_get_locale_by_type (const i18n_udate_format_h format, i18n_ulocale_data_locale_type_e type) |
Gets the locale for this date format object. | |
int | i18n_udate_set_context (i18n_udate_format_h format, i18n_udisplay_context_e value) |
Sets a particular i18n_udisplay_context_e value in the formatter, such as I18N_UDISPLAY_CONTEXT_CAPITALIZATION_FOR_STANDALONE. | |
Typedefs | |
typedef double | i18n_udate |
Date and Time data type. This is a primitive data type that holds the date and time as the number of milliseconds since 1970-jan-01, 00:00 UTC. UTC leap seconds are ignored. | |
typedef void * | i18n_udate_format_h |
A date formatter. | |
typedef i18n_ufield_position_s * | i18n_ufield_position_h |
Handle to struct representing a range of text containing a specific field. | |
Defines | |
#define | I18N_UDATE_YEAR "y" |
Constant for date skeleton with year. | |
#define | I18N_UDATE_QUARTER "QQQQ" |
Constant for date skeleton with quarter. | |
#define | I18N_UDATE_ABBR_QUARTER "QQQ" |
Constant for date skeleton with abbreviated quarter. | |
#define | I18N_UDATE_YEAR_QUARTER "yQQQQ" |
Constant for date skeleton with year and quarter. | |
#define | I18N_UDATE_YEAR_ABBR_QUARTER "yQQQ" |
Constant for date skeleton with year and abbreviated quarter. | |
#define | I18N_UDATE_MONTH "MMMM" |
Constant for date skeleton with month. | |
#define | I18N_UDATE_ABBR_MONTH "MMM" |
Constant for date skeleton with abbreviated month. | |
#define | I18N_UDATE_NUM_MONTH "M" |
Constant for date skeleton with numeric month. | |
#define | I18N_UDATE_YEAR_MONTH "yMMMM" |
Constant for date skeleton with year and month. | |
#define | I18N_UDATE_YEAR_ABBR_MONTH "yMMM" |
Constant for date skeleton with year and abbreviated month. | |
#define | I18N_UDATE_YEAR_NUM_MONTH "yM" |
Constant for date skeleton with year and numeric month. | |
#define | I18N_UDATE_DAY "d" |
Constant for date skeleton with day. | |
#define | I18N_UDATE_YEAR_MONTH_DAY "yMMMMd" |
Constant for date skeleton with year, month, and day. | |
#define | I18N_UDATE_YEAR_ABBR_MONTH_DAY "yMMMd" |
Constant for date skeleton with year, abbreviated month, and day. | |
#define | I18N_UDATE_YEAR_NUM_MONTH_DAY "yMd" |
Constant for date skeleton with year, numeric month, and day. | |
#define | I18N_UDATE_WEEKDAY "EEEE" |
Constant for date skeleton with weekday. | |
#define | I18N_UDATE_ABBR_WEEKDAY "E" |
Constant for date skeleton with abbreviated weekday. | |
#define | I18N_UDATE_YEAR_MONTH_WEEKDAY_DAY "yMMMMEEEEd" |
Constant for date skeleton with year, month, weekday, and day. | |
#define | I18N_UDATE_YEAR_ABBR_MONTH_WEEKDAY_DAY "yMMMEd" |
Constant for date skeleton with year, abbreviated month, weekday, and day. | |
#define | I18N_UDATE_YEAR_NUM_MONTH_WEEKDAY_DAY "yMEd" |
Constant for date skeleton with year, numeric month, weekday, and day. | |
#define | I18N_UDATE_MONTH_DAY "MMMMd" |
Constant for date skeleton with long month and day. | |
#define | I18N_UDATE_ABBR_MONTH_DAY "MMMd" |
Constant for date skeleton with abbreviated month and day. | |
#define | I18N_UDATE_NUM_MONTH_DAY "Md" |
Constant for date skeleton with numeric month and day. | |
#define | I18N_UDATE_MONTH_WEEKDAY_DAY "MMMMEEEEd" |
Constant for date skeleton with month, weekday, and day. | |
#define | I18N_UDATE_ABBR_MONTH_WEEKDAY_DAY "MMMEd" |
Constant for date skeleton with abbreviated month, weekday, and day. | |
#define | I18N_UDATE_NUM_MONTH_WEEKDAY_DAY "MEd" |
Constant for date skeleton with numeric month, weekday, and day. | |
#define | I18N_UDATE_HOUR "j" |
Constant for date skeleton with hour, with the locale's preferred hour format (12 or 24). | |
#define | I18N_UDATE_HOUR24 "H" |
Constant for date skeleton with hour in 24-hour presentation. | |
#define | I18N_UDATE_MINUTE "m" |
Constant for date skeleton with minute. | |
#define | I18N_UDATE_HOUR_MINUTE "jm" |
Constant for date skeleton with hour and minute, with the locale's preferred hour format (12 or 24). | |
#define | I18N_UDATE_HOUR24_MINUTE "Hm" |
Constant for date skeleton with hour and minute in 24-hour presentation. | |
#define | I18N_UDATE_SECOND "s" |
Constant for date skeleton with second. | |
#define | I18N_UDATE_HOUR_MINUTE_SECOND "jms" |
Constant for date skeleton with hour, minute, and second, with the locale's preferred hour format (12 or 24). | |
#define | I18N_UDATE_HOUR24_MINUTE_SECOND "Hms" |
Constant for date skeleton with hour, minute, and second in 24-hour presentation. | |
#define | I18N_UDATE_MINUTE_SECOND "ms" |
Constant for date skeleton with minute and second. |
Define Documentation
#define I18N_UDATE_ABBR_MONTH "MMM" |
Constant for date skeleton with abbreviated month.
- Since :
- 3.0
- See also:
- i18n_udatepg_get_best_pattern()
#define I18N_UDATE_ABBR_MONTH_DAY "MMMd" |
Constant for date skeleton with abbreviated month and day.
Used in combinations date + time, date + time + zone, or time + zone.
- Since :
- 3.0
- See also:
- i18n_udatepg_get_best_pattern()
#define I18N_UDATE_ABBR_MONTH_WEEKDAY_DAY "MMMEd" |
Constant for date skeleton with abbreviated month, weekday, and day.
Used in combinations date + time, date + time + zone, or time + zone.
- Since :
- 3.0
- See also:
- i18n_udatepg_get_best_pattern()
#define I18N_UDATE_ABBR_QUARTER "QQQ" |
Constant for date skeleton with abbreviated quarter.
- Since :
- 3.0
- See also:
- i18n_udatepg_get_best_pattern()
#define I18N_UDATE_ABBR_WEEKDAY "E" |
Constant for date skeleton with abbreviated weekday.
- Since :
- 3.0
- See also:
- i18n_udatepg_get_best_pattern()
#define I18N_UDATE_DAY "d" |
#define I18N_UDATE_HOUR "j" |
Constant for date skeleton with hour, with the locale's preferred hour format (12 or 24).
- Since :
- 3.0
- See also:
- i18n_udatepg_get_best_pattern()
#define I18N_UDATE_HOUR24 "H" |
Constant for date skeleton with hour in 24-hour presentation.
- Since :
- 3.0
- See also:
- i18n_udatepg_get_best_pattern()
#define I18N_UDATE_HOUR24_MINUTE "Hm" |
Constant for date skeleton with hour and minute in 24-hour presentation.
Used in combinations date + time, date + time + zone, or time + zone.
- Since :
- 3.0
- See also:
- i18n_udatepg_get_best_pattern()
#define I18N_UDATE_HOUR24_MINUTE_SECOND "Hms" |
Constant for date skeleton with hour, minute, and second in 24-hour presentation.
Used in combinations date + time, date + time + zone, or time + zone.
- Since :
- 3.0
- See also:
- i18n_udatepg_get_best_pattern()
#define I18N_UDATE_HOUR_MINUTE "jm" |
Constant for date skeleton with hour and minute, with the locale's preferred hour format (12 or 24).
Used in combinations date + time, date + time + zone, or time + zone.
- Since :
- 3.0
- See also:
- i18n_udatepg_get_best_pattern()
#define I18N_UDATE_HOUR_MINUTE_SECOND "jms" |
Constant for date skeleton with hour, minute, and second, with the locale's preferred hour format (12 or 24).
Used in combinations date + time, date + time + zone, or time + zone.
- Since :
- 3.0
- See also:
- i18n_udatepg_get_best_pattern()
#define I18N_UDATE_MINUTE "m" |
#define I18N_UDATE_MINUTE_SECOND "ms" |
Constant for date skeleton with minute and second.
Used in combinations date + time, date + time + zone, or time + zone.
- Since :
- 3.0
- See also:
- i18n_udatepg_get_best_pattern()
#define I18N_UDATE_MONTH "MMMM" |
#define I18N_UDATE_MONTH_DAY "MMMMd" |
Constant for date skeleton with long month and day.
Used in combinations date + time, date + time + zone, or time + zone.
- Since :
- 3.0
- See also:
- i18n_udatepg_get_best_pattern()
#define I18N_UDATE_MONTH_WEEKDAY_DAY "MMMMEEEEd" |
Constant for date skeleton with month, weekday, and day.
Used in combinations date + time, date + time + zone, or time + zone.
- Since :
- 3.0
- See also:
- i18n_udatepg_get_best_pattern()
#define I18N_UDATE_NUM_MONTH "M" |
#define I18N_UDATE_NUM_MONTH_DAY "Md" |
Constant for date skeleton with numeric month and day.
Used in combinations date + time, date + time + zone, or time + zone.
- Since :
- 3.0
- See also:
- i18n_udatepg_get_best_pattern()
#define I18N_UDATE_NUM_MONTH_WEEKDAY_DAY "MEd" |
Constant for date skeleton with numeric month, weekday, and day.
Used in combinations date + time, date + time + zone, or time + zone.
- Since :
- 3.0
- See also:
- i18n_udatepg_get_best_pattern()
#define I18N_UDATE_QUARTER "QQQQ" |
#define I18N_UDATE_SECOND "s" |
#define I18N_UDATE_WEEKDAY "EEEE" |
#define I18N_UDATE_YEAR "y" |
#define I18N_UDATE_YEAR_ABBR_MONTH "yMMM" |
Constant for date skeleton with year and abbreviated month.
- Since :
- 3.0
- See also:
- i18n_udatepg_get_best_pattern()
#define I18N_UDATE_YEAR_ABBR_MONTH_DAY "yMMMd" |
Constant for date skeleton with year, abbreviated month, and day.
Used in combinations date + time, date + time + zone, or time + zone.
- Since :
- 3.0
- See also:
- i18n_udatepg_get_best_pattern()
#define I18N_UDATE_YEAR_ABBR_MONTH_WEEKDAY_DAY "yMMMEd" |
Constant for date skeleton with year, abbreviated month, weekday, and day.
Used in combinations date + time, date + time + zone, or time + zone.
- Since :
- 3.0
- See also:
- i18n_udatepg_get_best_pattern()
#define I18N_UDATE_YEAR_ABBR_QUARTER "yQQQ" |
Constant for date skeleton with year and abbreviated quarter.
- Since :
- 3.0
- See also:
- i18n_udatepg_get_best_pattern()
#define I18N_UDATE_YEAR_MONTH "yMMMM" |
#define I18N_UDATE_YEAR_MONTH_DAY "yMMMMd" |
Constant for date skeleton with year, month, and day.
Used in combinations date + time, date + time + zone, or time + zone.
- Since :
- 3.0
- See also:
- i18n_udatepg_get_best_pattern()
#define I18N_UDATE_YEAR_MONTH_WEEKDAY_DAY "yMMMMEEEEd" |
Constant for date skeleton with year, month, weekday, and day.
Used in combinations date + time, date + time + zone, or time + zone.
- Since :
- 3.0
- See also:
- i18n_udatepg_get_best_pattern()
#define I18N_UDATE_YEAR_NUM_MONTH "yM" |
Constant for date skeleton with year and numeric month.
- Since :
- 3.0
- See also:
- i18n_udatepg_get_best_pattern()
#define I18N_UDATE_YEAR_NUM_MONTH_DAY "yMd" |
Constant for date skeleton with year, numeric month, and day.
Used in combinations date + time, date + time + zone, or time + zone.
- Since :
- 3.0
- See also:
- i18n_udatepg_get_best_pattern()
#define I18N_UDATE_YEAR_NUM_MONTH_WEEKDAY_DAY "yMEd" |
Constant for date skeleton with year, numeric month, weekday, and day.
Used in combinations date + time, date + time + zone, or time + zone.
- Since :
- 3.0
- See also:
- i18n_udatepg_get_best_pattern()
#define I18N_UDATE_YEAR_QUARTER "yQQQQ" |
Constant for date skeleton with year and quarter.
- Since :
- 3.0
- See also:
- i18n_udatepg_get_best_pattern()
Typedef Documentation
typedef double i18n_udate |
Date and Time data type.
This is a primitive data type that holds the date and time as the number of milliseconds since 1970-jan-01, 00:00 UTC. UTC leap seconds are ignored.
Date and Time data type.
This is a primitive data type that holds the date and time as the number of milliseconds since 1970-jan-01, 00:00 UTC. UTC leap seconds are ignored.
- Since :
- 2.3
typedef void* i18n_udate_format_h |
A date formatter.
- Since :
- 2.3
Handle to struct representing a range of text containing a specific field.
- Since :
- 2.3
Enumeration Type Documentation
Enumeration for format fields.
- Since :
- 2.3.1
- Enumerator:
Enumeration for the possible date/time format styles.
- Since :
- 2.3
- Enumerator:
I18N_UDATE_FULL Full style
I18N_UDATE_LONG Long style
I18N_UDATE_MEDIUM Medium style
I18N_UDATE_SHORT Short style
I18N_UDATE_DEFAULT Default style
I18N_UDATE_RELATIVE Bitfield for relative date
I18N_UDATE_FULL_RELATIVE I18N_UDATE_LONG_RELATIVE I18N_UDATE_MEDIUM_RELATIVE I18N_UDATE_SHORT_RELATIVE I18N_UDATE_NONE No style
I18N_UDATE_PATTERN Use the pattern given in the parameter to i18n_udate_create().
Enumeration for symbol types.
- Since :
- 2.3.1
- Enumerator:
Enumeration for display context.
- Since :
- 2.3.1
- Enumerator:
Display context types, for getting values of a particular setting.
Note, the specific numeric values are internal and may change.
- Since :
- 2.3.1
- Enumerator:
Function Documentation
int i18n_udate_apply_pattern | ( | i18n_udate_format_h | format, |
i18n_ubool | localized, | ||
const i18n_uchar * | pattern, | ||
int32_t | pattern_length | ||
) |
Sets the pattern used by an i18n_udate_format_h.
The pattern should follow the pattern syntax rules.
- Since :
- 2.3.1
- Parameters:
-
[in] format The i18n_udate_format_h to set. [in] localized true if the pattern is localized, false otherwise. [in] pattern The new pattern. [in] pattern_length The length of pattern, or -1 if NULL-terminated.
- Returns:
- Error code.
- Return values:
-
I18N_ERROR_NONE Successful I18N_ERROR_INVALID_PARAMETER Invalid function parameter
- See also:
- i18n_udate_to_pattern()
int i18n_udate_clone | ( | const i18n_udate_format_h | format, |
i18n_udate_format_h * | format_clone | ||
) |
Creates a copy of an i18n_udate_format_h.
This function performs a deep copy.
- Since :
- 2.3.1
- Parameters:
-
[in] format The format to copy. [out] format_clone A pointer to clone of format
.
- Returns:
- Error code. Error codes not listed below are described in i18n_error_code_e
- Return values:
-
I18N_ERROR_NONE Successful I18N_ERROR_INVALID_PARAMETER Invalid function parameter
int32_t i18n_udate_count_available | ( | void | ) |
Determines how many locales have date/time formatting patterns available.
This function is the most useful for determining the loop ending condition for calls to i18n_udate_get_available().
- Remarks:
- The specific error code can be obtained using the get_last_result() method. Error codes are described in Exceptions section.
- Since :
- 2.3.1
- Returns:
- The number of locales for which date/time formatting patterns are available.
- Exceptions:
-
I18N_ERROR_NONE Successful
- See also:
- i18n_udate_get_available()
int32_t i18n_udate_count_symbols | ( | const i18n_udate_format_h | format, |
i18n_udate_format_symbol_type_e | type | ||
) |
Counts the number of particular symbols for an i18n_udate_format_h.
This function is most useful for determining the loop termination condition for calls to i18n_udate_get_symbols().
- Remarks:
- The specific error code can be obtained using the get_last_result() method. Error codes are described in Exceptions section.
- Since :
- 2.3.1
- Parameters:
-
[in] format The i18n_udate_format_h to query. [in] type The type of symbols to count. If wrong type is passed, 0 will be returned.
- Returns:
- The number of symbols of type type.
- Exceptions:
-
I18N_ERROR_NONE Successful I18N_ERROR_INVALID_PARAMETER Invalid function parameter
int i18n_udate_create | ( | i18n_udate_format_style_e | time_style, |
i18n_udate_format_style_e | date_style, | ||
const char * | locale, | ||
const i18n_uchar * | tz_id, | ||
int32_t | tz_id_len, | ||
const i18n_uchar * | pattern, | ||
int | pattern_len, | ||
i18n_udate_format_h * | format | ||
) |
Creates a new i18n_udate_format_h for formatting and parsing dates and times.
A i18n_udate_format_h may be used to format dates in calls to i18n_udate_create().
- Since :
- 2.3
- Remarks:
- Must release format using i18n_udate_destroy().
If pattern parameter is used, pass in I18N_UDATE_PATTERN for time_style and date_style.
I18N_UDATE_PATTERN can only be used in this case, and has to be set for both time_style and date_style.
- Parameters:
-
[in] time_style The style used to format times
One of I18N_UDATE_FULL, I18N_UDATE_LONG, I18N_UDATE_MEDIUM, I18N_UDATE_SHORT, I18N_UDATE_DEFAULT, I18N_UDATE_PATTERN (see remarks) or I18N_UDATE_NONE (relative time styles are not currently supported).[in] date_style The style used to format dates
One of I18N_UDATE_FULL, I18N_UDATE_LONG, I18N_UDATE_MEDIUM, I18N_UDATE_SHORT, I18N_UDATE_DEFAULT, I18N_UDATE_RELATIVE, I18N_UDATE_LONG_RELATIVE, I18N_UDATE_MEDIUM_RELATIVE, I18N_UDATE_SHORT_RELATIVE, I18N_UDATE_PATTERN (see remarks) or I18N_UDATE_NONE[in] locale The locale specifying the formatting conventions. [in] tz_id A timezone ID specifying the timezone to use
If0
, use the default timezone.[in] tz_id_len The length of tz_id, otherwise -1
if NULL-terminated.[in] pattern A pattern specifying the format to use. The pattern is generated by Udatepg module.
When the pattern parameter is used, pass in I18N_UDATE_PATTERN for both time_style and date_style.
See remarks for additional conditions.[in] pattern_len The number of characters in the pattern, or otherwise -1
if NULL-terminated.[out] format A pointer to an i18n_udate_format_h to use for formatting dates and times, otherwise 0
if an error occurs.
- Returns:
- Error code. Error codes not listed below are described in i18n_error_code_e
- Return values:
-
I18N_ERROR_NONE Successful I18N_ERROR_INVALID_PARAMETER Invalid function parameter
int i18n_udate_destroy | ( | i18n_udate_format_h | format | ) |
Destroys an i18n_udate_format_h.
Once destroyed, an i18n_udate_format_h may no longer be used.
- Since :
- 2.3
- Parameters:
-
[in] format The formatter to destroy.
- Return values:
-
I18N_ERROR_NONE Successful I18N_ERROR_INVALID_PARAMETER Invalid function parameter
int i18n_udate_format_date | ( | const i18n_udate_format_h | format, |
i18n_udate | date_to_format, | ||
i18n_uchar * | result, | ||
int32_t | result_len, | ||
i18n_ufield_position_h | pos, | ||
int32_t * | buf_size_needed | ||
) |
Formats a date using an i18n_udate_format_h.
The date will be formatted using the conventions specified in i18n_udate_create()
- Since :
- 2.3
- Parameters:
-
[in] format The formatter to use. [in] date_to_format The date to format. [out] result A pointer to a buffer to receive the formatted number. [in] result_len The maximum size of the result. [in] pos A pointer to an i18n_ufield_position
On input, position->field is read
On output, position->beginIndex and position->endIndex indicate the beginning and ending indices of field number position->field, if such a field exists
This parameter may beNULL
, in which case no field position data is returned.[out] buf_size_needed The total buffer size needed
If greater than result_len, the output was truncated.
- Returns:
- Error code. Error codes not listed below are described in i18n_error_code_e
- Return values:
-
I18N_ERROR_NONE Successful I18N_ERROR_INVALID_PARAMETER Invalid function parameter
int i18n_udate_get_2digit_year_start | ( | const i18n_udate_format_h | format, |
i18n_udate * | year | ||
) |
Gets the year relative to which all 2-digit years are interpreted.
For example, if the 2-digit start year is 2100, the year 99 will be interpreted as 2199.
- Since :
- 2.3.1
- Parameters:
-
[in] format The i18n_udate_format_h to get. [out] year A pointer to the year relative to which all 2-digit years are interpreted.
- Returns:
- Error code. Error codes not listed below are described in i18n_error_code_e
- Return values:
-
I18N_ERROR_NONE Successful I18N_ERROR_INVALID_PARAMETER Invalid function parameter
- See also:
- i18n_udate_set_2digit_year_start()
const char* i18n_udate_get_available | ( | int32_t | locale_index | ) |
Gets a locale for which date/time formatting patterns are available.
An i18n_udate_format_h in a locale returned by this function will perform the correct formatting and parsing for the locale.
- Remarks:
- The specific error code can be obtained using the get_last_result() method. Error codes are described in Exceptions section.
- Since :
- 2.3.1
- Parameters:
-
[in] locale_index The index of the desired locale.
- Returns:
- A locale for which date/time formatting patterns are available, or 0 if none.
- Exceptions:
-
I18N_ERROR_NONE Successful I18N_ERROR_INVALID_PARAMETER Invalid function parameter
- See also:
- i18n_udate_count_available()
int i18n_udate_get_calendar | ( | const i18n_udate_format_h | format, |
i18n_ucalendar_h * | calendar | ||
) |
Gets the i18n_ucalendar_h associated with an i18n_udate_format_h.
An i18n_udate_format_h uses an i18n_ucalendar_h to convert a raw value to, for example, the day of the week.
- Since :
- 2.3.1
- Parameters:
-
[in] format The i18n_udate_format_h to query. [out] calendar A pointer to the i18n_ucalendar_h used by format.
- Returns:
- Error code.
- Exceptions:
-
I18N_ERROR_NONE Successful I18N_ERROR_INVALID_PARAMETER Invalid function parameter
- See also:
- i18n_udate_set_calendar()
const char* i18n_udate_get_locale_by_type | ( | const i18n_udate_format_h | format, |
i18n_ulocale_data_locale_type_e | type | ||
) |
Gets the locale for this date format object.
You can choose between valid and actual locale.
- Remarks:
- The specific error code can be obtained using the get_last_result() method. Error codes are described in Exceptions section and i18n_error_code_e description.
- Since :
- 2.3.1
- Parameters:
-
[in] format The i18n_udate_format_h to get the locale from. [in] type The type of the locale we're looking for (valid or actual).
- Returns:
- The locale name.
- Exceptions:
-
I18N_ERROR_NONE Successful I18N_ERROR_INVALID_PARAMETER Invalid function parameter
int i18n_udate_get_number_format | ( | const i18n_udate_format_h | format, |
i18n_unumber_format_h * | number_format | ||
) |
Gets the i18n_unumber_format_h associated with an i18n_udate_format_h.
An i18n_udate_format_h uses an i18n_unumber_format_h to format numbers within a date, for example the day number.
- Since :
- 2.3.1
- Parameters:
-
[in] format The formatter to query. [out] number_format A pointer to the i18n_unumber_format_h used by format to format numbers.
- Returns:
- Error code.
- Exceptions:
-
I18N_ERROR_NONE Successful I18N_ERROR_INVALID_PARAMETER Invalid function parameter
- See also:
- i18n_udate_set_number_format()
int32_t i18n_udate_get_symbols | ( | const i18n_udate_format_h | format, |
i18n_udate_format_symbol_type_e | type, | ||
int32_t | symbol_index, | ||
i18n_uchar * | result, | ||
int32_t | result_length | ||
) |
Gets the symbols associated with an i18n_udate_format_h.
The symbols are what an i18n_udate_format_h uses to represent locale-specific data, for example month or day names.
- Remarks:
- The specific error code can be obtained using the get_last_result() method. Error codes are described in Exceptions section and i18n_error_code_e description.
- Since :
- 2.3.1
- Parameters:
-
[in] format The i18n_udate_format_h to query. [in] type The type of symbols to get. All the types defined in the i18n_udate_format_symbol_type_e enumeration are supported. [in] symbol_index The desired symbol of type type. [out] result A pointer to a buffer to receive the pattern. [in] result_length The maximum size of the result buffer.
- Returns:
- The total buffer size needed; if greater than result_length, the output was truncated.
- Exceptions:
-
I18N_ERROR_NONE Successful I18N_ERROR_INVALID_PARAMETER Invalid function parameter
i18n_ubool i18n_udate_is_lenient | ( | const i18n_udate_format_h | format | ) |
Determines if an i18n_udate_format_h will perform lenient parsing.
With lenient parsing, the parser may use heuristics to interpret inputs that do not precisely match the pattern. With strict parsing, inputs must match the pattern.
- Remarks:
- The specific error code can be obtained using the get_last_result() method. Error codes are described in Exceptions section.
- Since :
- 2.3.1
- Parameters:
-
[in] format The i18n_udate_format_h to query.
- Returns:
- true if format is set to perform lenient parsing, false otherwise.
- Exceptions:
-
I18N_ERROR_NONE Successful I18N_ERROR_INVALID_PARAMETER Invalid function parameter
- See also:
- i18n_udate_set_lenient()
int i18n_udate_parse | ( | const i18n_udate_format_h | format, |
const i18n_uchar * | text, | ||
int32_t | text_length, | ||
int32_t * | parse_pos, | ||
i18n_udate * | parsed_date | ||
) |
Parses a string into an date/time using an i18n_udate_format_h.
The date will be parsed using the conventions specified in i18n_udate_create().
Note that the normal date formats associated with some calendars - such as the Chinese lunar calendar - do not specify enough fields to enable dates to be parsed unambiguously. In the case of the Chinese lunar calendar, while the year within the current 60-year cycle is specified, the number of such cycles since the start date of the calendar (in the I18N_UCALENDAR_ERA field of the i18n_ucalendar_h) is not normally part of the format, and parsing may assume the wrong era. For such cases it is recommended that clients parse using i18n_udate_parse_calendar() with the calendar passed in set to the current date, or to a date within the era/cycle that should be assumed if absent in the format.
- Since :
- 2.3.1
- Parameters:
-
[in] format The formatter to use. [in] text The text to parse. [in] text_length The length of text, or -1 if NULL-terminated. [in] parse_pos If not 0, on input a pointer to an integer specifying the offset at which to begin parsing. If not 0, on output the offset at which parsing ended. [out] parsed_date A pointer to the value of the parsed date/time.
- Returns:
- Error code. Error codes not listed below are described in i18n_error_code_e
- Return values:
-
I18N_ERROR_NONE Successful I18N_ERROR_INVALID_PARAMETER Invalid function parameter
- See also:
- i18n_udate_format_date()
int i18n_udate_parse_calendar | ( | const i18n_udate_format_h | format, |
i18n_ucalendar_h * | calendar, | ||
const i18n_uchar * | text, | ||
int32_t | text_length, | ||
int32_t * | parse_pos | ||
) |
Parses a string into an date/time using an i18n_udate_format_h.
The date will be parsed using the conventions specified in i18n_udate_create().
- Since :
- 2.3.1
- Parameters:
-
[in] format The formatter to use. [in,out] calendar A pointer to calendar set on input to the date and time to be used for missing values in the date/time string being parsed, and set on output to the parsed date/time. When the calendar type is different from the internal calendar held by the i18n_udate_format_h instance, the internal calendar will be cloned to a work calendar set to the same milliseconds and time zone as this calendar parameter, field values will be parsed based on the work calendar, then the result (milliseconds and time zone) will be set in this calendar. [in] text The text to parse. [in] text_length The length of text, or -1 if NULL-terminated. [in] parse_pos If not 0, on input a pointer to an integer specifying the offset at which to begin parsing. If not 0, on output the offset at which parsing ended.
- Returns:
- Error code. Error codes not listed below are described in i18n_error_code_e
- Return values:
-
I18N_ERROR_NONE Successful I18N_ERROR_INVALID_PARAMETER Invalid function parameter
- See also:
- i18n_udate_format_date()
int i18n_udate_set_2digit_year_start | ( | i18n_udate_format_h | format, |
i18n_udate | date | ||
) |
Sets the year relative to which all 2-digit years will be interpreted.
For example, if the 2-digit start year is 2100, the year 99 will be interpreted as 2199.
- Since :
- 2.3.1
- Parameters:
-
[in] format The i18n_udate_format_h to map. [in] date The year relative to which all 2-digit years will be interpreted.
- Returns:
- Error code. Error codes not listed below are described in i18n_error_code_e
- Return values:
-
I18N_ERROR_NONE Successful I18N_ERROR_INVALID_PARAMETER Invalid function parameter
- See also:
- i18n_udate_get_2digit_year_start()
int i18n_udate_set_calendar | ( | i18n_udate_format_h | format, |
const i18n_ucalendar_h | calendar_to_set | ||
) |
Sets the i18n_ucalendar_h associated with an i18n_udate_format_h.
An i18n_udate_format_h uses an i18n_ucalendar_h to convert a raw value to, for example, the day of the week.
- Since :
- 2.3.1
- Parameters:
-
[in] format The i18n_udate_format_h. [in] calendar_to_set An i18n_ucalendar_h to be used by the format.
- Returns:
- Error code.
- Return values:
-
I18N_ERROR_NONE Successful I18N_ERROR_INVALID_PARAMETER Invalid function parameter
- See also:
- i18n_udate_get_calendar()
int i18n_udate_set_context | ( | i18n_udate_format_h | format, |
i18n_udisplay_context_e | value | ||
) |
Sets a particular i18n_udisplay_context_e value in the formatter, such as I18N_UDISPLAY_CONTEXT_CAPITALIZATION_FOR_STANDALONE.
- Remarks:
- I18N_UDISPLAY_CONTEXT_STANDARD_NAMES and I18N_UDISPLAY_CONTEXT_DIALECT_NAMES are not supported.
- Since :
- 2.3.1
- Parameters:
-
[in] format The i18n_udate_format_h to set a i18n_udisplay_context_e value. [in] value The i18n_udisplay_context_e value to set.
- Returns:
- Error code. Error codes not listed below are described in i18n_error_code_e
- Return values:
-
I18N_ERROR_NONE Successful I18N_ERROR_INVALID_PARAMETER Invalid function parameter
int i18n_udate_set_lenient | ( | i18n_udate_format_h | format, |
i18n_ubool | is_lenient | ||
) |
Specifies whether an i18n_udate_format_h will perform lenient parsing.
With lenient parsing, the parser may use heuristics to interpret inputs that do not precisely match the pattern. With strict parsing, inputs must match the pattern.
- Since :
- 2.3.1
- Parameters:
-
[in] format The i18n_udate_format_h to set. [in] is_lenient true if fmt should perform lenient parsing, false otherwise.
- Returns:
- Error code.
- Return values:
-
I18N_ERROR_NONE Successful I18N_ERROR_INVALID_PARAMETER Invalid function parameter
- See also:
- i18n_udate_is_lenient()
int i18n_udate_set_number_format | ( | i18n_udate_format_h | format, |
const i18n_unumber_format_h | number_format_to_set | ||
) |
Sets the i18n_unumber_format_h associated with an i18n_udate_format_h.
An i18n_udate_format_h uses an i18n_unumber_format_h to format numbers within a date, for example the day number.
- Since :
- 2.3.1
- Parameters:
-
[in] format The i18n_udate_format_h to set. [in] number_format_to_set An i18n_unumber_format_h to be used by format to format numbers.
- Returns:
- Error code.
- Return values:
-
I18N_ERROR_NONE Successful I18N_ERROR_INVALID_PARAMETER Invalid function parameter
- See also:
- i18n_udate_get_number_format()
int i18n_udate_set_symbols | ( | i18n_udate_format_h | format, |
i18n_udate_format_symbol_type_e | type, | ||
int32_t | symbol_index, | ||
i18n_uchar * | value, | ||
int32_t | value_length | ||
) |
Sets the symbols associated with an i18n_udate_format_h.
The symbols are what an i18n_udate_format_h uses to represent locale-specific data, for example month or day names.
- Since :
- 2.3.1
- Parameters:
-
[in] format The i18n_udate_format_h to set. [in] type The type of symbols to set. All the types defined in the i18n_udate_format_symbol_type_e enumeration are supported. If a type not defined in the enumeration is passed, then the I18N_ERROR_NOT_SUPPORTED error is returned. [in] symbol_index The index of the symbol to set of type type. [in] value The new value. [in] value_length The length of value, or -1
if NULL-terminated.
- Returns:
- Error code. Error codes not listed below are described in the i18n_error_code_e enumeration.
- Return values:
-
I18N_ERROR_NONE Successful I18N_ERROR_INVALID_PARAMETER Invalid function parameter
int i18n_udate_to_calendar_date_field | ( | i18n_udate_format_field_e | field, |
i18n_ucalendar_date_fields_e * | date_field_type | ||
) |
Maps from an i18n_udate_format_h to the corresponding i18n_ucalendar_date_fields_e.
Note: since the mapping is many-to-one, there is no inverse mapping.
- Since :
- 2.3.1
- Parameters:
-
[in] field The i18n_udate_format_h to map. I18N_UDATE_FORMAT_TIMEZONE_LOCALIZED_GMT_OFFSET_FIELD, I18N_UDATE_FORMAT_TIMEZONE_ISO_FIELD, I18N_UDATE_FORMAT_TIMEZONE_ISO_LOCAL_FIELD and I18N_UDATE_FORMAT_FIELD_COUNT are not supported. [out] date_field_type A pointer to the i18n_ucalendar_date_fields_e.
- Returns:
- Error code.
- Return values:
-
I18N_ERROR_NONE Successful I18N_ERROR_INVALID_PARAMETER Invalid function parameter
int32_t i18n_udate_to_pattern | ( | const i18n_udate_format_h | format, |
i18n_ubool | localized, | ||
i18n_uchar * | result, | ||
int32_t | result_length | ||
) |
Extracts the pattern from an i18n_udate_format_h.
The pattern will follow the pattern syntax rules.
- Remarks:
- The specific error code can be obtained using the get_last_result() method. Error codes are described in Exceptions section and i18n_error_code_e description.
- Since :
- 2.3.1
- Parameters:
-
[in] format The i18n_udate_format_h to query. [in] localized true if the pattern should be localized, false otherwise. [out] result A pointer to a buffer to receive the pattern. [in] result_length The maximum size of result.
- Returns:
- The total buffer size needed; if greater than result_length, the output was truncated.
- Exceptions:
-
I18N_ERROR_NONE Successful I18N_ERROR_INVALID_PARAMETER Invalid function parameter
- See also:
- i18n_udate_apply_pattern()