FS-7198 add coma separated values and reverse ranges for time-of-day and day-of-week matches
This commit is contained in:
parent
e994b75e8b
commit
48b44832b2
|
@ -3320,11 +3320,19 @@ SWITCH_DECLARE(int) switch_fulldate_cmp(const char *exp, switch_time_t *ts)
|
|||
char *dup = strdup(exp);
|
||||
char *sStart;
|
||||
char *sEnd;
|
||||
char *cur;
|
||||
char *p;
|
||||
|
||||
switch_assert(dup);
|
||||
|
||||
sStart = dup;
|
||||
if ((sEnd=strchr(dup, '~'))) {
|
||||
cur = dup;
|
||||
if ((p = strchr(cur, ','))) {
|
||||
*p++ = '\0';
|
||||
}
|
||||
|
||||
while (cur) {
|
||||
sStart = cur;
|
||||
if ((sEnd=strchr(cur, '~'))) {
|
||||
char *sDate = sStart;
|
||||
char *sTime;
|
||||
*sEnd++ = '\0';
|
||||
|
@ -3376,6 +3384,15 @@ SWITCH_DECLARE(int) switch_fulldate_cmp(const char *exp, switch_time_t *ts)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
cur = p;
|
||||
if (p) {
|
||||
if ((p = strchr(p, ','))) {
|
||||
*p++ = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
switch_safe_free(dup);
|
||||
return 0;
|
||||
|
||||
|
@ -3711,7 +3728,7 @@ SWITCH_DECLARE(switch_bool_t) switch_dow_cmp(const char *exp, int val)
|
|||
} else {
|
||||
/* Valid day found */
|
||||
if (range_start != DOW_EOF) { /* Evaluating a range */
|
||||
if (val >= range_start && val <= cur) {
|
||||
if (range_start <= cur ? (val >= range_start && val <= cur) : (val >= range_start || val <= cur)) {
|
||||
return SWITCH_TRUE;
|
||||
}
|
||||
range_start = DOW_EOF;
|
||||
|
@ -3754,11 +3771,20 @@ SWITCH_DECLARE(int) switch_tod_cmp(const char *exp, int val)
|
|||
char *maxh;
|
||||
char *maxm;
|
||||
char *maxs;
|
||||
char *cur;
|
||||
char *p;
|
||||
int range_start, range_end;
|
||||
|
||||
switch_assert(dup);
|
||||
|
||||
minh = dup;
|
||||
if ((minm=strchr(dup, ':'))) {
|
||||
cur = dup;
|
||||
if ((p = strchr(cur, ','))) {
|
||||
*p++ = '\0';
|
||||
}
|
||||
|
||||
while (cur) {
|
||||
minh = cur;
|
||||
if ((minm=strchr(cur, ':'))) {
|
||||
*minm++ = '\0';
|
||||
if ((maxh=strchr(minm, '-'))) {
|
||||
if ((maxm=strchr(maxh, ':'))) {
|
||||
|
@ -3776,13 +3802,25 @@ SWITCH_DECLARE(int) switch_tod_cmp(const char *exp, int val)
|
|||
maxs = "00";
|
||||
}
|
||||
|
||||
if (val >= (atol(minh) * 60 * 60) + (atol(minm) * 60) + atol(mins) && val < (atol(maxh) * 60 * 60) + (atol(maxm) * 60) + atol(maxs)) {
|
||||
range_start = (atol(minh) * 60 * 60) + (atol(minm) * 60) + atol(mins);
|
||||
range_end = (atol(maxh) * 60 * 60) + (atol(maxm) * 60) + atol(maxs);
|
||||
if (range_start <= range_end ? (val >= range_start && val <= range_end) : (val >= range_start || val <= range_end)) {
|
||||
switch_safe_free(dup);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cur = p;
|
||||
if (p) {
|
||||
if ((p = strchr(p, ','))) {
|
||||
*p++ = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
switch_safe_free(dup);
|
||||
return 0;
|
||||
|
||||
|
|
Loading…
Reference in New Issue