summaryrefslogtreecommitdiff
path: root/funcs/func_strings.c
diff options
context:
space:
mode:
authorKevin P. Fleming <kpfleming@digium.com>2006-02-15 00:24:24 +0000
committerKevin P. Fleming <kpfleming@digium.com>2006-02-15 00:24:24 +0000
commit4662d58b01e5493a39697027285bc22deb2f143c (patch)
tree6572dc8ac1336a5e0c0859186138a5313e88bd85 /funcs/func_strings.c
parent124b00c4a4b971d8f4e34c3bbd73c992ad84d20c (diff)
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
Diffstat (limited to 'funcs/func_strings.c')
-rw-r--r--funcs/func_strings.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/funcs/func_strings.c b/funcs/func_strings.c
index 5dafb1f33..4d992b1b5 100644
--- a/funcs/func_strings.c
+++ b/funcs/func_strings.c
@@ -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';