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;
}