From: jk.koo Date: Fri, 27 Mar 2020 09:41:51 +0000 (+0900) Subject: Fixed the error reading timezone incorrectly X-Git-Tag: submit/tizen/20200327.115503~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f9158fe336b3d7d974676172b4e3ae65a956179f;hp=3f0425978ee15df6a1458bfb79e996eff525f4a9;p=platform%2Fcore%2Fpim%2Fcalendar-service.git Fixed the error reading timezone incorrectly Change-Id: I7a0d61e4a7068e2385dae96438cb2572c1b1002d Signed-off-by: jk.koo --- diff --git a/common/cal_time.cpp b/common/cal_time.cpp index 2520006..80e3c91 100644 --- a/common/cal_time.cpp +++ b/common/cal_time.cpp @@ -457,17 +457,44 @@ int _get_dst_savings(char *tzid) UChar utf16_timezone[CAL_STR_SHORT_LEN64] = {0}; u_uastrncpy(utf16_timezone, tzid, sizeof(utf16_timezone)); - UErrorCode status = U_ZERO_ERROR; + UErrorCode err = U_ZERO_ERROR; + + int dst_time = (int)ucal_getDSTSavings(utf16_timezone, &err); + if (err != 0) { + ERR("ucal_getDSTSavings() failed(%d)", err); + dst_time = 0; + } - return ucal_getDSTSavings(utf16_timezone, &status); + return dst_time; } bool cal_time_is_dst_savings(void) { - char buf[128] = {0}; + char buf[256] = {0}; + char *last = NULL; + char *next = NULL; + char *timezone = NULL; + readlink("/opt/etc/localtime", buf, sizeof(buf) - 1); - char *timezone = buf + 20; /* /usr/share/zoneinfo/ */ + do { + last = strrchr(buf, '/'); + if (NULL == last) + break; + + *last = '\0'; + + next = strrchr(buf, '/'); + } while (0); + + if (NULL == last || NULL == next) { + ERR("There is no timezone info"); + return false; + } + + *last = '/'; + timezone = next + 1; + return _get_dst_savings(timezone) == 0 ? false : true; }