int year, month, day, hour, minute, second;
struct tm result;
+ if (strlen(input_time) < 9) {
+ strcat(input_time, "000000");
+ }
strptime(input_time, "%Y%m%d%H%M%S", &result);
+
if (result.tm_year >= 100)
- result.tm_year = result.tm_year%100 + 2000;
+ result.tm_year = result.tm_year % 100 + 2000;
+ else
+ result.tm_year = result.tm_year + 1900;
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 */
return 0;
}
+int __convert_lunar_calendar(char *input_time)
+{
+ i18n_ucalendar_h ucal_ch, ucal_greg;
+ i18n_ucalendar_create(NULL, NULL, "en@calendar=chinese", I18N_UCALENDAR_TRADITIONAL, &ucal_ch);
+ i18n_ucalendar_create(NULL, NULL, "en@calendar=gregorian", I18N_UCALENDAR_TRADITIONAL, &ucal_greg);
+
+ i18n_udate new_date;
+
+ if(input_time) {
+ printf(" - Input date : %s\n", input_time);
+ printf("****************************************\n");
+ new_date = _time_convert(input_time);
+ PRINT_DEBUG_LOG("_time_convert = %lf\n", new_date);
+ i18n_ucalendar_set_milliseconds(ucal_greg, new_date);
+ } else
+ i18n_ucalendar_get_milliseconds(ucal_greg, &new_date);
+
+ i18n_ucalendar_set_milliseconds(ucal_ch, new_date);
+
+ int month, day, year;
+ int month_ch, day_ch, year_ch;
+
+ i18n_ucalendar_get(ucal_greg, I18N_UCALENDAR_YEAR, &year);
+ i18n_ucalendar_get(ucal_greg, I18N_UCALENDAR_MONTH, &month);
+ i18n_ucalendar_get(ucal_greg, I18N_UCALENDAR_DATE, &day);
+
+ i18n_ucalendar_get(ucal_ch, I18N_UCALENDAR_YEAR, &year_ch);
+ i18n_ucalendar_get(ucal_ch, I18N_UCALENDAR_MONTH, &month_ch);
+ i18n_ucalendar_get(ucal_ch, I18N_UCALENDAR_DATE, &day_ch);
+
+ printf("Solar calendar) year:%d month:%d day:%d\n", year, month+1, day);
+ printf("Lunar calendar) year:%d month:%d day:%d\n", year_ch, month_ch+1, day_ch);
+
+ return 0;
+}
+
#if (__TIZEN_VER >= 4)
int32_t _ustring_append_n(i18n_uchar *dest, int32_t dest_length, const i18n_uchar *src, int32_t src_length)
{
}
}
+void convertCalendar(char *input)
+{
+ int ret = 0;
+ printf("\n== Convert time to lunar calendar");
+ printf("\n****************************************\n");
+ ret = __convert_lunar_calendar(input);
+ if (ret == -1) {
+ printf("get lunar calendar failed\n");
+ }
+
+}
+
int main(int argc, char *argv[])
{
struct arguments arguments = {0, };
showUbidi(arguments.testTextArg);
}
+ if (arguments.convertCalendar) {
+ convertCalendar(arguments.testTime);
+ }
+
#if (__TIZEN_VER >= 4)
if (arguments.testNumberConvert) {
testNumberConvert(arguments.testNumberConvertArg);
static struct argp_option options[] = {
- {"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-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 },
- {"test-number-format", 'n', "Number", 0, "Number format test", 0 },
- {"test-number-symbol", 'N', 0, 0, "Number symbol test", 0 },
- {"test-string", 's', "Word", OPTION_ARG_OPTIONAL, "String test", 0 },
- {"test-string-iter", 'S', "Type", OPTION_ARG_OPTIONAL, "String iteration test", 0 },
- {"set-locale", 'l', "locale", 0, "Set specific locale", 0 },
- {"print-ASCII", 'p', 0, 0, "Print results as the ASCIIDoc Format", 0 },
- {"show-ubidi", 'b', 0, OPTION_ARG_OPTIONAL, "Show examples of the Unicode Bidirectional Algorithm", 0 },
+ {"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-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 },
+ {"test-number-format", 'n', "Number", 0, "Number format test", 0 },
+ {"test-number-symbol", 'N', 0, 0, "Number symbol test", 0 },
+ {"test-string", 's', "Word", OPTION_ARG_OPTIONAL, "String test", 0 },
+ {"test-string-iter", 'S', "Type", OPTION_ARG_OPTIONAL, "String iteration test", 0 },
+ {"set-locale", 'l', "locale", 0, "Set specific locale", 0 },
+ {"print-ASCII", 'p', 0, 0, "Print results as the ASCIIDoc Format", 0 },
+ {"show-ubidi", 'b', 0, OPTION_ARG_OPTIONAL, "Show examples of the Unicode Bidirectional Algorithm", 0 },
+ {"convert-calendar", 'e', "Date", OPTION_ARG_OPTIONAL, "Convert time to lunar calendar", 0 },
+
#if (__TIZEN_VER >= 4)
- {"test-number-converting", 'c', "Convert", OPTION_ARG_OPTIONAL, "Number converting test", 0 },
- {"show-measure-unit", 'm', "Number", OPTION_ARG_OPTIONAL, "Show measure unit", 0 },
+ {"test-number-converting", 'c', "Convert", OPTION_ARG_OPTIONAL, "Number converting test", 0 },
+ {"show-measure-unit", 'm', "Number", OPTION_ARG_OPTIONAL, "Show measure unit", 0 },
#endif
#if (__TIZEN_VER >= 5)
- {"test-plural-rules", 'r', "input", OPTION_ARG_OPTIONAL, "Show Plural Rules", 0},
+ {"test-plural-rules", 'r', "input", OPTION_ARG_OPTIONAL, "Show Plural Rules", 0 },
#endif
{ 0 }
};
int testStringIter;
int printASCII;
int showUbidi;
+ int convertCalendar;
#if (__TIZEN_VER >= 4)
int testNumberConvert;
int showMeasureUnit;
char *testStringIterArg;
char *setLocale;
char *testTextArg;
+ char *testTime;
#if (__TIZEN_VER >= 4)
char *testNumberConvertArg;
char *testInputNumArg;
state->next++;
}
break;
+ case 'e':
+ arguments->arg_flag = 18;
+ arguments->convertCalendar = 1;
+
+ nextArg = state->argv[state->next];
+ if (nextArg && *nextArg != '-') {
+ arguments->testTime = nextArg;
+ state->next++;
+ }
+ break;
#if (__TIZEN_VER >= 4)
case 'm':