diff --git a/conf/dialplan/default.xml b/conf/dialplan/default.xml
index dcd3fbd936..5e25a2317a 100644
--- a/conf/dialplan/default.xml
+++ b/conf/dialplan/default.xml
@@ -27,6 +27,7 @@
mon = 1-12
mday = 1-31
week = 1-52
+ mweek= 1-6
wday = 1-7
hour = 0-23
minute = 0-59
@@ -40,6 +41,50 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c b/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c
index 55eb23453c..cf6a7a9e79 100644
--- a/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c
+++ b/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c
@@ -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 *xmday = switch_xml_attr(xcond, "mday");
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 *xhour = switch_xml_attr(xcond, "hour");
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");
}
+ 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) {
int test = tm.tm_wday + 1;
time_match = switch_number_cmp(xwday, test);