#include <stddef.h>
#include <string.h>
#include <assert.h>
+#include <time.h>
#include "i18ninfo_argp.h"
#include <utils_i18n.h>
#define DEBUG_FLAG 0
+static int ASCIIDOC_FLAG = 0;
#define BUF_SIZE 64
#define MS_TO_MIN 60000
(dst)[(dst_len) - 1] = '\0'; \
} while (0)
+#define PRINT_ASCIIDOC_LOG(fmt) if (ASCIIDOC_FLAG) printf(fmt)
char *default_locale = I18N_ULOCALE_UK;
i18n_uchar default_timezone_id[BUF_SIZE] = {0,};
static void __get_available_locales();
-static int __get_date_and_time();
+static int __get_date_basic_format();
+static int __get_date_and_time(char *input_time);
static int __get_number_format(char *input_number);
static int __get_symbol();
static int __get_language_info();
}
}
+static void init_env()
+{
+
+ char *env_buf;
+
+ env_buf = getenv("ASCIIDOC_FLAG");
+ if (env_buf != NULL && strcmp(env_buf, "true") == 0) {
+ ASCIIDOC_FLAG = 1;
+ }
+}
+
char *__print_i18n_type_string(char *type, int num)
{
char *str = calloc(300, sizeof(char));
return str;
}
-static int __get_date_and_time()
+static const char *_date_basic_format_convert(char *input_pattern, int i, char *type)
+{
+ i18n_udate_format_h format_h = NULL;
+ i18n_uchar timezone[BUF_SIZE] = {0,};
+ i18n_ustring_copy_ua_n(timezone, default_locale, BUF_SIZE);
+ i18n_uchar pattern[BUF_SIZE] = {0,};
+ i18n_ustring_copy_ua_n(pattern, input_pattern, BUF_SIZE);
+ error_code = i18n_udate_create(I18N_UDATE_PATTERN, I18N_UDATE_PATTERN, default_locale, timezone, -1, pattern, -1, &format_h);
+
+ i18n_udate date_now = 259200000;
+
+ if (type == "day") date_now += i * 86400000;
+ else if (type == "month") {
+ int k;
+ for (k = 0; k < i; k++)
+ date_now += 2678400000;
+ } else {
+ i18n_ucalendar_get_now(&date_now);
+ }
+
+ i18n_uchar *result = (i18n_uchar *) malloc(BUF_SIZE * sizeof(i18n_uchar));
+ int date_len = 0;
+ error_code = i18n_udate_format_date(format_h, date_now, result, BUF_SIZE, NULL, &date_len);
+
+ char *s = (char *)malloc(BUF_SIZE * sizeof(char));
+ i18n_ustring_copy_au(s, result);
+ i18n_udate_destroy(format_h);
+ free(result);
+
+ PRINT_DEBUG_LOG("======%s\n", s);
+ return s;
+}
+
+static int __get_date_basic_format()
{
- printf(" * To get various date and time format\n");
+ printf(" - To get basic date format\n");
+ printf("****************************************\n");
+
+ char *f_narrow, *f_short, *f_long, *s_narrow, *s_short, *s_long;
+ int i;
+
+ //Day - Formatting
+ printf(" Day - Formatting\n");
+ PRINT_ASCIIDOC_LOG("\n[options=\"header\"]\n");
+ PRINT_ASCIIDOC_LOG("|===\n");
+ printf("| # | %-11.11s | %-11.11s | %s \n", "Narrow Names" , "Short Names" , "Long Names");
+ for (i = 0; i < 7; i++) {
+ f_narrow = _date_basic_format_convert("EEEEE", i, "day");
+ f_short = _date_basic_format_convert("EEE", i, "day");
+ f_long = _date_basic_format_convert("EEEE", i, "day");
+
+ printf("| %d | %-11.1s | %-11.3s | %s\n", i, f_narrow, f_short, f_long);
+ }
+ PRINT_ASCIIDOC_LOG("|===\n");
+
+ //Day - stand-alone
+ printf(" Day - Stand-alone\n");
+ PRINT_ASCIIDOC_LOG("\n[options=\"header\"]\n");
+ PRINT_ASCIIDOC_LOG("|===\n");
+ printf("| # | %-11.11s | %-11.11s | %s \n", "Narrow Names" , "Short Names" , "Long Names");
+ for (i = 0; i < 7; i++) {
+ s_narrow = _date_basic_format_convert("ccccc", i, "day");
+ s_short = _date_basic_format_convert("ccc", i, "day");
+ s_long = _date_basic_format_convert("cccc", i, "day");
+
+ printf("| %d | %-11.1s | %-11.3s | %s\n", i, s_narrow, s_short, s_long);
+ }
+ PRINT_ASCIIDOC_LOG("|===\n");
+
+ //Month - Formatting
+ printf(" Month - Formatting\n");
+ PRINT_ASCIIDOC_LOG("\n[options=\"header\"]\n");
+ PRINT_ASCIIDOC_LOG("|===\n");
+ printf("| # | %-11.11s | %-11.11s | %s \n", "Narrow Names" , "Short Names" , "Long Names");
+ for (i = 0; i < 12; i++) {
+ f_narrow = _date_basic_format_convert("MMMMM", i, "month");
+ f_short = _date_basic_format_convert("MMM", i, "month");
+ f_long = _date_basic_format_convert("MMMM", i, "month");
+
+ printf("| %-2d | %-11.11s | %-11.11s | %-11.11s\n", i, f_narrow, f_short, f_long);
+ }
+ PRINT_ASCIIDOC_LOG("|===\n");
+
+ //Month - stand-alone
+ printf(" Month - Stand-alone\n");
+ PRINT_ASCIIDOC_LOG("\n[options=\"header\"]\n");
+ PRINT_ASCIIDOC_LOG("|===\n");
+ printf("| # | %-11.11s | %-11.11s | %s \n", "Narrow Names" , "Short Names" , "Long Names");
+
+ for (i = 0; i < 12; i++) {
+ s_narrow = _date_basic_format_convert("LLLLL", i, "month");
+ s_short = _date_basic_format_convert("LLL", i, "month");
+ s_long = _date_basic_format_convert("LLLL", i, "month");
+
+ printf("| %-2d | %-11.1s | %-11.3s | %s\n", i, s_narrow, s_short, s_long);
+ }
+ PRINT_ASCIIDOC_LOG("|===\n");
+
+ return 0;
+}
+
+i18n_udate _time_convert(char *input_time)
+{
+ long long int lli;
+ i18n_ucalendar_h ucal;
+ i18n_udate date;
+ int ret = I18N_ERROR_NONE;
+ int year, month, day, hour, minute, second;
+ struct tm result;
+
+ strptime(input_time, "%Y%m%d%H%M%S", &result);
+ if (result.tm_year >= 100)
+ result.tm_year = result.tm_year%100 + 2000;
+ PRINT_DEBUG_LOG("Date from strptime, year:%d month:%d day:%d hour:%d minute:%d second:%d.\n", result.tm_year, result.tm_mon+1, result.tm_mday, result.tm_hour, result.tm_min, result.tm_sec);
+
+ /*create i18n_ucalendar_h */
+ ret = i18n_ucalendar_create(0, -1, "en_US", I18N_UCALENDAR_DEFAULT, &ucal);
+ if (ret) {
+ printf("i18n_ucalendar_create failed.\n");
+ return -1;
+ }
+
+ /*set i18n_ucalendar_h's date */
+ i18n_ucalendar_set_date_time(ucal, result.tm_year, result.tm_mon, result.tm_mday, result.tm_hour, result.tm_min, result.tm_sec);
+ 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);
+ PRINT_DEBUG_LOG("Date from ucal, year:%d month:%d day:%d hour:%d minute:%d second:%d.\n", year, month, day, hour, minute, second);
+ /* get i18n_ucalendar's current time and converts it from milliseconds to seconds */
+ i18n_ucalendar_get_milliseconds(ucal, &date);
+
+ /* destroy i18n_ucalendar_h */
+ i18n_ucalendar_destroy(ucal);
+
+ return date;
+}
+
+static int __get_date_and_time(char *input_time)
+{
+ printf(" - To get various date and time format\n");
+ printf("****************************************\n");
i18n_udate date_now;
- i18n_udate_format_h format_h = NULL;
- int error_code = i18n_ucalendar_get_now(&date_now);
- PRINT_DEBUG_LOG("i18n_ucalendar_get_now = %lf\n", date_now);
+ if (!input_time) {
+ int error_code = i18n_ucalendar_get_now(&date_now);
+ PRINT_DEBUG_LOG("i18n_ucalendar_get_now = %lf\n", date_now);
+ } else {
+ date_now = _time_convert(input_time);
+ PRINT_DEBUG_LOG("_time_convert = %lf\n", date_now);
+ }
+ i18n_udate_format_h format_h = NULL;
i18n_udatepg_h udatepg;
error_code = i18n_udatepg_create(default_locale, &udatepg);
CHECK_ERROR("i18n_udatepg_create", error_code);
int pattern_len;
i18n_uchar pattern[BUF_SIZE];
- error_code = i18n_udatepg_get_best_pattern(udatepg, I18N_UDATE_MONTH_DAY, BUF_SIZE, pattern, BUF_SIZE,
- &pattern_len);
+ error_code = i18n_udatepg_get_best_pattern(udatepg, I18N_UDATE_MONTH_DAY, BUF_SIZE, pattern, BUF_SIZE, &pattern_len);
CHECK_ERROR("i18n_udatepg_get_best_pattern", error_code);
- printf(" * TIME TYPE X DATE TYPE : OUTPUT\n");
+ PRINT_ASCIIDOC_LOG("\n[options=\"header\"]\n");
+ PRINT_ASCIIDOC_LOG("|===\n");
+ printf("| %-17.17s | %-26.26s | %s \n", "TIME TYPE" , "DATE TYPE" , "OUTPUT");
for (n_enum_date_counter = 0; n_enum_date_counter < n_date_enum_size; n_enum_date_counter++) {
for (n_enum_time_counter = 0; n_enum_time_counter < n_time_enum_size; n_enum_time_counter++) {
i18n_ustring_copy_ua_n(default_timezone_id, default_locale, BUF_SIZE);
error_code = i18n_udate_create(eTimeFormatStyle[n_enum_time_counter],
- eDateFormatStyle[n_enum_date_counter],
- default_locale, default_timezone_id, -1, pattern, -1, &format_h);
+ eDateFormatStyle[n_enum_date_counter],
+ default_locale, default_timezone_id, -1, pattern, -1, &format_h);
CHECK_ERROR("i18n_udate_create", error_code);
i18n_uchar *result = (i18n_uchar *) malloc(BUF_SIZE * sizeof(i18n_uchar));
char s[BUF_SIZE];
i18n_ustring_copy_au(s, result);
free(result);
+
char *time_str, *date_str;
time_str = __print_i18n_type_string("time", n_enum_time_counter);
date_str = __print_i18n_type_string("date", n_enum_date_counter);
- printf("TIME[%-17.17s] DATE[%-26.26s] : %s\n", time_str, date_str, s);
+ printf("| %-17.17s | %-26.26s | %s\n", time_str, date_str, s);
free(time_str);
free(date_str);
}
}
+
+ PRINT_ASCIIDOC_LOG("|===\n");
return 0;
}
static int __get_number_format(char *input_number)
{
- printf(" * To get various number format\n");
+ printf(" - To get various number format\n");
+ printf("****************************************\n");
double my_number = atof(input_number);
PRINT_DEBUG_LOG("Input number = %f\n", my_number);
i18n_unumber_format_h num_format = NULL;
i18n_uchar formatted_number[BUF_SIZE];
+ PRINT_ASCIIDOC_LOG("\n[options=\"header\"]\n");
+ PRINT_ASCIIDOC_LOG("|===\n");
+ printf("| %-30.30s | %s\n", "NUMBER FORMAT" , "OUTPUT");
+
int i;
for (i = I18N_UNUMBER_DECIMAL; i <= I18N_UNUMBER_FORMAT_STYLE_COUNT; ++i) {
/* Create a number formatter. */
char *number_str;
number_str = __print_i18n_type_string("number_format", i);
- printf("NUMBER_FORMAT[%-30.30s] : %s\n", number_str, string);
+ printf("| %-30.30s | %s\n", number_str, string);
free(number_str);
}
+ PRINT_ASCIIDOC_LOG("|===\n");
/* Release the decimal number formatter. */
error_code = i18n_unumber_destroy(num_format);
static int __get_symbol()
{
- printf(" * To get various number symbol\n");
+ printf(" - To get various number symbol\n");
+ printf("****************************************\n");
/* Create a default number formatter. */
i18n_unumber_format_h num_format = NULL;
CHECK_ERROR("18n_unumber_create", error_code);
int i;
+
+ PRINT_ASCIIDOC_LOG("\n[options=\"header\"]\n");
+ PRINT_ASCIIDOC_LOG("|===\n");
+ printf("| %-47.47s | %s\n", "NUMBER SYMBOL" , "OUTPUT");
for (i = 0; i < I18N_UNUMBER_FORMAT_SYMBOL_COUNT; ++i) {
/* Format the selected symbol according to the chosen locale. */
int buf_len;
char *symbol_str;
symbol_str = __print_i18n_type_string("symbol", i+1);
- printf("SYMBOL[%-47.47s] : %s\n", symbol_str, string);
+ printf("| %-47.47s | %s\n", symbol_str, string);
free(symbol_str);
}
+ PRINT_ASCIIDOC_LOG("|===\n");
/* Release the default number formatter object. */
error_code = i18n_unumber_destroy(num_format);
static int __get_language_info()
{
- printf(" * To get language information\n");
+ printf(" - To get language information\n");
+ printf("****************************************\n");
i18n_uchar lang[BUF_SIZE];
+ PRINT_ASCIIDOC_LOG("\n[options=\"header\"]\n");
+ PRINT_ASCIIDOC_LOG("|===\n");
+ printf("| KEY | VALUE\n");
+
/* Get the default locale code */
- printf("Default locale code : %s\n", default_locale);
+ printf("| Default locale code | %s\n", default_locale);
/* Get the display name of the selected locale. */
i18n_uchar name[BUF_SIZE];
int name_len;
int error_code =
- i18n_ulocale_get_display_name(default_locale, default_locale, name, BUF_SIZE, &name_len);
+ i18n_ulocale_get_display_name(default_locale, default_locale, name, BUF_SIZE, &name_len);
CHECK_ERROR("i18n_ulocale_get_display_name", error_code);
char name_ch[BUF_SIZE];
i18n_ustring_copy_au(name_ch, name);
- printf("Language display name : %s\n", name_ch);
+ printf("| Language display name | %s\n", name_ch);
/* Get the language related to the selected locale. */
/* Get the string representation of the obtained language. */
char language[BUF_SIZE];
i18n_ustring_copy_au(language, lang);
- printf("Full name : %s\n", language);
+ printf("| Full name | %s\n", language);
/* Get the obtained language code. */
int32_t lang_len;
error_code = i18n_ulocale_get_language(default_locale, language, BUF_SIZE, &lang_len);
CHECK_ERROR("i18n_ulocale_get_language", error_code);
- printf("language code : %s\n", language);
+ printf("| language code | %s\n", language);
/* Get the ISO code of the selected locale. */
const char *language_iso = i18n_ulocale_get_iso3_language(default_locale);
- printf("ISO code : %s\n", language_iso);
+ printf("| ISO code | %s\n", language_iso);
/* Get the type of the line orientation related to the selected locale. */
i18n_ulocale_layout_type_e type;
error_code = i18n_ulocale_get_line_orientation(default_locale, &type);
CHECK_ERROR("i18n_ulocale_get_line_orientation", error_code);
const char *orientation = layout_orientation_converter(type);
- printf("Line orientation : %s\n", orientation);
+ printf("| Line orientation | %s\n", orientation);
/* Get the characters orientation related to the selected locale. */
error_code = i18n_ulocale_get_character_orientation(default_locale, &type);
CHECK_ERROR("i18n_ulocale_get_character_orientation", error_code);
orientation = layout_orientation_converter(type);
- printf("Characters orientation : %s\n", orientation);
+ printf("| Characters orientation | %s\n", orientation);
/* Get the variant code related to the selected locale. */
char variant[BUF_SIZE];
error_code = i18n_ulocale_get_variant(default_locale, variant, BUF_SIZE);
CHECK_ERROR("i18n_ulocale_get_variant", error_code);
- printf("variant code: %s\n", variant);
+ printf("| variant code | %s\n", variant);
+ PRINT_ASCIIDOC_LOG("|===\n");
return 0;
}
static int __manage_string_iteration(char *input_string)
{
- printf(" * To manage the string iteration\n");
+ printf(" - To manage the string iteration\n");
+ printf("****************************************\n");
PRINT_DEBUG_LOG("Input string : %s\n", input_string);
i18n_uchar *string_to_examine;
if (!input_string) {
char *input_text = "Twinkle, twinkle, little star.\ How I wonder what you are";
- printf("Input string : %s\n", input_text);
+ printf("\nInput string : %s\n", input_text);
string_to_examine =
- (i18n_uchar *) malloc(sizeof(i18n_uchar) * (strlen(input_text) + 1));
+ (i18n_uchar *) malloc(sizeof(i18n_uchar) * (strlen(input_text) + 1));
i18n_ustring_copy_ua(string_to_examine, input_text);
} else {
char input_text[1000] = {0,};
COPY_STR(input_text, input_string, 999);
printf("Input string : %s\n", input_text);
string_to_examine =
- (i18n_uchar *) malloc(sizeof(i18n_uchar) * (strlen(input_text) + 1));
+ (i18n_uchar *) malloc(sizeof(i18n_uchar) * (strlen(input_text) + 1));
i18n_ustring_copy_ua(string_to_examine, input_text);
}
int i;
char *iter_type;
+ PRINT_ASCIIDOC_LOG("\n[options=\"header\"]\n");
+ PRINT_ASCIIDOC_LOG("|===\n");
+ printf("| %-19.19s | %s\n", "ITER First", "VALUE");
+
/* Displays the first element in the given text */
for (i = 0; i <= I18N_UBRK_SENTENCE; i++) {
error_code = i18n_ubrk_create(i, default_locale, string_to_examine, -1, &boundary);
free(result);
iter_type = __print_i18n_type_string("iter_type", i);
- printf("ITER First element[%-19.19s] : %s\n", iter_type, str);
+ printf("| %-19.19s | %s\n", iter_type, str);
}
+ PRINT_ASCIIDOC_LOG("|===\n");
+ printf("\n");
+ PRINT_ASCIIDOC_LOG("\n[options=\"header\"]\n");
+ PRINT_ASCIIDOC_LOG("|===\n");
+ printf("| %-19.19s | %s\n", "ITER Last", "VALUE");
/* Displays the last element in the given text */
for (i = 0; i <= I18N_UBRK_SENTENCE; i++) {
error_code = i18n_ubrk_create(i, default_locale, string_to_examine, -1, &boundary);
free(result);
iter_type = __print_i18n_type_string("iter_type", i);
- printf("ITER Last element[%-19.19s] : %s\n", iter_type, str);
+ printf("| %-19.19s | %s\n", iter_type, str);
}
+ PRINT_ASCIIDOC_LOG("|===\n");
free(iter_type);
free(string_to_examine);
static int __analyze_string(char *custom_string)
{
- printf(" * To manage the string\n");
+ printf(" - To manage the string\n");
+ printf("****************************************\n");
i18n_uchar *string_to_examine;
if (!custom_string) {
char *input_text = "String";
- printf("Input string : %s\n", input_text);
+ printf("\n Input string : %s\n", input_text);
string_to_examine =
- (i18n_uchar *) malloc(sizeof(i18n_uchar) * (strlen(input_text) + 1));
+ (i18n_uchar *) malloc(sizeof(i18n_uchar) * (strlen(input_text) + 1));
i18n_ustring_copy_ua(string_to_examine, input_text);
} else {
char *input_text = custom_string;
- printf("Input string : %s\n", input_text);
+ printf("\n Input string : %s\n", input_text);
string_to_examine =
- (i18n_uchar *) malloc(sizeof(i18n_uchar) * (strlen(input_text) + 1));
+ (i18n_uchar *) malloc(sizeof(i18n_uchar) * (strlen(input_text) + 1));
i18n_ustring_copy_ua(string_to_examine, input_text);
}
int i;
+ PRINT_ASCIIDOC_LOG("\n[options=\"header\"]\n");
+ PRINT_ASCIIDOC_LOG("|===\n");
+ printf("| KEY | VALUE\n");
+
/* Get length */
int32_t len = i18n_ustring_get_length(string_to_examine);
- printf("Length : %d\n", len);
+ printf("| Length | %d\n", len);
/* To upper */
i18n_uchar dest[BUF_SIZE + 1];
char s[BUF_SIZE];
i18n_ustring_copy_au(s, dest);
- printf("TO UPPER : %s\n", s);
+ printf("| TO UPPER | %s\n", s);
/* To lower */
i18n_ustring_to_lower(dest, BUF_SIZE + 1, string_to_examine, BUF_SIZE, NULL, &error_code);
CHECK_ERROR("i18n_ustring_to_lower", error_code);
i18n_ustring_copy_au(s, dest);
- printf("to lower : %s\n", s);
+ printf("| to lower | %s\n", s);
/* To title */
i18n_ustring_to_title_new(dest, BUF_SIZE + 1, string_to_examine, BUF_SIZE, NULL, &error_code);
CHECK_ERROR("i18n_ustring_to_title_new", error_code);
i18n_ustring_copy_au(s, dest);
- printf("To Title : %s\n", s);
+ printf("| To Title | %s\n", s);
+
+ PRINT_ASCIIDOC_LOG("|===\n");
return 0;
}
static int __get_timezone_info()
{
- printf(" * To get time zone information\n");
+ printf(" - To get time zone information\n");
+ printf("****************************************\n");
static i18n_timezone_h tmz;
+ PRINT_ASCIIDOC_LOG("\n[options=\"header\"]\n");
+ PRINT_ASCIIDOC_LOG("|===\n");
+ printf("| KEY | VALUE\n");
+
/* Get the default timezone. */
error_code = i18n_timezone_create_default(&tmz);
CHECK_ERROR("18n_timezone_create_default", error_code);
char *display_name;
error_code = i18n_timezone_get_display_name(tmz, &display_name);
CHECK_ERROR("i18n_timezone_get_display_name", error_code);
- printf("Current timezone : %s\n", display_name);
+ printf("| Current timezone | %s\n", display_name);
/* Get the selected timezone ID. */
char *timezone_id;
error_code = i18n_timezone_get_id(tmz, &timezone_id);
CHECK_ERROR("i18n_timezone_get_id", error_code);
- printf("Timezone ID : %s\n", timezone_id);
+ printf("| Timezone ID | %s\n", timezone_id);
/* Check whether the selected time zone uses daylight savings time or not. */
i18n_ubool daylight_time;
error_code = i18n_timezone_use_daylight_time(tmz, &daylight_time);
CHECK_ERROR("i18n_timezone_use_daylight_time", error_code);
- printf("Uses DST : %s\n", daylight_time ? "yes" : "no");
+ printf("| Uses DST | %s\n", daylight_time ? "yes" : "no");
/*
* Get the amount of time that need to be added to the
char ms[BUF_SIZE];
error_code = i18n_timezone_get_dst_savings(tmz, &dst_savings);
CHECK_ERROR("i18n_timezone_get_dst_savings", error_code);
- printf("DST savings in [min] : %d\n", dst_savings / MS_TO_MIN);
+ printf("| DST savings in [min] | %d\n", dst_savings / MS_TO_MIN);
/* Get the selected time zone raw GMT offset. */
int32_t offset_milliseconds;
error_code = i18n_timezone_get_raw_offset(tmz, &offset_milliseconds);
CHECK_ERROR("i18n_timezone_get_raw_offset", error_code);
if (offset_milliseconds / MS_TO_HOUR > 0)
- printf("Raw GMT offset : GMT +%d\n", offset_milliseconds / MS_TO_HOUR);
+ printf("| Raw GMT offset | GMT +%d\n", offset_milliseconds / MS_TO_HOUR);
else
- printf("Raw GMT offset : GMT %d\n", offset_milliseconds / MS_TO_HOUR);
+ printf("| Raw GMT offset | GMT %d\n", offset_milliseconds / MS_TO_HOUR);
/* Get the region code associated with the selected time zone. */
char region[BUF_SIZE];
int32_t region_len = -1;
error_code = i18n_timezone_get_region(timezone_id, region, ®ion_len, BUF_SIZE);
CHECK_ERROR("i18n_timezone_get_region", error_code);
- printf("Associated region code : %s\n", region);
+ printf("| Associated region code | %s\n", region);
+
+ PRINT_ASCIIDOC_LOG("|===\n");
/* Release the time zone object. */
error_code = i18n_timezone_destroy(tmz);
{
const char *ver = i18n_timezone_get_tzdata_version();
printf("tzdata version : %s\n", ver);
+ printf("****************************************\n");
return 0;
-
}
void allTest()
loc_count = i18n_ulocale_count_available();
for (i = 0; i < loc_count; i++) {
default_locale = i18n_ulocale_get_available(i);
- printf("\n * locales : %s\n", default_locale);
- ret = __get_date_and_time();
+ printf("\n== Date and Time Test");
+ printf("\n****************************************");
+ printf("\n - locales : %s\n", default_locale);
+ ret = __get_date_and_time(NULL);
printf("\n");
+ printf("\n== Number Format Test");
+ printf("\n****************************************");
+ printf("\n - locales : %s\n", default_locale);
ret = __get_number_format("3.5");
printf("\n");
+ printf("\n== Number Symbol Test");
+ printf("\n****************************************");
+ printf("\n - locales : %s\n", default_locale);
ret = __get_symbol();
printf("\n");
+ printf("\n== Language Info");
+ printf("\n****************************************");
+ printf("\n - locales : %s\n", default_locale);
ret = __get_language_info();
printf("\n");
}
+
+ printf("\n== String Iteration Test");
+ printf("\n****************************************\n");
ret = __manage_string_iteration(NULL);
printf("\n");
+
+ printf("\n== String Test");
+ printf("\n****************************************\n");
ret = __analyze_string(NULL);
printf("\n");
+ printf("\n== Timezone Info");
+ printf("\n****************************************\n");
ret = __get_timezone_info();
+ printf("\n");
+
+ printf("\n== TZ Data Version Info");
+ printf("\n****************************************\n");
ret = __get_tzdata_version();
if (ret == -1) {
printf("get i18n time zone info list failed\n");
loc_count = i18n_ulocale_count_available();
for (i = 0; i < loc_count; i++) {
default_locale = i18n_ulocale_get_available(i);
- printf("\n * locales : %s\n", default_locale);
+ printf("\n== Language Info");
+ printf("\n****************************************");
+ printf("\n - locales : %s\n", default_locale);
ret = __get_language_info();
}
if (ret == -1) {
}
} else {
default_locale = locale;
- printf("\n * locales : %s\n", default_locale);
+ printf("\n== Language Info");
+ printf("\n****************************************");
+ printf("\n - locales : %s\n", default_locale);
ret = __get_language_info();
if (ret == -1) {
printf("get i18n language info list failed\n");
void showTimezone()
{
int ret = 0;
+ printf("\n== Timezone Info");
+ printf("\n****************************************\n");
ret = __get_timezone_info();
if (ret == -1) {
printf("get i18n time zone info list failed\n");
void showTzdataVersion()
{
+ printf("\n== TZ Data Version Info");
+ printf("\n****************************************\n");
__get_tzdata_version();
}
-void testDatentime(char *locale)
+void showDatentimeFormat(char *locale)
+{
+ int ret = 0, i = 0;
+ int loc_count;
+
+ if (!locale) {
+ loc_count = i18n_ulocale_count_available();
+ for (i = 0; i < loc_count; i++) {
+ default_locale = i18n_ulocale_get_available(i);
+ printf("\n== Show Date basic format");
+ printf("\n****************************************");
+ printf("\n - locales : %s\n", default_locale);
+ ret = __get_date_basic_format();
+ }
+ if (ret == -1) {
+ printf("get i18n date and time basic format list failed\n");
+ }
+ } else {
+ default_locale = locale;
+ printf("\n== Show Date basic format");
+ printf("\n****************************************");
+ printf("\n - locales : %s\n", default_locale);
+ ret = __get_date_basic_format();
+ if (ret == -1) {
+ printf("get i18n date and time basic format list failed\n");
+ }
+ }
+}
+
+void testDatentime(char *input, char *locale)
{
int ret = 0, i = 0;
int loc_count;
loc_count = i18n_ulocale_count_available();
for (i = 0; i < loc_count; i++) {
default_locale = i18n_ulocale_get_available(i);
- printf("\n * locales : %s\n", default_locale);
- ret = __get_date_and_time();
+ printf("\n== Date and Time Test");
+ printf("\n****************************************");
+ printf("\n - locales : %s\n", default_locale);
+ ret = __get_date_and_time(input);
}
if (ret == -1) {
printf("get i18n date and time list failed\n");
}
} else {
default_locale = locale;
- printf("\n * locales : %s\n", default_locale);
- ret = __get_date_and_time();
+ printf("\n== Date and Time Test");
+ printf("\n****************************************");
+ printf("\n - locales : %s\n", default_locale);
+ ret = __get_date_and_time(input);
if (ret == -1) {
printf("get i18n date and time list failed\n");
}
loc_count = i18n_ulocale_count_available();
for (i = 0; i < loc_count; i++) {
default_locale = i18n_ulocale_get_available(i);
- printf("\n * locales : %s\n", default_locale);
+ printf("\n== Number Format Test");
+ printf("\n****************************************");
+ printf("\n - locales : %s\n", default_locale);
ret = __get_number_format(input);
}
if (ret == -1) {
}
} else {
default_locale = locale;
- printf("\n * locales : %s\n", default_locale);
+ printf("\n== Number Format Test");
+ printf("\n****************************************");
+ printf("\n - locales : %s\n", default_locale);
ret = __get_number_format(input);
if (ret == -1) {
printf("get number format list failed\n");
loc_count = i18n_ulocale_count_available();
for (i = 0; i < loc_count; i++) {
default_locale = i18n_ulocale_get_available(i);
- printf("\n * locales : %s\n", default_locale);
+ printf("\n== Number Symbol Test");
+ printf("\n****************************************");
+ printf("\n - locales : %s\n", default_locale);
ret = __get_symbol();
}
if (ret == -1) {
}
} else {
default_locale = locale;
- printf("\n * locales : %s\n", default_locale);
+ printf("\n== Number Symbol Test");
+ printf("\n****************************************");
+ printf("\n - locales : %s\n", default_locale);
ret = __get_symbol();
if (ret == -1) {
printf("get i18n symbol list failed\n");
{
int ret = 0;
+ printf("\n== String Test");
+ printf("\n****************************************\n");
ret = __analyze_string(input);
if (ret == -1) {
printf("get i18n string list failed\n");
{
int ret = 0;
+ printf("\n== String Iteration Test");
+ printf("\n****************************************\n");
ret = __manage_string_iteration(input);
if (ret == -1) {
printf("get i18n string iteration list failed\n");
struct arguments arguments = {0,};
+ init_env();
argp_parse(&argp, argc, argv, 0, 0, &arguments);
if (arguments.all) {
showLangInfo(arguments.setLocale);
}
+ if (arguments.showDateFormat) {
+ showDatentimeFormat(arguments.setLocale);
+ }
+
if (arguments.testDatentime) {
- testDatentime(arguments.setLocale);
+ testDatentime(arguments.testTimeArg, arguments.setLocale);
}
if (arguments.testNumberFormat) {