[i18ninfo] Add current time in timezone info menu 54/169254/4 accepted/tizen/unified/20180219.055809 submit/tizen/20180219.005324
authorHyunjee Kim <hj0426.kim@samsung.com>
Mon, 5 Feb 2018 07:51:35 +0000 (16:51 +0900)
committerHyunjee Kim <hj0426.kim@samsung.com>
Mon, 12 Feb 2018 07:48:37 +0000 (16:48 +0900)
Change-Id: Idce04063adad461634f2e928bc017a3437ae049e
Signed-off-by: Hyunjee Kim <hj0426.kim@samsung.com>
i18ninfo/i18ninfo.cpp

index b48b3e3..bbeca69 100644 (file)
@@ -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);