forked from Mirrors/freeswitch
add Vagabond's week of year patch
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@15721 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
ae05a0c5de
commit
c314c09976
@ -27,6 +27,7 @@
|
|||||||
mon = 1-12
|
mon = 1-12
|
||||||
mday = 1-31
|
mday = 1-31
|
||||||
week = 1-52
|
week = 1-52
|
||||||
|
mweek= 1-6
|
||||||
wday = 1-7
|
wday = 1-7
|
||||||
hour = 0-23
|
hour = 0-23
|
||||||
minute = 0-59
|
minute = 0-59
|
||||||
@ -40,6 +41,50 @@
|
|||||||
<extension name="tod_example" continue="true">
|
<extension name="tod_example" continue="true">
|
||||||
<condition wday="2-6" hour="9-18">
|
<condition wday="2-6" hour="9-18">
|
||||||
<action application="set" data="open=true"/>
|
<action application="set" data="open=true"/>
|
||||||
|
</condition>
|
||||||
|
</extension>
|
||||||
|
|
||||||
|
<!-- Example of routing based on holidays
|
||||||
|
|
||||||
|
This example covers all US Federal holidays except for inauguration day and memorial day.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<extension name="holiday_example" continue="true">
|
||||||
|
<condition mday="1" mon="1">
|
||||||
|
<!-- new year's day -->
|
||||||
|
<action application="set" data="open=false"/>
|
||||||
|
</condition>
|
||||||
|
<condition wday="2" mweek="3" mon="1">
|
||||||
|
<!-- martin luther king day is the 3rd monday in january -->
|
||||||
|
<action application="set" data="open=false"/>
|
||||||
|
</condition>
|
||||||
|
<condition wday="2" mweek="3" mon="2">
|
||||||
|
<!-- president's day is the 3rd monday in february -->
|
||||||
|
<action application="set" data="open=false"/>
|
||||||
|
</condition>
|
||||||
|
<condition mday="4" mon="6">
|
||||||
|
<!-- independence day -->
|
||||||
|
<action application="set" data="open=false"/>
|
||||||
|
</condition>
|
||||||
|
<condition wday="2" mweek="1" mon="9">
|
||||||
|
<!-- labor day is the 1st monday in september -->
|
||||||
|
<action application="set" data="open=false"/>
|
||||||
|
</condition>
|
||||||
|
<condition wday="2" mweek="2" mon="10">
|
||||||
|
<!-- columbus day is the 2st monday in october -->
|
||||||
|
<action application="set" data="open=false"/>
|
||||||
|
</condition>
|
||||||
|
<condition mday="11" mon="11">
|
||||||
|
<!-- veteran's day -->
|
||||||
|
<action application="set" data="open=false"/>
|
||||||
|
</condition>
|
||||||
|
<condition wday="5-6" mweek="4" mon="11">
|
||||||
|
<!-- thanksgiving is the 4th thursday in november and usually there's an extension for black friday -->
|
||||||
|
<action application="set" data="open=false"/>
|
||||||
|
</condition>
|
||||||
|
<condition mday="25" mon="12">
|
||||||
|
<!-- Christmas -->
|
||||||
|
<action application="set" data="open=false"/>
|
||||||
</condition>
|
</condition>
|
||||||
</extension>
|
</extension>
|
||||||
|
|
||||||
|
@ -106,6 +106,7 @@ static int parse_exten(switch_core_session_t *session, switch_caller_profile_t *
|
|||||||
const char *xmon = switch_xml_attr(xcond, "mon");
|
const char *xmon = switch_xml_attr(xcond, "mon");
|
||||||
const char *xmday = switch_xml_attr(xcond, "mday");
|
const char *xmday = switch_xml_attr(xcond, "mday");
|
||||||
const char *xweek = switch_xml_attr(xcond, "week");
|
const char *xweek = switch_xml_attr(xcond, "week");
|
||||||
|
const char *xmweek = switch_xml_attr(xcond, "mweek");
|
||||||
const char *xwday = switch_xml_attr(xcond, "wday");
|
const char *xwday = switch_xml_attr(xcond, "wday");
|
||||||
const char *xhour = switch_xml_attr(xcond, "hour");
|
const char *xhour = switch_xml_attr(xcond, "hour");
|
||||||
const char *xminute = switch_xml_attr(xcond, "minute");
|
const char *xminute = switch_xml_attr(xcond, "minute");
|
||||||
@ -160,6 +161,16 @@ static int parse_exten(switch_core_session_t *session, switch_caller_profile_t *
|
|||||||
"Dialplan: week of year[%d] =~ %s (%s)\n", test, xweek, time_match ? "PASS" : "FAIL");
|
"Dialplan: week of year[%d] =~ %s (%s)\n", test, xweek, time_match ? "PASS" : "FAIL");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (time_match && xmweek) {
|
||||||
|
/* calculate the day of the week of the first of the month (0-6) */
|
||||||
|
int firstdow = (int) (7 - (tm.tm_mday - (tm.tm_wday + 1)) % 7) % 7;
|
||||||
|
/* calculate the week of the month (1-6)*/
|
||||||
|
int test = (int) ceil((tm.tm_mday + firstdow) / 7.0);
|
||||||
|
time_match = switch_number_cmp(xmweek, test);
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_DEBUG,
|
||||||
|
"Dialplan: week of month[%d] =~ %s (%s)\n", test, xmweek, time_match ? "PASS" : "FAIL");
|
||||||
|
}
|
||||||
|
|
||||||
if (time_match && xwday) {
|
if (time_match && xwday) {
|
||||||
int test = tm.tm_wday + 1;
|
int test = tm.tm_wday + 1;
|
||||||
time_match = switch_number_cmp(xwday, test);
|
time_match = switch_number_cmp(xwday, test);
|
||||||
|
Loading…
Reference in New Issue
Block a user