diff options
author | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-02-15 00:24:24 +0000 |
---|---|---|
committer | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-02-15 00:24:24 +0000 |
commit | 15db46a445a4d6d71993475369b4a4906861f362 (patch) | |
tree | 6572dc8ac1336a5e0c0859186138a5313e88bd85 /funcs/func_strings.c | |
parent | 69f7e69869d726709046bffd71fd109b7dc4560d (diff) |
add API function for parsing strings to time_t (issue #6320, with mods)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@10105 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'funcs/func_strings.c')
-rw-r--r-- | funcs/func_strings.c | 15 |
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'; |