summaryrefslogtreecommitdiff
path: root/pbx.c
diff options
context:
space:
mode:
authorMark Spencer <markster@digium.com>2003-04-21 03:02:22 +0000
committerMark Spencer <markster@digium.com>2003-04-21 03:02:22 +0000
commit5d3958b794402db3b3cf6958ee6a5a924f007c16 (patch)
tree879a6e81223aee0c2be265d543bbb57abe45a2df /pbx.c
parent0dee7f521bf487f9685c9c2a447c3adc2aef6273 (diff)
Add epoch and date/time variables
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@876 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'pbx.c')
-rwxr-xr-xpbx.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/pbx.c b/pbx.c
index e454ed786..18e6eb41d 100755
--- a/pbx.c
+++ b/pbx.c
@@ -713,6 +713,8 @@ static void pbx_substitute_variables_temp(struct ast_channel *c,const char *var,
{
char *first,*second;
char tmpvar[80] = "";
+ time_t thistime;
+ struct tm brokentime;
int offset,offset2;
struct ast_var_t *variables;
char *name, *num; /* for callerid name + num variables */
@@ -807,6 +809,21 @@ static void pbx_substitute_variables_temp(struct ast_channel *c,const char *var,
} else if (!strcmp(var, "CHANNEL")) {
strncpy(workspace, c->name, workspacelen - 1);
*ret = workspace;
+ } else if (!strcmp(var, "EPOCH")) {
+ snprintf(workspace, workspacelen -1, "%u",(int)time(NULL));
+ *ret = workspace;
+ } else if (!strcmp(var, "DATETIME")) {
+ thistime=time(NULL);
+ localtime_r(&thistime, &brokentime);
+ snprintf(workspace, workspacelen -1, "%02d%02d%04d-%02d:%02d:%02d",
+ brokentime.tm_mday,
+ brokentime.tm_mon+1,
+ brokentime.tm_year+1900,
+ brokentime.tm_hour,
+ brokentime.tm_min,
+ brokentime.tm_sec
+ );
+ *ret = workspace;
} else {
AST_LIST_TRAVERSE(headp,variables,entries) {
#if 0