From: Hyunjin Park Date: Tue, 11 Aug 2015 01:16:53 +0000 (+0900) Subject: [time] Fixed web TCT issues. Added getDefaultLocale api to get region format of vconf... X-Git-Tag: submit/tizen/20151026.073646^2^2~192 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=54da56b94b86409c1f648358b4a8fdafcc12b67d;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [time] Fixed web TCT issues. Added getDefaultLocale api to get region format of vconf key. - from http://slp-info.sec.samsung.net/gerrit/#/c/2663854/ Web TCT - Time : 100% passed Change-Id: I398070a2c6a84c679c0822949daad647d4a96101 --- diff --git a/src/time/time_instance.cc b/src/time/time_instance.cc index 9f75c23a..ddf62552 100644 --- a/src/time/time_instance.cc +++ b/src/time/time_instance.cc @@ -423,14 +423,47 @@ void TimeInstance::TimeGetDateFormat(const JsonValue& args, JsonObject& out) { ReportSuccess(JsonValue(result), out); } +Locale* TimeInstance::getDefaultLocale() { + char *tempstr = vconf_get_str(VCONFKEY_REGIONFORMAT); + if (NULL == tempstr){ + return NULL; + } + + Locale *defaultLocale = NULL; + + char *str_region = NULL; + char* p = strchr(tempstr, '.'); + int len = strlen(tempstr) - strlen(".UTF-8"); + if (p && len > 0) { + str_region = strndup(tempstr, len); //.UTF8 => 5 + defaultLocale = new Locale(str_region); + } + + free(tempstr); + free(str_region); + + if (defaultLocale) { + if (defaultLocale->isBogus()) { + delete defaultLocale; + defaultLocale = NULL; + } + } + + return defaultLocale; +} + UnicodeString TimeInstance::getDateTimeFormat(DateTimeFormatType type, bool bLocale) { LoggerD("Entered"); + LoggerD("bLocale %d", bLocale); UErrorCode ec = U_ZERO_ERROR; + Locale *defaultLocale = getDefaultLocale(); std::unique_ptr dateTimepattern( DateTimePatternGenerator::createInstance( - (bLocale ? Locale::getDefault() : Locale::getEnglish()), ec)); + ((bLocale && defaultLocale) ? *defaultLocale : Locale::getEnglish()), ec)); + + delete defaultLocale; if (U_FAILURE(ec)) { LoggerE("Failed to create Calendar instance"); diff --git a/src/time/time_instance.h b/src/time/time_instance.h index 6cb1e1ed..3c5ffa9b 100644 --- a/src/time/time_instance.h +++ b/src/time/time_instance.h @@ -50,6 +50,7 @@ class TimeInstance : public common::ParsedInstance { void TimeUnsetTimezoneChangeListener(const JsonValue& args, JsonObject& out); void TimeGetMsUTC(const JsonValue& args, JsonObject& out); + Locale* getDefaultLocale(); UnicodeString getDateTimeFormat(DateTimeFormatType type, bool bLocale); bool toStringByFormat(const JsonValue& args, JsonValue& out, DateTimeFormatType format);