rendered paste body===================================================================
--- funcs/func_strings.c (revision 4176)
+++ funcs/func_strings.c (working copy)
@@ -217,24 +217,27 @@
static char *acf_strftime(struct opbx_channel *chan, int argc, char **argv, char *buf, size_t len)
{
- char *epoch;
+ char *epoch = NULL;
+ char *timezone = NULL;
+ char *format = "%c";
long epochi;
struct tm time;
+ if ( (argc>0) && (!opbx_strlen_zero(argv[0])) ) epoch=argv[0];
+ if ( (argc>1) && (!opbx_strlen_zero(argv[1])) ) timezone=argv[1];
+ if ( (argc>2) && (!opbx_strlen_zero(argv[2])) ) format=argv[2];
+
if (argc < 1 || !argv[0][0] || !sscanf(epoch, "%ld", &epochi)) {
struct timeval tv = opbx_tvnow();
epochi = tv.tv_sec;
}
-
buf[0] = '\0';
+ opbx_localtime(&epochi, &time, timezone );
- opbx_localtime(&epochi, &time, (argc > 1 && argv[1][0] ? argv[1] : NULL));
-
- if (!strftime(buf, len, (argc > 2 && argv[2][0] ? argv[2] : "%c"), &time)) {
+ if (!strftime(buf, len, format, &time)) {
opbx_log(LOG_WARNING, "C function strftime() output nothing?!!\n");
}
buf[len - 1] = '\0';
-
return buf;
}