[Asterisk-Users] ${EPOCH} and ${DATETIME} patch
John Todd
jtodd at loligo.com
Sun Apr 20 20:10:32 MST 2003
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
>
More information about the asterisk-users
mailing list