mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-10-24 20:24:16 +00:00
switch_utils: Add date time range string compare function switch_fulldate_cmp. It usable in XML dialplan with date-time. String format example : 2009-10-10 14:33:22~2009-11-10 17:32:31.
This commit is contained in:
1 parent
4ab8fa13e1
commit
c9fcce0869
3 files changed
+145
No files matched your search
@@ -2652,6 +2652,7 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_cut(switch_xml_t xml)
|
||||
|
||||
SWITCH_DECLARE(int) switch_xml_std_datetime_check(switch_xml_t xcond) {
|
||||
|
||||
const char *xdt = switch_xml_attr(xcond, "date-time");
|
||||
const char *xyear = switch_xml_attr(xcond, "year");
|
||||
const char *xyday = switch_xml_attr(xcond, "yday");
|
||||
const char *xmon = switch_xml_attr(xcond, "mon");
|
||||
@@ -2670,6 +2671,15 @@ SWITCH_DECLARE(int) switch_xml_std_datetime_check(switch_xml_t xcond) {
|
||||
|
||||
switch_time_exp_lt(&tm, ts);
|
||||
|
||||
if (time_match && xdt) {
|
||||
char tmpdate[80];
|
||||
switch_size_t retsize;
|
||||
switch_strftime(tmpdate, &retsize, sizeof(tmpdate), "%Y-%m-%d %H:%M:%S", &tm);
|
||||
time_match = switch_fulldate_cmp(xdt, &ts);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
|
||||
"XML DateTime Check: date time[%s] =~ %s (%s)\n", tmpdate, xdt, time_match ? "PASS" : "FAIL");
|
||||
}
|
||||
|
||||
if (time_match && xyear) {
|
||||
int test = tm.tm_year + 1900;
|
||||
time_match = switch_number_cmp(xyear, test);
|
||||
|
||||
Reference in new issue
Block a user