diff --git a/src/switch_utils.c b/src/switch_utils.c index 4624badc07..808afd0c57 100644 --- a/src/switch_utils.c +++ b/src/switch_utils.c @@ -2342,6 +2342,9 @@ SWITCH_DECLARE(int) switch_fulldate_cmp(const char *exp, switch_time_t *ts) char *sTime; switch_time_t tsStart; switch_time_t tsEnd; + struct tm tmTmp; + int year, month, day; + int hour, min, sec; switch_assert(dup); @@ -2350,16 +2353,13 @@ SWITCH_DECLARE(int) switch_fulldate_cmp(const char *exp, switch_time_t *ts) *sEnd++ = '\0'; sDate = sStart; if ((sTime=strchr(sStart, ' '))) { - struct tm tmTmp; - int year, month, day; - int hour, min, sec; - *sTime++ = '\0'; + memset(&tmTmp, 0, sizeof(tmTmp)); switch_split_date(sDate, &year, &month, &day); switch_split_time(sTime, &hour, &min, &sec); - tmTmp.tm_year = year; - tmTmp.tm_mon = month; + tmTmp.tm_year = year-1900; + tmTmp.tm_mon = month-1; tmTmp.tm_mday = day; tmTmp.tm_hour = hour; @@ -2370,16 +2370,13 @@ SWITCH_DECLARE(int) switch_fulldate_cmp(const char *exp, switch_time_t *ts) sDate = sEnd; if ((sTime=strchr(sEnd, ' '))) { - struct tm tmTmp; - int year, month, day; - int hour, min, sec; - *sTime++ = '\0'; + memset(&tmTmp, 0, sizeof(tmTmp)); switch_split_date(sDate, &year, &month, &day); switch_split_time(sTime, &hour, &min, &sec); - tmTmp.tm_year = year; - tmTmp.tm_mon = month; + tmTmp.tm_year = year-1900; + tmTmp.tm_mon = month-1; tmTmp.tm_mday = day; tmTmp.tm_hour = hour; @@ -2388,7 +2385,7 @@ SWITCH_DECLARE(int) switch_fulldate_cmp(const char *exp, switch_time_t *ts) tmTmp.tm_isdst = 0; tsEnd = mktime(&tmTmp); - if (tsStart <= *ts && tsEnd > *ts) { + if (tsStart <= *ts/1000000 && tsEnd > *ts/1000000) { switch_safe_free(dup); return 1; }