}
/* Release the time zone object. */
+ ret = i18n_udatepg_destroy(udatepg);
+ CHECK_ERROR("i18n_udatepg_destroy", ret);
ret = i18n_timezone_destroy(tmz);
CHECK_ERROR("i18n_timezone_destroy", ret);
free(timezone_id);
printf(" - To get time zone information\n");
static i18n_timezone_h tmz;
+ i18n_uchar default_timezone_id[BUF_SIZE] = {0, };
if (!timezone_id) {
/* Get the default timezone. */
PRINT_ASCIIDOC_LOG("|===\n");
printf("| KEY | VALUE\n");
- /* Get the display name of the default timezone. */
+ /* Get the display name of the default or selected timezone. */
char *display_name;
ret = i18n_timezone_get_display_name(tmz, &display_name);
CHECK_ERROR("i18n_timezone_get_display_name", ret);
printf("| Current timezone | %s\n", display_name);
+ /* Get the current time of the default or selected timezone. */
+ i18n_udate date_now;
+ ret = i18n_ucalendar_get_now(&date_now);
+ CHECK_ERROR("i18n_ucalendar_get_now", ret);
+ PRINT_DEBUG_LOG("i18n_ucalendar_get_now = %lf\n", date_now);
+
+ i18n_udate_format_h format_h = NULL;
+ i18n_udatepg_h udatepg;
+ ret = i18n_udatepg_create("ko_KR", &udatepg);
+ CHECK_ERROR("i18n_udatepg_create", ret);
+
+ i18n_uchar format[BUF_SIZE] = {0, };
+ i18n_ustring_copy_ua_n(format, "ddMMMyyyyHHmmssz", BUF_SIZE);
+
+ int pattern_len = 0, len = 0;
+ i18n_uchar pattern[BUF_SIZE] = {0, }, skeleton[BUF_SIZE] = {0, };
+ i18n_ustring_copy_ua(skeleton, I18N_UDATE_MONTH_DAY);
+ len = i18n_ustring_get_length(skeleton);
+ ret = i18n_udatepg_get_best_pattern(udatepg, skeleton, len, pattern, BUF_SIZE, &pattern_len);
+ CHECK_ERROR("i18n_udatepg_get_best_pattern", ret);
+
+ i18n_ustring_copy_ua(default_timezone_id, timezone_id);
+ ret = i18n_udate_create(I18N_UDATE_FULL, I18N_UDATE_FULL, default_locale, default_timezone_id, -1, pattern, -1, &format_h);
+ CHECK_ERROR("i18n_udate_create", ret);
+
+ i18n_uchar result[BUF_SIZE] = {0, };
+ int date_len = 0;
+ ret = i18n_udate_format_date(format_h, date_now, result, BUF_SIZE, NULL, &date_len);
+ CHECK_ERROR("i18n_udate_format_date", ret);
+
+ char s[BUF_SIZE] = {0, };
+ i18n_ustring_copy_au(s, result);
+ free(result);
+ printf("| Current time | %s\n", s);
+
/* Get the selected timezone ID. */
ret = i18n_timezone_get_id(tmz, &timezone_id);
CHECK_ERROR("i18n_timezone_get_id", ret);
PRINT_ASCIIDOC_LOG("|===\n");
/* Release the time zone object. */
+ ret = i18n_udatepg_destroy(udatepg);
+ CHECK_ERROR("i18n_udatepg_destroy", ret);
ret = i18n_timezone_destroy(tmz);
CHECK_ERROR("i18n_timezone_destroy", ret);
free(timezone_id);