FS-9693 use existing date parsing functions in fulldate comparison that take timezone into account
This commit is contained in:
parent
ce01590486
commit
92b8996eea
|
@ -3341,6 +3341,8 @@ SWITCH_DECLARE(int) switch_fulldate_cmp(const char *exp, switch_time_t *ts)
|
|||
char *sEnd;
|
||||
char *cur;
|
||||
char *p;
|
||||
switch_time_t tsStart = 0;
|
||||
switch_time_t tsEnd = 0;
|
||||
|
||||
switch_assert(dup);
|
||||
|
||||
|
@ -3351,70 +3353,26 @@ SWITCH_DECLARE(int) switch_fulldate_cmp(const char *exp, switch_time_t *ts)
|
|||
|
||||
while (cur) {
|
||||
sStart = cur;
|
||||
if ((sEnd=strchr(cur, '~'))) {
|
||||
char *sDate = sStart;
|
||||
char *sTime;
|
||||
if ((sEnd = strchr(cur, '~'))) {
|
||||
*sEnd++ = '\0';
|
||||
if ((sTime=strchr(sStart, ' '))) {
|
||||
switch_time_t tsStart;
|
||||
struct tm tmTmp;
|
||||
int year = 1970, month = 1, day = 1;
|
||||
int hour = 0, min = 0, sec = 0;
|
||||
*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-1900;
|
||||
tmTmp.tm_mon = month-1;
|
||||
tmTmp.tm_mday = day;
|
||||
tsStart = switch_str_time(sStart);
|
||||
tsEnd = switch_str_time(sEnd);
|
||||
switch_safe_free(dup);
|
||||
|
||||
tmTmp.tm_hour = hour;
|
||||
tmTmp.tm_min = min;
|
||||
tmTmp.tm_sec = sec;
|
||||
tmTmp.tm_isdst = 0;
|
||||
tsStart = mktime(&tmTmp);
|
||||
|
||||
sDate = sEnd;
|
||||
if ((sTime=strchr(sEnd, ' '))) {
|
||||
switch_time_t tsEnd;
|
||||
struct tm tmTmp;
|
||||
int year = 1970, month = 1, day = 1;
|
||||
int hour = 0, min = 0, sec = 0;
|
||||
*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-1900;
|
||||
tmTmp.tm_mon = month-1;
|
||||
tmTmp.tm_mday = day;
|
||||
|
||||
tmTmp.tm_hour = hour;
|
||||
tmTmp.tm_min = min;
|
||||
tmTmp.tm_sec = sec;
|
||||
tmTmp.tm_isdst = 0;
|
||||
tsEnd = mktime(&tmTmp);
|
||||
|
||||
if (tsStart <= *ts/1000000 && tsEnd > *ts/1000000) {
|
||||
switch_safe_free(dup);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tsStart == 0) return 0;
|
||||
if (tsEnd == 0) return 0;
|
||||
if (tsStart <= *ts && tsEnd > *ts) return 1;
|
||||
}
|
||||
|
||||
cur = p;
|
||||
if (p) {
|
||||
if ((cur = p)) {
|
||||
if ((p = strchr(p, ','))) {
|
||||
*p++ = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
switch_safe_free(dup);
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue