add tod_tz_offset variable to set to the integer value of the tz offset or the tz-offset tag on a per-tag basis

This commit is contained in:
Anthony Minessale 2011-11-07 14:31:25 -06:00
parent 041e3bf00c
commit 65a756643a
4 changed files with 27 additions and 6 deletions

View File

@ -421,7 +421,7 @@ SWITCH_DECLARE(switch_status_t) switch_xml_unbind_search_function_ptr(_In_ switc
///\return the section mask ///\return the section mask
SWITCH_DECLARE(switch_xml_section_t) switch_xml_parse_section_string(_In_opt_z_ const char *str); SWITCH_DECLARE(switch_xml_section_t) switch_xml_parse_section_string(_In_opt_z_ const char *str);
SWITCH_DECLARE(int) switch_xml_std_datetime_check(switch_xml_t xcond); SWITCH_DECLARE(int) switch_xml_std_datetime_check(switch_xml_t xcond, int *offset);
SWITCH_DECLARE(switch_status_t) switch_xml_locate_language(switch_xml_t *root, switch_xml_t *node, switch_event_t *params, switch_xml_t *language, switch_xml_t *phrases, switch_xml_t *macros, const char *str_language); SWITCH_DECLARE(switch_status_t) switch_xml_locate_language(switch_xml_t *root, switch_xml_t *node, switch_event_t *params, switch_xml_t *language, switch_xml_t *phrases, switch_xml_t *macros, const char *str_language);

View File

@ -81,7 +81,7 @@ static int parse_exten(switch_event_t *event, switch_xml_t xexten, switch_event_
switch_bool_t anti_action = SWITCH_TRUE; switch_bool_t anti_action = SWITCH_TRUE;
break_t do_break_i = BREAK_ON_FALSE; break_t do_break_i = BREAK_ON_FALSE;
int time_match = switch_xml_std_datetime_check(xcond); int time_match = switch_xml_std_datetime_check(xcond, NULL);
switch_safe_free(field_expanded); switch_safe_free(field_expanded);
switch_safe_free(expression_expanded); switch_safe_free(expression_expanded);

View File

@ -87,6 +87,14 @@ static int parse_exten(switch_core_session_t *session, switch_caller_profile_t *
int proceed = 0, save_proceed = 0; int proceed = 0, save_proceed = 0;
char *expression_expanded = NULL, *field_expanded = NULL; char *expression_expanded = NULL, *field_expanded = NULL;
switch_regex_t *re = NULL, *save_re = NULL; switch_regex_t *re = NULL, *save_re = NULL;
int offset = 0;
const char *tzoff = switch_channel_get_variable(channel, "tod_tz_offset");
if (!zstr(tzoff) && switch_is_number(tzoff)) {
offset = atoi(tzoff);
} else {
tzoff = NULL;
}
if (!exten_name) { if (!exten_name) {
exten_name = "_anon_"; exten_name = "_anon_";
@ -102,7 +110,7 @@ static int parse_exten(switch_core_session_t *session, switch_caller_profile_t *
switch_bool_t anti_action = SWITCH_TRUE; switch_bool_t anti_action = SWITCH_TRUE;
break_t do_break_i = BREAK_ON_FALSE; break_t do_break_i = BREAK_ON_FALSE;
int time_match = switch_xml_std_datetime_check(xcond); int time_match = switch_xml_std_datetime_check(xcond, tzoff ? &offset : NULL);
switch_safe_free(field_expanded); switch_safe_free(field_expanded);
switch_safe_free(expression_expanded); switch_safe_free(expression_expanded);
@ -152,7 +160,7 @@ static int parse_exten(switch_core_session_t *session, switch_caller_profile_t *
switch_channel_del_variable_prefix(channel, "DP_REGEX_MATCH"); switch_channel_del_variable_prefix(channel, "DP_REGEX_MATCH");
for (xregex = switch_xml_child(xcond, "regex"); xregex; xregex = xregex->next) { for (xregex = switch_xml_child(xcond, "regex"); xregex; xregex = xregex->next) {
time_match = switch_xml_std_datetime_check(xregex); time_match = switch_xml_std_datetime_check(xregex, tzoff ? &offset : NULL);
if (time_match == 1) { if (time_match == 1) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_DEBUG, switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_DEBUG,

View File

@ -2783,7 +2783,8 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_cut(switch_xml_t xml)
return xml; return xml;
} }
SWITCH_DECLARE(int) switch_xml_std_datetime_check(switch_xml_t xcond) { SWITCH_DECLARE(int) switch_xml_std_datetime_check(switch_xml_t xcond, int *offset)
{
const char *xdt = switch_xml_attr(xcond, "date-time"); const char *xdt = switch_xml_attr(xcond, "date-time");
const char *xyear = switch_xml_attr(xcond, "year"); const char *xyear = switch_xml_attr(xcond, "year");
@ -2797,12 +2798,24 @@ SWITCH_DECLARE(int) switch_xml_std_datetime_check(switch_xml_t xcond) {
const char *xminute = switch_xml_attr(xcond, "minute"); const char *xminute = switch_xml_attr(xcond, "minute");
const char *xminday = switch_xml_attr(xcond, "minute-of-day"); const char *xminday = switch_xml_attr(xcond, "minute-of-day");
const char *xtod = switch_xml_attr(xcond, "time-of-day"); const char *xtod = switch_xml_attr(xcond, "time-of-day");
const char *tzoff = switch_xml_attr(xcond, "tz-offset");
int loffset = 0;
switch_time_t ts = switch_micro_time_now(); switch_time_t ts = switch_micro_time_now();
int time_match = -1; int time_match = -1;
switch_time_exp_t tm; switch_time_exp_t tm;
if (!zstr(tzoff) && switch_is_number(tzoff)) {
loffset = atoi(tzoff);
offset = &loffset;
}
if (offset) {
switch_time_exp_tz(&tm, ts, *offset);
} else {
switch_time_exp_lt(&tm, ts); switch_time_exp_lt(&tm, ts);
}
if (time_match && xdt) { if (time_match && xdt) {
char tmpdate[80]; char tmpdate[80];