add API function for parsing strings to time_t (issue #6320, with mods)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@10105 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Kevin P. Fleming
2006-02-15 00:24:24 +00:00
parent 124b00c4a4
commit 4662d58b01
8 changed files with 66 additions and 72 deletions

View File

@@ -232,8 +232,8 @@ static int acf_strftime(struct ast_channel *chan, char *cmd, char *parse,
AST_APP_ARG(timezone);
AST_APP_ARG(format);
);
long epochi;
struct tm time;
time_t epochi;
struct tm tm;
buf[0] = '\0';
@@ -245,14 +245,13 @@ static int acf_strftime(struct ast_channel *chan, char *cmd, char *parse,
AST_STANDARD_APP_ARGS(args, parse);
if (ast_strlen_zero(args.epoch) || !sscanf(args.epoch, "%ld", &epochi)) {
struct timeval tv = ast_tvnow();
epochi = tv.tv_sec;
}
ast_get_time_t(args.epoch, &epochi, time(NULL));
ast_localtime(&epochi, &tm, args.timezone);
ast_localtime(&epochi, &time, args.timezone);
if (!args.format)
args.format = "%c";
if (!strftime(buf, len, args.format ? args.format : "%c", &time))
if (!strftime(buf, len, args.format, &tm))
ast_log(LOG_WARNING, "C function strftime() output nothing?!!\n");
buf[len - 1] = '\0';