提交 79992ac5 authored 作者: Jeff Lenk's avatar Jeff Lenk

refactor switch_fulldate_cmp and correct usec comparison and year month error

上级 2b904c0b
......@@ -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;
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论