+#define _GNU_SOURCE 1
+#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <assert.h>
-#include <time.h>
#include "i18ninfo_argp.h"
#include <utils_i18n.h>
#define PRINT_ASCIIDOC_LOG(fmt) if (ASCIIDOC_FLAG) printf(fmt)
-char *default_locale = I18N_ULOCALE_UK;
+const char *default_locale = I18N_ULOCALE_UK;
i18n_uchar default_timezone_id[BUF_SIZE] = {0,};
i18n_udate_format_style_e eTimeFormatStyle[] = {
{
char *str = calloc(300, sizeof(char));
PRINT_DEBUG_LOG("input type: %s, num: %d\n", type, num);
- if (type == "time") {
+ if (!strcmp(type, "time")) {
switch (num) {
case 0:
COPY_STR(str, "I18N_UDATE_FULL", strlen("I18N_UDATE_FULL"));
COPY_STR(str, "err", strlen("err"));
break;
}
- } else if (type == "date") {
+ } else if (!strcmp(type, "date")) {
switch (num) {
case 0:
COPY_STR(str, "I18N_UDATE_FULL", strlen("I18N_UDATE_FULL"));
COPY_STR(str, "err", strlen("err"));
break;
}
- } else if (type == "number_format") {
+ } else if (!strcmp(type, "number_format")) {
switch (num) {
case 1:
COPY_STR(str, "I18N_UNUMBER_DECIMAL", strlen("I18N_UNUMBER_DECIMAL"));
COPY_STR(str, "err", strlen("err"));
break;
}
- } else if (type == "symbol") {
+ } else if (!strcmp(type, "symbol")) {
switch (num) {
case 1:
COPY_STR(str, "I18N_UNUMBER_DECIMAL_SEPARATOR_SYMBOL", strlen("I18N_UNUMBER_DECIMAL_SEPARATOR_SYMBOL"));
COPY_STR(str, "err", strlen("err"));
break;
}
- } else if (type == "iter_type") {
+ } else if (!strcmp(type, "iter_type")) {
switch (num) {
case 0:
COPY_STR(str, "I18N_UBRK_CHARACTER", strlen("I18N_UBRK_CHARACTER"));
return str;
}
-static const char *_date_basic_format_convert(char *input_pattern, int i, char *type)
+static 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_udate date_now = 259200000;
- if (type == "day") date_now += i * 86400000;
- else if (type == "month") {
+ if (!strcmp(type, "day")) date_now += i * 86400000;
+ else if (!strcmp(type, "month")) {
int k;
for (k = 0; k < i; k++)
date_now += 2678400000;
i18n_udate _time_convert(char *input_time)
{
- long long int lli;
i18n_ucalendar_h ucal;
i18n_udate date;
int ret = I18N_ERROR_NONE;
i18n_udate date_now;
if (!input_time) {
int error_code = i18n_ucalendar_get_now(&date_now);
+ CHECK_ERROR("i18n_ucalendar_get_now", error_code);
PRINT_DEBUG_LOG("i18n_ucalendar_get_now = %lf\n", date_now);
} else {
date_now = _time_convert(input_time);
i18n_uchar format[BUF_SIZE];
i18n_ustring_copy_ua_n(format, "ddMMMyyyyHHmmssz", BUF_SIZE);
- 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);
+ int pattern_len, len;
+ i18n_uchar pattern[BUF_SIZE], skeleton[BUF_SIZE];
+ i18n_ustring_copy_ua(skeleton, I18N_UDATE_MONTH_DAY);
+ len = i18n_ustring_get_length(skeleton);
+ error_code = i18n_udatepg_get_best_pattern(udatepg, skeleton, len, pattern, BUF_SIZE, &pattern_len);
CHECK_ERROR("i18n_udatepg_get_best_pattern", error_code);
PRINT_ASCIIDOC_LOG("\n[options=\"header\"]\n");
i18n_ubreak_iterator_h boundary;
if (!input_string) {
- char *input_text = "Twinkle, twinkle, little star.\ How I wonder what you are";
+ char *input_text = "Twinkle, twinkle, little star. How I wonder what you are";
printf("\nInput string : %s\n", input_text);
string_to_examine =
(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");
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);
+ i18n_ustring_to_title_new(dest, BUF_SIZE + 1, string_to_examine, BUF_SIZE, NULL, NULL);
CHECK_ERROR("i18n_ustring_to_title_new", error_code);
i18n_ustring_copy_au(s, dest);
printf("| To Title | %s\n", s);
* local standard time to get the local wall clock time.
*/
int32_t dst_savings;
- 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);
int main(int argc, char *argv[])
{
- int ret = 0, i = 0;
-
struct arguments arguments = {0,};
init_env();