Skipped content of type multipart/alternative-------------- next part -------------- Index: pbx.c ==================================================================RCS file: /usr/cvsroot/asterisk/pbx.c,v retrieving revision 1.14 diff -u -r1.14 pbx.c --- pbx.c 19 Apr 2003 02:41:22 -0000 1.14 +++ pbx.c 21 Apr 2003 02:27:43 -0000 @@ -713,6 +713,8 @@ { 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 @@ } 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
On Sun, 2003-04-20 at 20:26, Benjamin Miller wrote:> Greetings, > This patch adds two global variables to Asterisk, > EPOCH and DATETIME > These can be used to retrieve the epoch or a datetime stamp (usable in > file names) for the moment these variables are resolved. > > EPOCH is an epoch of course, and DATETIME is DDMMYYYY-HH:MM:SSI'd suggest iso style YYYYMMDD That way things always sort correctly and it's unambiguous. -- Karl Putland <karl@putland.linux-site.net>
This is actually fairly useful. I did the equivalent (again, for a filename like you did) with an AGI. Here is my method below. It's less elegant (requires an AGI call every time) but more flexible (uses the Linux built-in "date" program to produce any number of variations on date/time). I suppose a quick extension could be written into the AGI to also specify the time/date format, but I didn't get that fancy with this version. Contents of the file /var/lib/asterisk/agi-bin/set-timestamp.agi: #!/bin/sh longtime=`date +%Y%m%d-%H%M%S` echo SET VARIABLE timestamp $longtime ;(snippet from extensions.conf) ;Now, I call the AGI: exten => s,1,AGI(set-timestamp.agi) ; and the results are set in $timestamp exten => s,2,SetVar(CALLFILENAME=${timestamp}-${ARG2}-${ARG1}) JT>Greetings, >This patch adds two global variables to Asterisk, >EPOCH and DATETIME >These can be used to retrieve the epoch or a datetime stamp (usable >in file names) for the moment these variables are resolved. > >EPOCH is an epoch of course, and DATETIME is DDMMYYYY-HH:MM:SS >format. Not natively US format for a date, but used more widely for >date stamping files (And it always makes more sense to me that way >any way). > >Until someone writes a fill app_gettime(VARNAME, "format") to make a >customizable date format, this will suffice for many uses. I >imagine one could make a unique, human readable filename by doing: > >${DATETIME)-${CHANNEL}. > >I've sent a copy to Mark as well for approval. >Ben >
Not a bad suggestion. After a brief discussion in #asterisk, I resent the diffs to Mark to make the format: YYYY-MM-DD_HH:MM:SS Ben -----Original Message----- From: Karl Putland [mailto:karl@putland.linux-site.net] Sent: Sunday, April 20, 2003 9:50 PM To: asterisk-users@lists.digium.com Subject: Re: [Asterisk-Users] ${EPOCH} and ${DATETIME} patch On Sun, 2003-04-20 at 20:26, Benjamin Miller wrote:> Greetings, > This patch adds two global variables to Asterisk, > EPOCH and DATETIME > These can be used to retrieve the epoch or a datetime stamp (usable in > file names) for the moment these variables are resolved. > > EPOCH is an epoch of course, and DATETIME is DDMMYYYY-HH:MM:SSI'd suggest iso style YYYYMMDD That way things always sort correctly and it's unambiguous. -- Karl Putland <karl@putland.linux-site.net> _______________________________________________ Asterisk-Users mailing list Asterisk-Users@lists.digium.com http://lists.digium.com/mailman/listinfo/asterisk-users
i need to set the AbsoluteTimeout and value of Dial from an perl AGI script. i dont know if there is a way to set the absolutetimeout from within AGI so i can only think that i need to pass a variable out of the script and into the extensions.conf. i know you can dial out from an AGI - but doesnt it use the console dial? what happens if i want to dial several times with the same AGI? the email below shows a method, but im not entirely sure i understand how it works if i want the variable to be set differently each time from the perl AGI script. any ideas on a better way to do this? exten => s,1,AGI,plt_record.agi exten => s,2,AbsoluteTimeout,${timeout}-${ARG1} exten => s,3,Dial,${dialednumber}-${ARG1} thanks duncan>This is actually fairly useful. I did the equivalent (again, for a >filename like you did) with an AGI. Here is my method below. It's less >elegant (requires an AGI call every time) but more flexible (uses the >Linux built-in "date" program to produce any number of variations on >date/time). I suppose a quick extension could be written into the AGI to >also specify the time/date format, but I didn't get that fancy with this >version. > >Contents of the file /var/lib/asterisk/agi-bin/set-timestamp.agi: > >#!/bin/sh >longtime=`date +%Y%m%d-%H%M%S` >echo SET VARIABLE timestamp $longtime > >;(snippet from extensions.conf) >;Now, I call the AGI: >exten => s,1,AGI(set-timestamp.agi) >; and the results are set in $timestamp >exten => s,2,SetVar(CALLFILENAME=${timestamp}-${ARG2}-${ARG1})