static char *my_timeout; /* 5 */
static char *my_retries; /* 3 */
static char my_servers[SERVER_MAX][255];
+static const char *my_timezone=""; /* Asia/Tokyo */
static rc_handle *my_radius_init(void)
{
char *uuid_str;
switch_time_exp_t tm;
+ switch_time_exp_t requested_tm;
char buffer[32];
char *radius_avpair_data;
goto end;
}
+ /* GMT offset may change according daylight saving rules. Evaluating GMT offset each time */
+ if (zstr(my_timezone)) {
+ switch_time_exp_lt(&requested_tm, switch_micro_time_now());
+ } else {
+ switch_time_exp_tz_name(my_timezone, &requested_tm, switch_micro_time_now());
+ }
+
/* Create the radius packet */
/* Set Status Type */
}
}
if (callstartdate > 0) {
- switch_time_exp_lt(&tm, callstartdate);
+ switch_time_exp_tz(&tm, callstartdate, requested_tm.tm_gmtoff);
switch_snprintf(buffer, sizeof(buffer), "%04u-%02u-%02uT%02u:%02u:%02u.%06u%+03d%02d",
tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
tm.tm_hour, tm.tm_min, tm.tm_sec, tm.tm_usec, tm.tm_gmtoff / 3600, tm.tm_gmtoff % 3600);
}
if (callanswerdate > 0) {
- switch_time_exp_lt(&tm, callanswerdate);
+ switch_time_exp_tz(&tm, callanswerdate, requested_tm.tm_gmtoff);
switch_snprintf(buffer, sizeof(buffer), "%04u-%02u-%02uT%02u:%02u:%02u.%06u%+03d%02d",
tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
tm.tm_hour, tm.tm_min, tm.tm_sec, tm.tm_usec, tm.tm_gmtoff / 3600, tm.tm_gmtoff % 3600);
}
if (calltransferdate > 0) {
- switch_time_exp_lt(&tm, calltransferdate);
+ switch_time_exp_tz(&tm, calltransferdate, requested_tm.tm_gmtoff);
switch_snprintf(buffer, sizeof(buffer), "%04u-%02u-%02uT%02u:%02u:%02u.%06u%+03d%02d",
tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
tm.tm_hour, tm.tm_min, tm.tm_sec, tm.tm_usec, tm.tm_gmtoff / 3600, tm.tm_gmtoff % 3600);
}
if (callenddate > 0) {
- switch_time_exp_lt(&tm, callenddate);
+ switch_time_exp_tz(&tm, callenddate, requested_tm.tm_gmtoff);
switch_snprintf(buffer, sizeof(buffer), "%04u-%02u-%02uT%02u:%02u:%02u.%06u%+03d%02d",
tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
tm.tm_hour, tm.tm_min, tm.tm_sec, tm.tm_usec, tm.tm_gmtoff / 3600, tm.tm_gmtoff % 3600);
char *uuid_str;
switch_time_exp_t tm;
+ switch_time_exp_t requested_tm;
+
char buffer[32] = "";
char *radius_avpair_data;
goto end;
}
+ /* GMT offset may change according daylight saving rules. Evaluating GMT offset each time */
+ if (zstr(my_timezone)) {
+ switch_time_exp_lt(&requested_tm, time(NULL));
+ } else {
+ switch_time_exp_tz_name(my_timezone, &requested_tm, time(NULL));
+ }
+
/* Create the radius packet */
/* Set Status Type */
}
if (callstartdate > 0) {
- switch_time_exp_lt(&tm, callstartdate);
+ switch_time_exp_tz(&tm, callstartdate, requested_tm.tm_gmtoff);
switch_snprintf(buffer, sizeof(buffer), "%04u-%02u-%02uT%02u:%02u:%02u.%06u%+03d%02d",
tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
tm.tm_hour, tm.tm_min, tm.tm_sec, tm.tm_usec, tm.tm_gmtoff / 3600, tm.tm_gmtoff % 3600);
}
if (callanswerdate > 0) {
- switch_time_exp_lt(&tm, callanswerdate);
+ switch_time_exp_tz(&tm, callanswerdate, requested_tm.tm_gmtoff);
switch_snprintf(buffer, sizeof(buffer), "%04u-%02u-%02uT%02u:%02u:%02u.%06u%+03d%02d",
tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
tm.tm_hour, tm.tm_min, tm.tm_sec, tm.tm_usec, tm.tm_gmtoff / 3600, tm.tm_gmtoff % 3600);
}
if (calltransferdate > 0) {
- switch_time_exp_lt(&tm, calltransferdate);
+ switch_time_exp_tz(&tm, calltransferdate, requested_tm.tm_gmtoff);
switch_snprintf(buffer, sizeof(buffer), "%04u-%02u-%02uT%02u:%02u:%02u.%06u%+03d%02d",
tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
tm.tm_hour, tm.tm_min, tm.tm_sec, tm.tm_usec, tm.tm_gmtoff / 3600, tm.tm_gmtoff % 3600);
}
if (callenddate > 0) {
- switch_time_exp_lt(&tm, callenddate);
+ switch_time_exp_tz(&tm, callenddate, requested_tm.tm_gmtoff);
switch_snprintf(buffer, sizeof(buffer), "%04u-%02u-%02uT%02u:%02u:%02u.%06u%+03d%02d",
tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
tm.tm_hour, tm.tm_min, tm.tm_sec, tm.tm_usec, tm.tm_gmtoff / 3600, tm.tm_gmtoff % 3600);
int num_servers = 0;
int i = 0;
+ static char *tz_name;
my_timeout = "5";
my_retries = "3";
my_retries = strdup(val);
} else if (!strcmp(var, "radius_deadtime")) {
my_deadtime = strdup(val);
+ } else if (!strcmp(var, "timezone")) {
+ tz_name = strdup(val);
}
}
}
return SWITCH_STATUS_TERM;
}
+ if (!zstr(tz_name)) {
+ if (switch_lookup_timezone(tz_name)) {
+ my_timezone= tz_name;
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot find timezone %s\n, Setting timezone to GMT", tz_name);
+ my_timezone= "GMT";
+ }
+ }
+
/* If we made it this far, we succeeded */
return SWITCH_STATUS_SUCCESS;
}