Merge branch 'master' of ssh://git.freeswitch.org:222/freeswitch

This commit is contained in:
Giovanni Maruzzelli 2011-07-13 08:44:32 -05:00
commit e486677538
1 changed files with 7 additions and 6 deletions

View File

@ -1352,27 +1352,28 @@ SWITCH_STANDARD_API(strftime_api_function)
switch_time_exp_t tm; switch_time_exp_t tm;
char date[80] = ""; char date[80] = "";
switch_time_t thetime; switch_time_t thetime;
char *p; char *p, *q = NULL;
char *mycmd = NULL; char *mycmd = NULL;
if (!zstr(cmd)) { if (!zstr(cmd)) {
mycmd = strdup(cmd); mycmd = strdup(cmd);
q = mycmd;
} }
if (!zstr(mycmd) && (p = strchr(mycmd, '|'))) { if (!zstr(q) && (p = strchr(q, '|'))) {
*p++ = '\0'; *p++ = '\0';
thetime = switch_time_make(atol(mycmd), 0); thetime = switch_time_make(atol(q), 0);
mycmd = p + 1; q = p + 1;
} else { } else {
thetime = switch_micro_time_now(); thetime = switch_micro_time_now();
} }
switch_time_exp_lt(&tm, thetime); switch_time_exp_lt(&tm, thetime);
if (zstr(mycmd)) { if (zstr(q)) {
switch_strftime_nocheck(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm); switch_strftime_nocheck(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm);
} else { } else {
switch_strftime(date, &retsize, sizeof(date), mycmd, &tm); switch_strftime(date, &retsize, sizeof(date), q, &tm);
} }
stream->write_function(stream, "%s", date); stream->write_function(stream, "%s", date);
switch_safe_free(mycmd); switch_safe_free(mycmd);