[asterisk-commits] cdr mysql: fix UTC support (asterisk[11])
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Sep 22 07:21:49 CDT 2016
Anonymous Coward #1000019 has submitted this change and it was merged.
Change subject: cdr_mysql: fix UTC support
......................................................................
cdr_mysql: fix UTC support
* Make 'cdrzone=UTC' work properly.
* Fix the documentation of cdr_mysql.conf: it's cdrzone and not timezone
ASTERISK-26359 #close
Change-Id: I2a6f67b71bbbe77cac31a34d0bbfb1d67c933778
(cherry picked from commit d3ddf4b0fdaf3e9562ede947c2367031434b3b5e)
---
M addons/cdr_mysql.c
M configs/cdr_mysql.conf.sample
2 files changed, 14 insertions(+), 4 deletions(-)
Approvals:
Anonymous Coward #1000019: Verified
Joshua Colp: Looks good to me, approved
diff --git a/addons/cdr_mysql.c b/addons/cdr_mysql.c
index b87d8c6..16b5337 100644
--- a/addons/cdr_mysql.c
+++ b/addons/cdr_mysql.c
@@ -250,7 +250,7 @@
struct ast_tm tm;
char timestr[128];
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), DATE_FORMAT, &tm);
ast_cdr_setvar(cdr, "calldate", timestr, 0);
cdrname = "calldate";
} else {
@@ -265,8 +265,7 @@
/* Need the type and value to determine if we want the raw value or not */
if (entry->staticvalue) {
value = ast_strdupa(entry->staticvalue);
- } else if ((!strcmp(cdrname, "start") ||
- !strcmp(cdrname, "answer") ||
+ } else if ((!strcmp(cdrname, "answer") ||
!strcmp(cdrname, "end") ||
!strcmp(cdrname, "disposition") ||
!strcmp(cdrname, "amaflags")) &&
@@ -278,6 +277,14 @@
strstr(entry->type, "numeric") ||
strstr(entry->type, "fixed"))) {
ast_cdr_getvar(cdr, cdrname, &value, workspace, sizeof(workspace), 0, 1);
+ } else if (!strcmp(cdrname, "start")) {
+ struct ast_tm tm;
+ char timestr[128];
+ ast_localtime(&cdr->start, &tm, ast_str_strlen(cdrzone) ? ast_str_buffer(cdrzone) : NULL);
+ ast_strftime(timestr, sizeof(timestr), DATE_FORMAT, &tm);
+ value = ast_strdupa(timestr);
+ } else if (!strcmp(cdrname, "calldate")) {
+ /* Skip calldate - the value has already been dup'd */
} else {
ast_cdr_getvar(cdr, cdrname, &value, workspace, sizeof(workspace), 0, 0);
}
diff --git a/configs/cdr_mysql.conf.sample b/configs/cdr_mysql.conf.sample
index 04b7049..e15a8ed 100644
--- a/configs/cdr_mysql.conf.sample
+++ b/configs/cdr_mysql.conf.sample
@@ -18,7 +18,10 @@
;user=asteriskcdruser
;port=3306
;sock=/tmp/mysql.sock
-;timezone=UTC ; Previously called usegmtime
+; By default CDRs are logged in the system's time zone
+;cdrzone=UTC ; log CDRs with UTC
+;usegmtime=yes ;log date/time in GMT. Default is "no"
+;cdrzone=America/New_York ; or use a specific time zone
;
; If your system's locale differs from mysql database character set,
; cdr_mysql can damage non-latin characters in CDR variables. Use this
--
To view, visit https://gerrit.asterisk.org/3950
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I2a6f67b71bbbe77cac31a34d0bbfb1d67c933778
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 11
Gerrit-Owner: Tzafrir Cohen <tzafrir.cohen at xorcom.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
More information about the asterisk-commits
mailing list