]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-6626 fix winter DST issue
authorBrian West <brian@freeswitch.org>
Wed, 9 Jul 2014 12:58:11 +0000 (07:58 -0500)
committerBrian West <brian@freeswitch.org>
Wed, 9 Jul 2014 12:58:11 +0000 (07:58 -0500)
src/switch_utils.c

index a5c4b8f2f74d19d2e5ba68b2e93ffc7948a55976..d13db78d864aed09a2ab8ed7baea14a3df2cfc5a 100644 (file)
@@ -1637,16 +1637,16 @@ SWITCH_DECLARE(switch_status_t) switch_find_interface_ip(char *buf, int len, int
 
 SWITCH_DECLARE(switch_time_t) switch_str_time(const char *in)
 {
-       switch_time_exp_t tm = { 0 };
+       switch_time_exp_t tm = { 0 }, local_tm = { 0 };
        int proceed = 0, ovector[30];
        switch_regex_t *re = NULL;
        char replace[1024] = "";
-       switch_time_t ret = 0;
+       switch_time_t ret = 0, local_time = 0;
        char *pattern = "^(\\d+)-(\\d+)-(\\d+)\\s*(\\d*):{0,1}(\\d*):{0,1}(\\d*)";
        char *pattern2 = "^(\\d{4})(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})";
 
        switch_time_exp_lt(&tm, switch_micro_time_now());
-       tm.tm_year = tm.tm_mon = tm.tm_mday = tm.tm_hour = tm.tm_min = tm.tm_sec = 0;
+       tm.tm_year = tm.tm_mon = tm.tm_mday = tm.tm_hour = tm.tm_min = tm.tm_sec = tm.tm_usec = 0;
 
        if (!(proceed = switch_regex_perform(in, pattern, &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) {
                switch_regex_safe_free(re);
@@ -1687,6 +1687,11 @@ SWITCH_DECLARE(switch_time_t) switch_str_time(const char *in)
 
                switch_regex_safe_free(re);
 
+               switch_time_exp_get(&local_time, &tm);
+               switch_time_exp_lt(&local_tm, local_time);
+               tm.tm_isdst = local_tm.tm_isdst;
+               tm.tm_gmtoff = local_tm.tm_gmtoff;
+
                switch_time_exp_gmt_get(&ret, &tm);
                return ret;
        }