i18n (Internationalization)
: https://ko.wikipedia.org/wiki/%EA%B5%AD%EC%A0%9C%ED%99%94%EC%99%80_%EC%A7%80%EC%97%AD%ED%99%94
Tizen i18n Tutorial & Guide
: https://developer.tizen.org/ko/development/api-tutorials/native-application/base/i18n#dates
: https://developer.tizen.org/ko/development/guides/native-application/base/i18n?langredirect=1
Get System Settings for Current Locale, Time Zone
: https://developer.tizen.org/ko/development/tutorials/native-application/system/system-settings
: https://developer.tizen.org/ko/development/guides/native-application/system/system-settings?langredirect=1
Date, Time Display Guide by Time Zones
: https://developer.tizen.org/ko/development/api-tutorials/web-application/tizen-features/system/time
<샘플코드>
#include <utils_i18n.h>
#include <system_settings.h>
bool print_loca_date()
{
i18n_udatepg_h pattern_generator = NULL;
char *locale;
if (SYSTEM_SETTINGS_ERROR_NONE != system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, &locale))
return false;
dlog_print(DLOG_INFO, LOG_TAG, "Current Locale Country : %s\n", locale);
i18n_udatepg_create(locale, &pattern_generator);
if (!pattern_generator)
return false;
i18n_uchar bestPattern[64] = {0,};
char bestPatternString[64] = {0,};
int bestPatternLength, len;
const char *custom_format = "EEE, MMM d, yyyy 'at' HH:mm:ss zzz";
i18n_uchar uch_custom_format[64];
i18n_ustring_copy_ua(uch_custom_format, custom_format);
len = i18n_ustring_get_length(uch_custom_format);
i18n_udatepg_get_best_pattern(pattern_generator, uch_custom_format, len, bestPattern, 64, &bestPatternLength);
i18n_ustring_copy_au_n(bestPatternString, bestPattern, 64);
dlog_print(DLOG_INFO, LOG_TAG, "BestPattern(char[]) : %s \n", bestPatternString);
i18n_udatepg_destroy(pattern_generator);
i18n_udate_format_h formatter_Current = NULL;
i18n_uchar formatted[64] = {0,};
char result[64] = {0,};
int formattedLength;
i18n_udate date;
char *timezone_Current;
i18n_uchar utf16_timezone_Current[64] = {0,};
if (SYSTEM_SETTINGS_ERROR_NONE != system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_TIMEZONE, &timezone_Current))
return false;
i18n_ustring_copy_ua_n(utf16_timezone_Current, timezone_Current, strlen(timezone_Current));
if (I18N_ERROR_NONE != i18n_udate_create(I18N_UDATE_PATTERN , I18N_UDATE_PATTERN , locale,
utf16_timezone_Current, -1, bestPattern, -1, &formatter_Current))
return false;
if (utf16_timezone_Current)
{
i18n_ucalendar_get_now(&date);
i18n_udate_format_date(formatter_Current, date, formatted, 64, NULL, &formattedLength);
i18n_ustring_copy_au_n(result, formatted, 64);
dlog_print(DLOG_INFO, LOG_TAG, "Current Date : %s\n",result);
}
i18n_udate_destroy(formatter_Current);
return true;
}
<결과>
Current Locale Country : en_US
BestPattern(char[]) : EEE, MMM d, yyyy, h:mm:ss a zzz
Current Date : Thu, May 12, 2016, 11:22:56 AM GMT+9
Current Locale Country : de_DE
BestPattern(char[]) : EEE, d. MMM yyyy HH:mm:ss zzz
Current Date : Do., 12. Mai 2016 11:23:33 GMT+9
Current Locale Country : ko_KR
BestPattern(char[]) : yyyy년 MMM d일 (EEE) a h시 m분 s초 zzz
Current Date : 2016년 5월 12일 (목) 오전 11시 24분 13초 GMT+9
Current Locale Country : zh_CN
BestPattern(char[]) : yyyy年M月d日EEE zzzah:mm:ss
Current Date : 2016年5月12日星期四 GMT+9AM11:24:48
Current Locale Country : ja_JP
BestPattern(char[]) : yyyy年M月d日(EEE) H:mm:ss zzz
Current Date : 2016年5月12日(木) 11:25:13 GMT+9
Current Locale Country : hi_IN
BestPattern(char[]) : EEE, d MMM yyyy h:mm:ss a zzz
Current Date : गुरु, 12 मई 2016 11:26:29 AM GMT+9