Tizen Native API
5.0
|
The Ucalendar is used for converting between an udate module and a set of integer fields such as I18N_UCALENDAR_YEAR, I18N_UCALENDAR_MONTH, I18N_UCALENDAR_DATE, I18N_UCALENDAR_HOUR, and so on.
#include <utils_i18n.h>
The Ucalendar is used for converting between an udate module and a set of integer fields such as I18N_UCALENDAR_YEAR, I18N_UCALENDAR_MONTH, I18N_UCALENDAR_DATE, I18N_UCALENDAR_HOUR, and so on. (An udate module represents a specific instant in time with millisecond precision. See udate for information about the udate.)
Converts the given date and time to the corresponding UTC time(number of seconds that have elapsed since January 1, 1970), considering the given time zone
#define ms2sec(ms) (long long int)(ms)/1000.0 // get time in sec from input date and time long long int _time_convert_itol(char *tzid, int y, int mon, int d, int h, int min, int s) { long long int lli; i18n_ucalendar_h ucal; i18n_udate date; int ret = I18N_ERROR_NONE; int year, month, day, hour, minute, second; int len; i18n_uchar *_tzid = NULL; if (tzid == NULL) { tzid = "Etc/GMT"; } _tzid = (i18n_uchar*)calloc(strlen(tzid) + 1, sizeof(i18n_uchar)); if (_tzid == NULL) { return -1; } // converts 'tzid' to unicode string i18n_ustring_copy_ua(_tzid, tzid); // gets length of '_tzid' len = i18n_ustring_get_length(_tzid); // creates i18n_ucalendar_h ret = i18n_ucalendar_create(_tzid, len, "en_US", I18N_UCALENDAR_TRADITIONAL, &ucal); if (ret) { dlog_print(DLOG_INFO, LOG_TAG, "i18n_ucalendar_create failed.\n"); return -1; } // sets i18n_ucalendar_h's date i18n_ucalendar_set_date_time(ucal, y, mon-1, d, h, min, s); // gets the current value of a field from i18n_ucalendar_h i18n_ucalendar_get(ucal, I18N_UCALENDAR_YEAR, &year); i18n_ucalendar_get(ucal, I18N_UCALENDAR_MONTH, &month); i18n_ucalendar_get(ucal, I18N_UCALENDAR_DATE, &day); i18n_ucalendar_get(ucal, I18N_UCALENDAR_HOUR, &hour); i18n_ucalendar_get(ucal, I18N_UCALENDAR_MINUTE, &minute); i18n_ucalendar_get(ucal, I18N_UCALENDAR_SECOND, &second); dlog_print(DLOG_INFO, LOG_TAG, "Date from ucal, year:%d month:%d day:%d hour:%d minute:%d second:%d.\n",year, month, day, hour, minute, second); // gets i18n_ucalendar's current time and converts it from milliseconds to seconds i18n_ucalendar_get_milliseconds(ucal, &date); lli = ms2sec(date); // destroys i18n_ucalendar_h i18n_ucalendar_destroy(ucal); if (_tzid) { free(_tzid); } return lli; }
Describes an example that uses _time_convert_itol from 'Sample Code 2'
// converts the given time to UTC time(number of seconds that have elapsed since January 1, 1970) long long int time = _time_convert_itol("Etc/GMT", 2014, 5, 28, 15, 14, 0); dlog_print(DLOG_INFO, LOG_TAG, "Time Zone: %s\t, %d/%d/%d/%d/%d/%d\n", "Etc/GMT", 2014, 5, 28, 15, 14, 0); dlog_print(DLOG_INFO, LOG_TAG, "_time_convert_itol test : %lld\n", time);
Functions | |
int | i18n_ucalendar_set_default_timezone (const i18n_uchar *zone_id) |
Sets the default time zone. | |
int | i18n_ucalendar_get_now (i18n_udate *date) |
Gets the current date and time. | |
int | i18n_ucalendar_create (const i18n_uchar *zone_id, int32_t len, const char *locale, i18n_ucalendar_type_e type, i18n_ucalendar_h *calendar) |
Creates an i18n_ucalendar_h. An i18n_ucalendar_h may be used to convert a millisecond value to a year, month, and day. | |
int | i18n_ucalendar_destroy (i18n_ucalendar_h calendar) |
Destroys an i18n_ucalendar_h. | |
int | i18n_ucalendar_clone (const i18n_ucalendar_h cal, i18n_ucalendar_h *identical_to_cal) |
Creates a copy of a i18n_ucalendar_h. This function performs a deep copy. | |
int | i18n_ucalendar_get_timezone_displayname (const i18n_ucalendar_h calendar, i18n_ucalendar_displayname_type_e type, const char *locale, i18n_uchar *result, int32_t result_len, int32_t *buf_size_needed) |
Gets the display name for a calendar's TimeZone. | |
int | i18n_ucalendar_is_in_daylight_time (const i18n_ucalendar_h calendar, i18n_ubool *is_in) |
Determines if an i18n_ucalendar_h is currently in daylight savings time. | |
int | i18n_ucalendar_set (i18n_ucalendar_h cal, i18n_ucalendar_date_fields_e field, int32_t val) |
Sets the value of a field in a i18n_ucalendar_h. | |
int | i18n_ucalendar_set_attribute (i18n_ucalendar_h calendar, i18n_ucalendar_attribute_e attr, int32_t val) |
Sets a numeric attribute associated with an i18n_ucalendar_h. | |
int | i18n_ucalendar_get_attribute (i18n_ucalendar_h calendar, i18n_ucalendar_attribute_e attr, int32_t *val) |
Gets a numeric attribute associated with an i18n_ucalendar. | |
int | i18n_ucalendar_get_milliseconds (const i18n_ucalendar_h calendar, i18n_udate *date) |
Gets a calendar's current time in milliseconds. | |
int | i18n_ucalendar_set_milliseconds (i18n_ucalendar_h calendar, i18n_udate milliseconds) |
Sets a calendar's current time in milliseconds. | |
int | i18n_ucalendar_set_date_time (i18n_ucalendar_h calendar, int32_t year, int32_t month, int32_t date, int32_t hour, int32_t min, int32_t sec) |
Sets a calendar's current date. | |
int | i18n_ucalendar_is_equivalent_to (const i18n_ucalendar_h calendar1, const i18n_ucalendar_h calendar2, i18n_ubool *equiv) |
Returns true if two i18n_ucalendar_h calendars are equivalent. | |
int | i18n_ucalendar_add (i18n_ucalendar_h calendar, i18n_ucalendar_date_fields_e field, int32_t amount) |
Adds a specified signed amount to a particular field in a i18n_ucalendar_h. | |
int | i18n_ucalendar_get (const i18n_ucalendar_h calendar, i18n_ucalendar_date_fields_e field, int32_t *val) |
Gets the current value of a field from an i18n_ucalendar_h. | |
int32_t | i18n_ucalendar_get_field_difference (i18n_ucalendar_h calendar, i18n_udate target, i18n_ucalendar_date_fields_e field, i18n_error_code_e *status) |
Returns the difference between the target time and the time this calendar object is currently set to. | |
int | i18n_ucalendar_timezone_id_enumeration_create (i18n_system_timezone_type_e zone_type, const char *region, const int32_t *raw_offset, i18n_uenumeration_h *enumeration) |
Creates an enumeration over system time zone IDs with the given filter conditions. | |
int | i18n_ucalendar_timezones_create (i18n_uenumeration_h *enumeration) |
Creates an enumeration over all time zones. | |
int | i18n_ucalendar_country_timezones_create (const char *country, i18n_uenumeration_h *enumeration) |
Creates an enumeration over all time zones associated with the given country. | |
int32_t | i18n_ucalendar_get_default_timezone (i18n_uchar *result, int32_t result_capacity) |
Returns the default time zone (i.e., the one returned by the i18n_timezone_create_default() function). | |
int | i18n_ucalendar_set_timezone (i18n_ucalendar_h calendar, const i18n_uchar *zone_id, int32_t length) |
Sets the TimeZone used by a i18n_ucalendar_h. | |
int32_t | i18n_ucalendar_get_timezone_id (const i18n_ucalendar_h calendar, i18n_uchar *result, int32_t result_length) |
Gets the ID of the calendar's time zone. | |
int | i18n_ucalendar_set_gregorian_change (i18n_ucalendar_h calendar, i18n_udate date) |
Sets the Gregorian Calendar change date. | |
int | i18n_ucalendar_get_gregorian_change (const i18n_ucalendar_h calendar, i18n_udate *date) |
Gets the Gregorian Calendar change date. | |
const char * | i18n_ucalendar_get_available (int32_t locale_index) |
Gets a locale for which calendars are available. | |
int32_t | i18n_ucalendar_count_available (void) |
Determines how many locales have calendars available. | |
int | i18n_ucalendar_set_date (i18n_ucalendar_h calendar, int32_t year, int32_t month, int32_t date) |
Sets a calendar's current date. | |
int | i18n_ucalendar_roll (i18n_ucalendar_h calendar, i18n_ucalendar_date_fields_e field, int32_t amount) |
Adds a specified signed amount to a particular field in a i18n_ucalendar_h. | |
i18n_ubool | i18n_ucalendar_is_set (const i18n_ucalendar_h calendar, i18n_ucalendar_date_fields_e field) |
Determines if a field in a i18n_ucalendar_h is set. | |
int | i18n_ucalendar_clear_field (i18n_ucalendar_h calendar, i18n_ucalendar_date_fields_e field) |
Clears a field in a i18n_ucalendar_h. | |
int | i18n_ucalendar_clear (i18n_ucalendar_h calendar) |
Clears all fields in a i18n_ucalendar_h. | |
int32_t | i18n_ucalendar_get_limit (const i18n_ucalendar_h calendar, i18n_ucalendar_date_fields_e field, i18n_ucalendar_limit_type_e type) |
Determines a limit for a field in an i18n_ucalendar_h. | |
const char * | i18n_ucalendar_get_locale_by_type (const i18n_ucalendar_h calendar, i18n_ulocale_data_locale_type_e type) |
Gets the locale for this calendar object. | |
const char * | i18n_ucalendar_get_tz_data_version (void) |
Returns the timezone data version currently used by ICU. | |
int32_t | i18n_ucalendar_get_canonical_timezone_id (const i18n_uchar *id, int32_t length, i18n_uchar *result, int32_t result_capacity, i18n_ubool *is_system_id) |
Returns the canonical system timezone ID or the normalized custom time zone ID for the given time zone ID. | |
const char * | i18n_ucalendar_get_type (const i18n_ucalendar_h calendar) |
Gets the resource keyword value string designating the calendar type for the i18n_ucalendar_h. | |
int | i18n_ucalendar_get_keyword_values_for_locale (const char *key, const char *locale, i18n_ubool commonly_used, i18n_uenumeration_h *enumeration) |
Given a key and a locale, returns an array of string values in a preferred order that would make a difference. | |
int | i18n_ucalendar_get_day_of_week_type (const i18n_ucalendar_h calendar, i18n_ucalendar_days_of_week_e day_of_week, i18n_ucalendar_weekday_type_e *weekday) |
Returns whether the given day of the week is a weekday, a weekend day, or a day that transitions from one to the other, for the locale and calendar system associated with this i18n_ucalendar_h (the locale's region is often the most determinant factor). | |
int32_t | i18n_ucalendar_get_weekend_transition (const i18n_ucalendar_h calendar, i18n_ucalendar_days_of_week_e day_of_week) |
Returns the time during the day at which the weekend begins or ends in this calendar system. | |
i18n_ubool | i18n_ucalendar_is_weekend (i18n_ucalendar_h calendar, i18n_udate date) |
Returns true if the given i18n_udate is in the weekend in this calendar system. | |
i18n_ubool | i18n_ucalendar_get_timezone_transition_date (const i18n_ucalendar_h calendar, i18n_utimezone_transition_type_e type, i18n_udate *transition) |
Get the i18n_udate for the next/previous time zone transition relative to the calendar's current date, in the time zone to which the calendar is currently set. | |
Typedefs | |
typedef void * | i18n_ucalendar_h |
i18n_ucalendar_h. | |
Defines | |
#define | I18N_UCALENDAR_UNKNOWN_ZONE_ID "Etc/Unknown" |
The time zone ID reserved for unknown time zone. |
#define I18N_UCALENDAR_UNKNOWN_ZONE_ID "Etc/Unknown" |
The time zone ID reserved for unknown time zone.
typedef void* i18n_ucalendar_h |
i18n_ucalendar_h.
Enumeration for types of i18n_ucalendar_h attributes.
Enumeration for possible fields in an i18n_ucalendar_h.
I18N_UCALENDAR_ERA |
Field number indicating the era, e.g., AD or BC in the Gregorian (Julian) calendar |
I18N_UCALENDAR_YEAR |
Field number indicating the year |
I18N_UCALENDAR_MONTH |
Field number indicating the month. This is a calendar-specific value. |
I18N_UCALENDAR_WEEK_OF_YEAR |
Field number indicating the week number within the current year. |
I18N_UCALENDAR_WEEK_OF_MONTH |
Field number indicating the week number within the current month. |
I18N_UCALENDAR_DATE |
Field number indicating the day of the month. |
I18N_UCALENDAR_DAY_OF_YEAR |
Field number indicating the day number within the current year. |
I18N_UCALENDAR_DAY_OF_WEEK |
Field number indicating the day of the week. |
I18N_UCALENDAR_DAY_OF_WEEK_IN_MONTH |
Field number indicating the ordinal number of the day of the week within the current month. |
I18N_UCALENDAR_AM_PM |
Field number indicating whether the "hour" is before or after noon. |
I18N_UCALENDAR_HOUR |
Field number indicating the hour of the morning or afternoon. |
I18N_UCALENDAR_HOUR_OF_DAY |
Field number indicating the hour of the day. |
I18N_UCALENDAR_MINUTE |
Field number indicating the minute within the hour. |
I18N_UCALENDAR_SECOND |
Field number indicating the second within the minute. |
I18N_UCALENDAR_MILLISECOND |
Field number indicating the millisecond within the second. |
I18N_UCALENDAR_ZONE_OFFSET |
Field number indicating the raw offset from GMT in milliseconds |
I18N_UCALENDAR_DST_OFFSET |
Field number indicating the daylight savings offset in milliseconds |
I18N_UCALENDAR_YEAR_WOY |
Field number indicating the extended year corresponding to the I18N_UCALENDAR_WEEK_OF_YEAR field. |
I18N_UCALENDAR_DOW_LOCAL |
Field number indicating the localized day of the week. |
I18N_UCALENDAR_EXTENDED_YEAR |
Year of this calendar system, encompassing all supra-year fields. |
I18N_UCALENDAR_JULIAN_DAY |
Field number indicating the modified Julian day number. |
I18N_UCALENDAR_MILLISECONDS_IN_DAY |
Ranges from 0 to 23:59:59.999 (regardless of DST). |
I18N_UCALENDAR_IS_LEAP_MONTH |
Whether or not the current month is a leap month (0 or 1) |
I18N_UCALENDAR_FIELD_COUNT |
Number of enumerators |
I18N_UCALENDAR_DAY_OF_MONTH |
Field number indicating the day of the month. |
Useful constants for days of week.
Note: Calendar day-of-week is 1-based. Clients who create locale resources for the field of first-day-of-week should be aware of this. For instance, in US locale, first-day-of-week is set to 1, i.e., I18N_UCALENDAR_SUNDAY. Possible days of the week in an i18n_ucalendar_h.
Enumeration for possible formats of an i18n_ucalendar_h's display name.
Possible limit values for an i18n_ucalendar_h.
Enumeration for possible months in an i18n_ucalendar_h.
Enumeration for possible months in an i18n_ucalendar_h.
I18N_UCALENDAR_TRADITIONAL |
Despite the name, I18N_UCALENDAR_TRADITIONAL designates the locale's default calendar, which may be the Gregorian calendar or some other calendar |
I18N_UCALENDAR_DEFAULT |
A better name for I18N_UCALENDAR_TRADITIONAL |
I18N_UCALENDAR_GREGORIAN |
Unambiguously designates the Gregorian calendar for the locale |
Weekday types, as returned by i18n_ucalendar_get_day_of_week_type().
I18N_UCALENDAR_WEEKDAY |
Designates a full weekday (no part of the day is included in the weekend). |
I18N_UCALENDAR_WEEKEND |
Designates a full weekend day (the entire day is included in the weekend). |
I18N_UCALENDAR_WEEKEND_ONSET |
Designates a day that starts as a weekday and transitions to the weekend. Call i18n_ucalendar_get_weekend_transition() to get the time of transition. |
I18N_UCALENDAR_WEEKEND_CEASE |
Designates a day that starts as the weekend and transitions to a weekday. Call i18n_ucalendar_get_weekend_transition() to get the time of transition. |
Time zone transition types for i18n_ucalendar_get_timezone_transition_date().
int i18n_ucalendar_add | ( | i18n_ucalendar_h | calendar, |
i18n_ucalendar_date_fields_e | field, | ||
int32_t | amount | ||
) |
Adds a specified signed amount to a particular field in a i18n_ucalendar_h.
This can modify more significant fields in the calendar.
[in] | calendar | The i18n_ucalendar_h to which to add |
[in] | field | The field to which to add the signed value One of I18N_UCALENDAR_ERA, I18N_UCALENDAR_YEAR, I18N_UCALENDAR_MONTH, I18N_UCALENDAR_WEEK_OF_YEAR, I18N_UCALENDAR_WEEK_OF_MONTH, I18N_UCALENDAR_DATE, I18N_UCALENDAR_DAY_OF_YEAR, I18N_UCALENDAR_DAY_OF_WEEK, I18N_UCALENDAR_DAY_OF_WEEK_IN_MONTH, I18N_UCALENDAR_AM_PM, I18N_UCALENDAR_HOUR, I18N_UCALENDAR_HOUR_OF_DAY, I18N_UCALENDAR_MINUTE, I18N_UCALENDAR_SECOND, I18N_UCALENDAR_MILLISECOND. |
[in] | amount | The signed amount to add to the field If the amount causes the value to exceed to maximum or minimum values for that field, other fields are modified to preserve the magnitude of the change. |
I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
int i18n_ucalendar_clear | ( | i18n_ucalendar_h | calendar | ) |
Clears all fields in a i18n_ucalendar_h.
All fields are represented as 32-bit integers.
[in] | calendar | i18n_ucalendar_h to clear. |
I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
int i18n_ucalendar_clear_field | ( | i18n_ucalendar_h | calendar, |
i18n_ucalendar_date_fields_e | field | ||
) |
Clears a field in a i18n_ucalendar_h.
All fields are represented as 32-bit integers.
[in] | calendar | The i18n_ucalendar_h containing the field to clear. |
[in] | field | The field to clear. |
I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
int i18n_ucalendar_clone | ( | const i18n_ucalendar_h | cal, |
i18n_ucalendar_h * | identical_to_cal | ||
) |
Creates a copy of a i18n_ucalendar_h. This function performs a deep copy.
[in] | cal | The i18n_ucalendar_h to copy |
[out] | identical_to_cal | A pointer to a i18n_ucalendar_h identical to cal. |
I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
int32_t i18n_ucalendar_count_available | ( | void | ) |
Determines how many locales have calendars available.
This function is most useful as determining the loop ending condition for calls to i18n_ucalendar_get_available().
I18N_ERROR_NONE | Successful |
int i18n_ucalendar_country_timezones_create | ( | const char * | country, |
i18n_uenumeration_h * | enumeration | ||
) |
Creates an enumeration over all time zones associated with the given country.
Some zones are affiliated with no country (e.g., "UTC"); these may also be retrieved, as a group.
[in] | country | The ISO 3166 two-letter country code, or NULL to retrieve zones not affiliated with any country |
[out] | enumeration | A pointer to the enumeration object that the caller must dispose of using i18n_uenumeration_destroy(), or NULL upon failure. |
I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
int i18n_ucalendar_create | ( | const i18n_uchar * | zone_id, |
int32_t | len, | ||
const char * | locale, | ||
i18n_ucalendar_type_e | type, | ||
i18n_ucalendar_h * | calendar | ||
) |
Creates an i18n_ucalendar_h. An i18n_ucalendar_h may be used to convert a millisecond value to a year, month, and day.
Note: When an unknown TimeZone ID is specified, the i18n_ucalendar_h returned by the function is initialized with GMT ("Etc/GMT") without any errors/warnings.
[in] | zone_id | The desired TimeZone ID If 0 , use the default time zone. |
[in] | len | The length of the zone ID, otherwise -1 if null-terminated |
[in] | locale | The desired locale If NULL , the default locale will be used. |
[in] | type | The type of I18N_UCALENDAR_DEFAULT to create This can be I18N_UCALENDAR_GREGORIAN to create the Gregorian calendar for the locale, or I18N_UCALENDAR_DEFAULT to create the default calendar for the locale (the default calendar may also be Gregorian). |
[out] | calendar | A pointer to an i18n_ucalendar_h, otherwise 0 if an error occurs |
I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
I18N_ERROR_OUT_OF_MEMORY | Out of memory |
int i18n_ucalendar_destroy | ( | i18n_ucalendar_h | calendar | ) |
Destroys an i18n_ucalendar_h.
Once destroyed, an i18n_ucalendar_h may no longer be used.
[in] | calendar | The i18n_ucalendar_h to destroy |
I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
int i18n_ucalendar_get | ( | const i18n_ucalendar_h | calendar, |
i18n_ucalendar_date_fields_e | field, | ||
int32_t * | val | ||
) |
Gets the current value of a field from an i18n_ucalendar_h.
All fields are represented as 32-bit integers.
[in] | calendar | The i18n_ucalendar_h to query |
[in] | field | The desired field One of I18N_UCALENDAR_ERA, I18N_UCALENDAR_YEAR, I18N_UCALENDAR_MONTH, I18N_UCALENDAR_WEEK_OF_YEAR, I18N_UCALENDAR_WEEK_OF_MONTH, I18N_UCALENDAR_DATE, I18N_UCALENDAR_DAY_OF_YEAR, I18N_UCALENDAR_DAY_OF_WEEK, I18N_UCALENDAR_DAY_OF_WEEK_IN_MONTH, I18N_UCALENDAR_AM_PM, I18N_UCALENDAR_HOUR, I18N_UCALENDAR_HOUR_OF_DAY, I18N_UCALENDAR_MINUTE, I18N_UCALENDAR_SECOND, I18N_UCALENDAR_MILLISECOND, I18N_UCALENDAR_ZONE_OFFSET, or I18N_UCALENDAR_DST_OFFSET. |
[out] | val | The value of the desired field. |
I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
int i18n_ucalendar_get_attribute | ( | i18n_ucalendar_h | calendar, |
i18n_ucalendar_attribute_e | attr, | ||
int32_t * | val | ||
) |
Gets a numeric attribute associated with an i18n_ucalendar.
Numeric attributes include the first day of the week, or the minimal numbers of days in the first week of the month.
[in] | calendar | The i18n_ucalendar to query |
[in] | attr | The desired attribute One of I18N_UCALENDAR_LENIENT, I18N_UCALENDAR_FIRST_DAY_OF_WEEK, or I18N_UCALENDAR_MINIMAL_DAYS_IN_FIRST_WEEK. |
[out] | val | The value of attr |
I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
const char* i18n_ucalendar_get_available | ( | int32_t | locale_index | ) |
Gets a locale for which calendars are available.
A i18n_ucalendar_h in a locale returned by this function will contain the correct day and month names for the locale.
[in] | locale_index | The index of the desired locale. |
I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid parameter |
int32_t i18n_ucalendar_get_canonical_timezone_id | ( | const i18n_uchar * | id, |
int32_t | length, | ||
i18n_uchar * | result, | ||
int32_t | result_capacity, | ||
i18n_ubool * | is_system_id | ||
) |
Returns the canonical system timezone ID or the normalized custom time zone ID for the given time zone ID.
[in] | id | The input timezone ID to be canonicalized. |
[in] | length | The length of the id , or -1 if NULL-terminated. |
[out] | result | The buffer receives the canonical system timezone ID or the custom timezone ID in normalized format. |
[in] | result_capacity | The capacity of the result buffer. |
[out] | is_system_id | Receives if the given id is a known system timezone ID. |
I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
int i18n_ucalendar_get_day_of_week_type | ( | const i18n_ucalendar_h | calendar, |
i18n_ucalendar_days_of_week_e | day_of_week, | ||
i18n_ucalendar_weekday_type_e * | weekday | ||
) |
Returns whether the given day of the week is a weekday, a weekend day, or a day that transitions from one to the other, for the locale and calendar system associated with this i18n_ucalendar_h
(the locale's region is often the most determinant factor).
If a transition occurs at midnight, then the days before and after the transition will have the type I18N_UCALENDAR_WEEKDAY or I18N_UCALENDAR_WEEKEND. If a transition occurs at a time other than midnight, then the day of the transition will have the type I18N_UCALENDAR_WEEKEND_ONSET or I18N_UCALENDAR_WEEKEND_CEASE. In this case, the function i18n_ucalendar_get_weekend_transition() will return the point of transition.
[in] | calendar | The i18n_ucalendar_h to query. |
[in] | day_of_week | The day of the week whose type is desired (I18N_UCALENDAR_SUNDAY..I18N_UCALENDAR_SATURDAY). |
[out] | weekday | A pointer to the i18n_ucalendar_weekday_type_e for the day of the week. |
I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
int32_t i18n_ucalendar_get_default_timezone | ( | i18n_uchar * | result, |
int32_t | result_capacity | ||
) |
Returns the default time zone (i.e., the one returned by the i18n_timezone_create_default() function).
The default time zone is determined initially by querying the host operating system and storing the obtained time zone as default until the application terminates. Therefore, if the time zone is changed after the first call, subsequent calls will not reflect the change, i.e. the returned time zone will be the same as for the first function call.
To query the system for the current timezone, use i18n_timezone_detect_host_timezone() from the Timezone module.
The default time zone may be changed with i18n_ucalendar_set_default_timezone() or with the i18n Timezone API.
[out] | result | A buffer to receive the result, or NULL |
[in] | result_capacity | The capacity of the result buffer |
result
string length, not including the terminating NULL
. I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid parameter |
int32_t i18n_ucalendar_get_field_difference | ( | i18n_ucalendar_h | calendar, |
i18n_udate | target, | ||
i18n_ucalendar_date_fields_e | field, | ||
i18n_error_code_e * | status | ||
) |
Returns the difference between the target time and the time this calendar object is currently set to.
If the target time is after the current calendar setting, the the returned value will be positive. The field parameter specifies the units of the return value. For example, if field is I18N_UCALENDAR_MONTH and i18n_ucalendar_get_field_difference returns 3, then the target time is 3 to less than 4 months after the current calendar setting.
As a side effect of this call, this calendar is advanced toward target by the given amount. That is, calling this function has the side effect of calling i18n_ucalendar_add on this calendar with the specified field and an amount equal to the return value from this function.
A typical way of using this function is to call it first with the largest field of interest, then with progressively smaller fields.
[in] | calendar | The i18n_ucalendar_h to compare and update. |
[in] | target | The target date to compare to the current calendar setting. |
[in] | field | One of I18N_UCALENDAR_ERA, I18N_UCALENDAR_YEAR, I18N_UCALENDAR_MONTH, I18N_UCALENDAR_WEEK_OF_YEAR, I18N_UCALENDAR_WEEK_OF_MONTH, I18N_UCALENDAR_DATE, I18N_UCALENDAR_DAY_OF_YEAR, I18N_UCALENDAR_DAY_OF_WEEK, I18N_UCALENDAR_DAY_OF_WEEK_IN_MONTH, I18N_UCALENDAR_AM_PM, I18N_UCALENDAR_HOUR, I18N_UCALENDAR_HOUR_OF_DAY, I18N_UCALENDAR_MINUTE, I18N_UCALENDAR_SECOND, I18N_UCALENDAR_MILLISECOND. Please note that the returned value type is int32_t. In case of I18N_UCALENDAR_MILLISECOND, maximal difference between dates may be equal to the maximal value of the int32_t, which is 2147483647 (about one month difference). If the difference is bigger, then the I18N_ERROR_INVALID_PARAMETER error will be returned. |
[out] | status | A pointer to an i18n_error_code_e to receive any errors |
int i18n_ucalendar_get_gregorian_change | ( | const i18n_ucalendar_h | calendar, |
i18n_udate * | date | ||
) |
Gets the Gregorian Calendar change date.
This is the point when the switch from Julian dates to Gregorian dates occurred. Default is 00:00:00 local time, October 15, 1582. Previous to this time and date will be Julian dates. This function works only for Gregorian calendars. If the i18n_ucalendar_h is not an instance of a Gregorian calendar, then a I18N_ERROR_NOT_SUPPORTED error code is set.
[in] | calendar | The calendar object. |
[out] | date | A pointer to the Gregorian cutover time for this calendar. |
I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
int i18n_ucalendar_get_keyword_values_for_locale | ( | const char * | key, |
const char * | locale, | ||
i18n_ubool | commonly_used, | ||
i18n_uenumeration_h * | enumeration | ||
) |
Given a key and a locale, returns an array of string values in a preferred order that would make a difference.
These are all and only those values where the open (creation) of the service with the locale formed from the input locale plus input keyword and that value has different behavior than creation with the input locale alone.
[in] | key | One of the keys supported by this service. For now, only "calendar" is supported. |
[in] | locale | The locale |
[in] | commonly_used | If set to true it will return only commonly used values with the given locale in preferred order. Otherwise, it will return all the available values for the locale. |
[out] | enumeration | A pointer to the string enumeration over keyword values for the given key and the locale. |
I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
int32_t i18n_ucalendar_get_limit | ( | const i18n_ucalendar_h | calendar, |
i18n_ucalendar_date_fields_e | field, | ||
i18n_ucalendar_limit_type_e | type | ||
) |
Determines a limit for a field in an i18n_ucalendar_h.
A limit is a maximum or minimum value for a field.
I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
const char* i18n_ucalendar_get_locale_by_type | ( | const i18n_ucalendar_h | calendar, |
i18n_ulocale_data_locale_type_e | type | ||
) |
Gets the locale for this calendar
object.
You can choose between valid and actual locale.
[in] | calendar | The calendar object |
[in] | type | Type of the locale we're looking for (valid or actual) |
I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
int i18n_ucalendar_get_milliseconds | ( | const i18n_ucalendar_h | calendar, |
i18n_udate * | date | ||
) |
Gets a calendar's current time in milliseconds.
The time is represented as milliseconds from the epoch.
[in] | calendar | The i18n_ucalendar_h to query |
[out] | date | The calendar's current time in milliseconds |
I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
int i18n_ucalendar_get_now | ( | i18n_udate * | date | ) |
Gets the current date and time.
The value returned is represented as milliseconds from the epoch.
[out] | date | The current date and time |
I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
int i18n_ucalendar_get_timezone_displayname | ( | const i18n_ucalendar_h | calendar, |
i18n_ucalendar_displayname_type_e | type, | ||
const char * | locale, | ||
i18n_uchar * | result, | ||
int32_t | result_len, | ||
int32_t * | buf_size_needed | ||
) |
Gets the display name for a calendar's TimeZone.
A display name is suitable for presentation to a user.
[in] | calendar | The i18n_ucalendar_h to query |
[in] | type | The desired display name format One of I18N_UCALENDAR_STANDARD, I18N_UCALENDAR_SHORT_STANDARD, I18N_UCALENDAR_DST, or I18N_UCALENDAR_SHORT_DST |
[in] | locale | The desired locale for the display name |
[out] | result | A pointer to a buffer to receive the formatted number |
[in] | result_len | The maximum size of the result |
[out] | buf_size_needed | The total buffer size needed If greater than result_len, the output is truncated |
I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
int32_t i18n_ucalendar_get_timezone_id | ( | const i18n_ucalendar_h | calendar, |
i18n_uchar * | result, | ||
int32_t | result_length | ||
) |
Gets the ID of the calendar's time zone.
[in] | calendar | The i18n_ucalendar_h to query. |
[out] | result | Receives the calendar's time zone ID. |
[in] | result_length | The maximum size of the result . |
result_length
, the output was truncated. I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
i18n_ubool i18n_ucalendar_get_timezone_transition_date | ( | const i18n_ucalendar_h | calendar, |
i18n_utimezone_transition_type_e | type, | ||
i18n_udate * | transition | ||
) |
Get the i18n_udate for the next/previous time zone transition relative to the calendar's current date, in the time zone to which the calendar is currently set.
If there is no known time zone transition of the requested type relative to the calendar's date, the function returns false
.
[in] | calendar | The i18n_ucalendar_h to query. |
[in] | type | The type of transition desired. |
[out] | transition | A pointer to a i18n_udate to be set to the transition time. If the function returns false , the value set is unspecified. |
true
if the given i18n_udate is in the weekend in this calendar system, false
otherwise. I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
const char* i18n_ucalendar_get_type | ( | const i18n_ucalendar_h | calendar | ) |
Gets the resource keyword value string designating the calendar type for the i18n_ucalendar_h.
[in] | calendar | The i18n_ucalendar_h to query. |
I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
const char* i18n_ucalendar_get_tz_data_version | ( | void | ) |
Returns the timezone data version currently used by ICU.
I18N_ERROR_NONE | Successful |
int32_t i18n_ucalendar_get_weekend_transition | ( | const i18n_ucalendar_h | calendar, |
i18n_ucalendar_days_of_week_e | day_of_week | ||
) |
Returns the time during the day at which the weekend begins or ends in this calendar system.
If i18n_ucalendar_get_day_of_week_type() returns I18N_UCALENDAR_WEEKEND_ONSET for the specified day_of_week
, return the time at which the weekend begins. If i18n_ucalendar_get_day_of_week_type() returns I18N_UCALENDAR_WEEKEND_CEASE for the specified day_of_week
, return the time at which the weekend ends. If i18n_ucalendar_get_day_of_week_type() returns some other i18n_ucalendar_weekday_type_e for the specified day_of_week
, it is an error condition (I18N_ERROR_INVALID_PARAMETER).
[in] | calendar | The i18n_ucalendar_h to query. |
[in] | day_of_week | The day of the week whose type is desired (I18N_UCALENDAR_SUNDAY..I18N_UCALENDAR_SATURDAY). |
I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
int i18n_ucalendar_is_equivalent_to | ( | const i18n_ucalendar_h | calendar1, |
const i18n_ucalendar_h | calendar2, | ||
i18n_ubool * | equiv | ||
) |
Returns true
if two i18n_ucalendar_h calendars are equivalent.
Equivalent i18n_ucalendar_h calendars will behave identically, but they may be set to different times.
[in] | calendar1 | The first of the calendars to compare |
[in] | calendar2 | The second of the calendars to compare |
[out] | equiv | If true cal1 and cal2 are equivalent, otherwise false |
I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
int i18n_ucalendar_is_in_daylight_time | ( | const i18n_ucalendar_h | calendar, |
i18n_ubool * | is_in | ||
) |
Determines if an i18n_ucalendar_h is currently in daylight savings time.
Daylight savings time is not used in all parts of the world.
[in] | calendar | The i18n_ucalendar_h to query |
[out] | is_in | If true calendar is currently in daylight savings time, otherwise false |
I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
i18n_ubool i18n_ucalendar_is_set | ( | const i18n_ucalendar_h | calendar, |
i18n_ucalendar_date_fields_e | field | ||
) |
Determines if a field in a i18n_ucalendar_h is set.
All fields are represented as 32-bit integers.
[in] | calendar | The i18n_ucalendar_h to query. |
[in] | field | The desired field. |
true
if field is set, false
otherwise. I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
i18n_ubool i18n_ucalendar_is_weekend | ( | i18n_ucalendar_h | calendar, |
i18n_udate | date | ||
) |
Returns true
if the given i18n_udate is in the weekend in this calendar system.
[in] | calendar | The i18n_ucalendar_h to query. |
[in] | date | The i18n_udate in question. |
true
if the given i18n_udate is in the weekend in this calendar system, false
otherwise. I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
int i18n_ucalendar_roll | ( | i18n_ucalendar_h | calendar, |
i18n_ucalendar_date_fields_e | field, | ||
int32_t | amount | ||
) |
Adds a specified signed amount to a particular field in a i18n_ucalendar_h.
This will not modify more significant fields in the calendar. Rolling by a positive value always means moving forward in time (unless the limit of the field is reached, in which case it may pin or wrap), so for Gregorian calendar, starting with 100 BC and rolling the year by +1 results in 99 BC. When eras have a definite beginning and end (as in the Chinese calendar, or as in most eras in the Japanese calendar) then rolling the year past either limit of the era will cause the year to wrap around. When eras only have a limit at one end, then attempting to roll the year past that limit will result in pinning the year at that limit. Note that for most calendars in which era 0 years move forward in time (such as Buddhist, Hebrew, or Islamic), it is possible for add or roll to result in negative years for era 0 (that is the only way to represent years before the calendar epoch).
[in] | calendar | The i18n_ucalendar_h to which to add. |
[in] | field | The field to which to add the signed value; one of I18N_UCALENDAR_ERA, I18N_UCALENDAR_YEAR, I18N_UCALENDAR_MONTH, I18N_UCALENDAR_WEEK_OF_YEAR, I18N_UCALENDAR_WEEK_OF_MONTH, I18N_UCALENDAR_DATE, I18N_UCALENDAR_DAY_OF_YEAR, I18N_UCALENDAR_DAY_OF_WEEK, I18N_UCALENDAR_DAY_OF_WEEK_IN_MONTH, I18N_UCALENDAR_AM_PM, I18N_UCALENDAR_HOUR, I18N_UCALENDAR_HOUR_OF_DAY, I18N_UCALENDAR_MINUTE, I18N_UCALENDAR_SECOND, I18N_UCALENDAR_MILLISECOND. |
[in] | amount | The signed amount to add to the field . If the amount causes the value to exceed to maximum or minimum values for that field, the field is pinned to a permissible value. |
I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
int i18n_ucalendar_set | ( | i18n_ucalendar_h | cal, |
i18n_ucalendar_date_fields_e | field, | ||
int32_t | val | ||
) |
Sets the value of a field in a i18n_ucalendar_h.
All fields are represented as 32-bit integers.
[in] | cal | The i18n_ucalendar_h to modify |
[in] | field | The field to set One of I18N_UCALENDAR_ERA, I18N_UCALENDAR_YEAR, I18N_UCALENDAR_MONTH, I18N_UCALENDAR_WEEK_OF_YEAR, I18N_UCALENDAR_WEEK_OF_MONTH, I18N_UCALENDAR_DATE, I18N_UCALENDAR_DAY_OF_YEAR, I18N_UCALENDAR_DAY_OF_WEEK, I18N_UCALENDAR_DAY_OF_WEEK_IN_MONTH, I18N_UCALENDAR_AM_PM, I18N_UCALENDAR_HOUR, I18N_UCALENDAR_HOUR_OF_DAY, I18N_UCALENDAR_MINUTE, I18N_UCALENDAR_SECOND, I18N_UCALENDAR_MILLISECOND, I18N_UCALENDAR_ZONE_OFFSET, I18N_UCALENDAR_DST_OFFSET. |
[in] | val | The desired value of field. |
I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
int i18n_ucalendar_set_attribute | ( | i18n_ucalendar_h | calendar, |
i18n_ucalendar_attribute_e | attr, | ||
int32_t | val | ||
) |
Sets a numeric attribute associated with an i18n_ucalendar_h.
Numeric attributes include the first day of the week, or the minimal number of days in the first week of the month.
[in] | calendar | The i18n_ucalendar_h to modify |
[in] | attr | The desired attribute One of I18N_UCALENDAR_LENIENT, I18N_UCALENDAR_FIRST_DAY_OF_WEEK, or I18N_UCALENDAR_MINIMAL_DAYS_IN_FIRST_WEEK. |
[in] | val | The new value of attr |
I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
int i18n_ucalendar_set_date | ( | i18n_ucalendar_h | calendar, |
int32_t | year, | ||
int32_t | month, | ||
int32_t | date | ||
) |
Sets a calendar's current date.
The date is represented as a series of 32-bit integers.
[in] | calendar | The i18n_ucalendar_h to set. |
[in] | year | The desired year. |
[in] | month | The desired month; one of I18N_UCALENDAR_JANUARY, I18N_UCALENDAR_FEBRUARY, I18N_UCALENDAR_MARCH, I18N_UCALENDAR_APRIL, I18N_UCALENDAR_MAY, I18N_UCALENDAR_JUNE, I18N_UCALENDAR_JULY, I18N_UCALENDAR_AUGUST, I18N_UCALENDAR_SEPTEMBER, I18N_UCALENDAR_OCTOBER, I18N_UCALENDAR_NOVEMBER, I18N_UCALENDAR_DECEMBER |
[in] | date | The desired day of the month. |
I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
int i18n_ucalendar_set_date_time | ( | i18n_ucalendar_h | calendar, |
int32_t | year, | ||
int32_t | month, | ||
int32_t | date, | ||
int32_t | hour, | ||
int32_t | min, | ||
int32_t | sec | ||
) |
Sets a calendar's current date.
The date is represented as a series of 32-bit integers.
[in] | calendar | The i18n_ucalendar_h to set |
[in] | year | The desired year |
[in] | month | The desired month One of I18N_UCALENDAR_JANUARY, I18N_UCALENDAR_FEBRUARY, I18N_UCALENDAR_MARCH, I18N_UCALENDAR_APRIL, I18N_UCALENDAR_MAY, I18N_UCALENDAR_JUNE, I18N_UCALENDAR_JULY, I18N_UCALENDAR_AUGUST, I18N_UCALENDAR_SEPTEMBER, I18N_UCALENDAR_OCTOBER, I18N_UCALENDAR_NOVEMBER, or I18N_UCALENDAR_DECEMBER |
[in] | date | The desired day of the month |
[in] | hour | The desired hour of the day |
[in] | min | The desired minute |
[in] | sec | The desired second |
I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
int i18n_ucalendar_set_default_timezone | ( | const i18n_uchar * | zone_id | ) |
Sets the default time zone.
[in] | zone_id | null-terminated time zone ID |
I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
int i18n_ucalendar_set_gregorian_change | ( | i18n_ucalendar_h | calendar, |
i18n_udate | date | ||
) |
Sets the Gregorian Calendar change date.
This is the point when the switch from Julian dates to Gregorian dates occurred. Default is 00:00:00 local time, October 15, 1582. Previous to this time and date will be Julian dates. This function works only for Gregorian calendars. If the i18n_ucalendar_h is not an instance of a Gregorian calendar, then a I18N_ERROR_NOT_SUPPORTED error code is set.
[in] | calendar | The calendar object. |
[in] | date | The given Gregorian cutover date. |
I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
int i18n_ucalendar_set_milliseconds | ( | i18n_ucalendar_h | calendar, |
i18n_udate | milliseconds | ||
) |
Sets a calendar's current time in milliseconds.
The time is represented as milliseconds from the epoch.
[in] | calendar | The i18n_ucalendar_h to set |
[in] | milliseconds | The desired date and time |
I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
int i18n_ucalendar_set_timezone | ( | i18n_ucalendar_h | calendar, |
const i18n_uchar * | zone_id, | ||
int32_t | length | ||
) |
Sets the TimeZone used by a i18n_ucalendar_h.
A i18n_ucalendar_h uses a timezone for converting from Greenwich time to local time.
[in] | calendar | The i18n_ucalendar_h to set. |
[in] | zone_id | The desired TimeZone ID. If NULL, use the default time zone. |
[in] | length | The length of zone_id , or -1 if NULL-terminated. |
I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
int i18n_ucalendar_timezone_id_enumeration_create | ( | i18n_system_timezone_type_e | zone_type, |
const char * | region, | ||
const int32_t * | raw_offset, | ||
i18n_uenumeration_h * | enumeration | ||
) |
Creates an enumeration over system time zone IDs with the given filter conditions.
[in] | zone_type | The system time zone type. |
[in] | region | The ISO 3166 two-letter country code or UN M.49 three-digit area code. When NULL , no filtering done by region. |
[in] | raw_offset | An offset from GMT in milliseconds, ignoring the effect of daylight savings time, if any. When NULL , no filtering done by zone offset. |
[out] | enumeration | A Pointer to the enumeration object that the caller must dispose of using i18n_uenumeration_destroy(), orNULL upon failure. |
I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |
int i18n_ucalendar_timezones_create | ( | i18n_uenumeration_h * | enumeration | ) |
Creates an enumeration over all time zones.
[out] | enumeration | A pointer to the enumeration object that the caller must dispose of using i18n_uenumeration_destroy(), or NULL upon failure. |
I18N_ERROR_NONE | Successful |
I18N_ERROR_INVALID_PARAMETER | Invalid function parameter |