From: Hyunjee Kim Date: Mon, 5 Feb 2018 07:51:35 +0000 (+0900) Subject: [i18ninfo] Add current time in timezone info menu X-Git-Tag: accepted/tizen/unified/20180219.055809^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=64aa4e66e9d78c42d788346f20957f183b1f3687;p=platform%2Fcore%2Fapi%2Fbase-utils.git [i18ninfo] Add current time in timezone info menu Change-Id: Idce04063adad461634f2e928bc017a3437ae049e Signed-off-by: Hyunjee Kim --- diff --git a/i18ninfo/i18ninfo.cpp b/i18ninfo/i18ninfo.cpp index b48b3e3..bbeca69 100644 --- a/i18ninfo/i18ninfo.cpp +++ b/i18ninfo/i18ninfo.cpp @@ -569,6 +569,8 @@ static int __get_date_and_time(char *input_time) } /* 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); @@ -921,6 +923,7 @@ static int __get_timezone_info(char *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. */ @@ -941,12 +944,47 @@ static int __get_timezone_info(char *timezone_id) 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); @@ -986,6 +1024,8 @@ static int __get_timezone_info(char *timezone_id) 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);