return 0;
}
-static int __get_timezone_info()
+bool timezone_cb(const char *timezone_id, void *user_data)
+{
+ printf("%s\n", timezone_id);
+ return true;
+}
+
+static int __get_available_timezone()
{
int ret = 0;
- printf(" - To get time zone information\n");
+ printf(" - To get the list of time zone");
printf("****************************************\n");
+ ret = i18n_timezone_foreach_timezone_id(timezone_cb, NULL);
+ CHECK_ERROR("i18n_timezone_foreach_timezone_id", ret);
+
+ return 0;
+}
+
+static int __get_timezone_info(char *timezone_id)
+{
+ int ret = 0;
+ printf(" - To get time zone information\n");
+
static i18n_timezone_h tmz;
+ if (!timezone_id) {
+ /* Get the default timezone. */
+ ret = i18n_timezone_create_default(&tmz);
+ CHECK_ERROR("18n_timezone_create_default", ret);
+ ret = i18n_timezone_get_id(tmz, &timezone_id);
+ CHECK_ERROR("i18n_timezone_get_id", ret);
+ printf(" - Default timezone Id : %s\n", timezone_id);
+ } else {
+ ret = i18n_timezone_create(&tmz, timezone_id);
+ CHECK_ERROR("18n_timezone_create", ret);
+ printf(" - Input timezone Id : %s\n", timezone_id);
+ }
+
+ printf("****************************************\n");
+
PRINT_ASCIIDOC_LOG("\n[options=\"header\"]\n");
PRINT_ASCIIDOC_LOG("|===\n");
printf("| KEY | VALUE\n");
- /* Get the default timezone. */
- ret = i18n_timezone_create_default(&tmz);
- CHECK_ERROR("18n_timezone_create_default", ret);
-
/* Get the display name of the default timezone. */
char *display_name;
ret = i18n_timezone_get_display_name(tmz, &display_name);
printf("| Current timezone | %s\n", display_name);
/* Get the selected timezone ID. */
- char *timezone_id;
ret = i18n_timezone_get_id(tmz, &timezone_id);
CHECK_ERROR("i18n_timezone_get_id", ret);
printf("| Timezone ID | %s\n", timezone_id);
printf("\n");
printf("\n== Timezone Info");
printf("\n****************************************\n");
- ret = __get_timezone_info();
+ ret = __get_timezone_info(NULL);
printf("\n");
printf("\n== TZ Data Version Info");
}
}
-void showTimezone()
+void showTimezone(char *timezone_id)
{
int ret = 0;
printf("\n== Timezone Info");
printf("\n****************************************\n");
- ret = __get_timezone_info();
+ ret = __get_timezone_info(timezone_id);
if (ret == -1) {
printf("get i18n time zone info list failed\n");
}
}
+void showAllTimezone()
+{
+
+ int ret = 0;
+ printf("\n== List of Timezone");
+ printf("\n****************************************\n");
+ ret = __get_available_timezone();
+ if (ret != 0) {
+ printf("get the list of time zone failed\n");
+ }
+}
+
void showTzdataVersion()
{
printf("\n== TZ Data Version Info");
}
if (arguments.showTimezone) {
- showTimezone();
+ showTimezone(arguments.timezoneId);
+ }
+
+ if (arguments.showAllTimezone) {
+ showAllTimezone();
}
if (arguments.showTzdataVersion) {
{"all", 'a', 0, 0, "Show all information and test" , 0 },
{"show-all-locale", 'L', 0, 0, "Show all supported locales list", 0 },
{"show-lang-info", 'I', 0, 0, "Show language information", 0 },
- {"show-timezone", 'T', 0, 0, "Show timezone", 0 },
+ {"show-all-timezone", 'T', 0, 0, "Show all supported timezone list", 0 },
+ {"show-timezone", 't', "TimezoneId", OPTION_ARG_OPTIONAL, "Show timezone", 0 },
{"show-tzdata-version", 'Z', 0, 0, "Show tzdata version", 0 },
{"show-date-format", 'D', 0, 0, "Show Date basic format", 0 },
{"test-datentime", 'd', "DateTime", OPTION_ARG_OPTIONAL, "Date and time format test", 0 },
int showAllLocale;
int showLangInfo;
int showTimezone;
+ int showAllTimezone;
int showTzdataVersion;
int showDateFormat;
int testDatentime;
char *testNumberConvertArg;
char *testInputNumArg;
#endif
+ char *timezoneId;
};
/* Parse a single option. */
arguments->arg_flag = 3;
arguments->showLangInfo = 1;
break;
- case 'T':
+ case 't':
arguments->arg_flag = 4;
arguments->showTimezone = 1;
+
+ nextArg = state->argv[state->next];
+ if (nextArg && *nextArg != '-') {
+ arguments->timezoneId = nextArg;
+ state->next++;
+ }
+
break;
case 'Z':
arguments->arg_flag = 5;
#endif
+ case 'T':
+ arguments->arg_flag = 15;
+ arguments->showAllTimezone = 1;
+ break;
+
case ARGP_KEY_NO_ARGS:
if (arguments->arg_flag == 0) {
argp_usage(state);