mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 20:20:07 +00:00
Permit dates and times to be stored in timezones other than the default (typically, UTC)
(closes issue #16401) Reported by: lordmortis git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@239152 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -66,7 +66,7 @@ static const char desc[] = "MySQL CDR Backend";
|
|||||||
static const char name[] = "mysql";
|
static const char name[] = "mysql";
|
||||||
static const char config[] = "cdr_mysql.conf";
|
static const char config[] = "cdr_mysql.conf";
|
||||||
|
|
||||||
static struct ast_str *hostname = NULL, *dbname = NULL, *dbuser = NULL, *password = NULL, *dbsock = NULL, *dbtable = NULL, *dbcharset = NULL;
|
static struct ast_str *hostname = NULL, *dbname = NULL, *dbuser = NULL, *password = NULL, *dbsock = NULL, *dbtable = NULL, *dbcharset = NULL, *cdrzone = NULL;
|
||||||
|
|
||||||
static struct ast_str *ssl_ca = NULL, *ssl_cert = NULL, *ssl_key = NULL;
|
static struct ast_str *ssl_ca = NULL, *ssl_cert = NULL, *ssl_key = NULL;
|
||||||
|
|
||||||
@@ -247,7 +247,7 @@ db_reconnect:
|
|||||||
struct timeval tv = ast_tvnow();
|
struct timeval tv = ast_tvnow();
|
||||||
struct ast_tm tm;
|
struct ast_tm tm;
|
||||||
char timestr[128];
|
char timestr[128];
|
||||||
ast_localtime(&tv, &tm, NULL);
|
ast_localtime(&tv, &tm, ast_str_strlen(cdrzone) ? ast_str_buffer(cdrzone) : NULL);
|
||||||
ast_strftime(timestr, sizeof(timestr), "%Y-%m-%d %T", &tm);
|
ast_strftime(timestr, sizeof(timestr), "%Y-%m-%d %T", &tm);
|
||||||
ast_cdr_setvar(cdr, "calldate", timestr, 0);
|
ast_cdr_setvar(cdr, "calldate", timestr, 0);
|
||||||
cdrname = "calldate";
|
cdrname = "calldate";
|
||||||
@@ -444,6 +444,15 @@ static int my_load_module(int reload)
|
|||||||
res |= my_load_config_number(cfg, "global", "port", &dbport, 0);
|
res |= my_load_config_number(cfg, "global", "port", &dbport, 0);
|
||||||
res |= my_load_config_number(cfg, "global", "timeout", &timeout, 0);
|
res |= my_load_config_number(cfg, "global", "timeout", &timeout, 0);
|
||||||
res |= my_load_config_string(cfg, "global", "compat", &compat, "no");
|
res |= my_load_config_string(cfg, "global", "compat", &compat, "no");
|
||||||
|
res |= my_load_config_string(cfg, "global", "cdrzone", &cdrzone, "");
|
||||||
|
if (ast_str_strlen(cdrzone) == 0) {
|
||||||
|
for (; var; var = var->next) {
|
||||||
|
if (!strcasecmp(var->name, "usegmtime") && ast_true(var->value)) {
|
||||||
|
ast_str_set(&cdrzone, 0, "UTC");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ast_true(ast_str_buffer(compat))) {
|
if (ast_true(ast_str_buffer(compat))) {
|
||||||
calldate_compat = 1;
|
calldate_compat = 1;
|
||||||
} else {
|
} else {
|
||||||
@@ -475,6 +484,7 @@ static int my_load_module(int reload)
|
|||||||
ast_debug(1, "Got dbname of %s\n", ast_str_buffer(dbname));
|
ast_debug(1, "Got dbname of %s\n", ast_str_buffer(dbname));
|
||||||
ast_debug(1, "Got password of %s\n", ast_str_buffer(password));
|
ast_debug(1, "Got password of %s\n", ast_str_buffer(password));
|
||||||
ast_debug(1, "%sunning in calldate compatibility mode\n", calldate_compat ? "R" : "Not r");
|
ast_debug(1, "%sunning in calldate compatibility mode\n", calldate_compat ? "R" : "Not r");
|
||||||
|
ast_debug(1, "Dates and times are localized to %s\n", S_OR(ast_str_buffer(cdrzone), "local timezone"));
|
||||||
|
|
||||||
if (dbcharset) {
|
if (dbcharset) {
|
||||||
ast_debug(1, "Got DB charset of %s\n", ast_str_buffer(dbcharset));
|
ast_debug(1, "Got DB charset of %s\n", ast_str_buffer(dbcharset));
|
||||||
|
@@ -18,6 +18,7 @@
|
|||||||
;user=asteriskcdruser
|
;user=asteriskcdruser
|
||||||
;port=3306
|
;port=3306
|
||||||
;sock=/tmp/mysql.sock
|
;sock=/tmp/mysql.sock
|
||||||
|
;timezone=UTC ; Previously called usegmtime
|
||||||
;
|
;
|
||||||
; If your system's locale differs from mysql database character set,
|
; If your system's locale differs from mysql database character set,
|
||||||
; cdr_mysql can damage non-latin characters in CDR variables. Use this
|
; cdr_mysql can damage non-latin characters in CDR variables. Use this
|
||||||
|
Reference in New Issue
Block a user