Tizen Native API
|
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) |
Open a copy of a i18n_ucalendar. 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 an i18n_ucalendar_h'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 an i18n_ucalendar_h's current time in milliseconds. | |
int | i18n_ucalendar_set_milliseconds (i18n_ucalendar_h calendar, i18n_udate milliseconds) |
Sets an i18n_ucalendar_h'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 an i18n_ucalendar_h'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_hs 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. |
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' i18n_ustring_get_length(_tzid, &len); // 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);
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 |
Field count |
I18N_UCALENDAR_DAY_OF_MONTH |
Field number indicating the day of the month. |
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 |
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, I18N_UCALENDAR_ZONE_OFFSET, or I18N_UCALENDAR_DST_OFFSET. |
[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_clone | ( | const i18n_ucalendar_h | cal, |
i18n_ucalendar_h * | identical_to_cal | ||
) |
Open a copy of a i18n_ucalendar. 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 |
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 |
[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 |
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 |
int i18n_ucalendar_get_milliseconds | ( | const i18n_ucalendar_h | calendar, |
i18n_udate * | date | ||
) |
Gets an i18n_ucalendar_h'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 an i18n_ucalendar_h'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 |
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_hs are equivalent.
Equivalent i18n_ucalendar_hs will behave identically, but they may be set to different times.
[in] | calendar1 | The first of the i18n_ucalendar_hs to compare |
[in] | calendar2 | The second of the i18n_ucalendar_hs 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 |
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 to set. |
[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 set. |
[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_time | ( | i18n_ucalendar_h | calendar, |
int32_t | year, | ||
int32_t | month, | ||
int32_t | date, | ||
int32_t | hour, | ||
int32_t | min, | ||
int32_t | sec | ||
) |
Sets an i18n_ucalendar_h'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 |
int i18n_ucalendar_set_milliseconds | ( | i18n_ucalendar_h | calendar, |
i18n_udate | milliseconds | ||
) |
Sets an i18n_ucalendar_h'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 |