[Asterisk-Dev] DATETIME Variable or TIME in general

John Todd jtodd at loligo.com
Mon Oct 6 23:54:26 MST 2003


>Which format _should_ be correct? Code or Readme.  Currently I have to do
>AGI to fix this would prefer not to have to.  Any objections to changing to
>non-punctuated ISO format of:
>
>YYYYMMDDTHHMMSSTZD
>   for today
>20031006T120234-0500
>
>And also adding a Standard Variable of something like ${ISOTIME} for
>everyone to use.  Would be very useful for many things including file names
>and easy to parse!
>
>
>-Nicholas
>
>
>----------
>
>Readme Says this:
>
>${DATETIME} Current date time in the format: YYYY-MM-DD_HH:MM:SS
>
>Code says this:
>
>  } else if (c && !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;

It doesn't seem like a big issue to create an ISOTIME string.  Why 
don't you create the routine and submit it as a feature request to 
the bugtracker (http://bugs.digium.com/)?  I, too, have been using an 
AGI hack to get the time into the "correct" format, since ${DATETIME} 
doesn't have a logical ordering to the values.

JT



More information about the asterisk-dev mailing list