From 15db46a445a4d6d71993475369b4a4906861f362 Mon Sep 17 00:00:00 2001 From: kpfleming Date: Wed, 15 Feb 2006 00:24:24 +0000 Subject: 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 --- res/res_agi.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'res/res_agi.c') diff --git a/res/res_agi.c b/res/res_agi.c index 85436a672..ef7576fcd 100644 --- a/res/res_agi.c +++ b/res/res_agi.c @@ -742,16 +742,13 @@ static int handle_saytime(struct ast_channel *chan, AGI *agi, int argc, char *ar if (res == 1) return RESULT_SUCCESS; fdprintf(agi->fd, "200 result=%d\n", res); - if (res >= 0) - return RESULT_SUCCESS; - else - return RESULT_FAILURE; + return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE; } static int handle_saydatetime(struct ast_channel *chan, AGI *agi, int argc, char *argv[]) { int res=0; - long unixtime; + time_t unixtime; char *format, *zone=NULL; if (argc < 4) @@ -770,19 +767,15 @@ static int handle_saydatetime(struct ast_channel *chan, AGI *agi, int argc, char if (argc > 5 && !ast_strlen_zero(argv[5])) zone = argv[5]; - if (sscanf(argv[2], "%ld", &unixtime) != 1) + if (ast_get_time_t(argv[2], &unixtime, 0)) return RESULT_SHOWUSAGE; - res = ast_say_date_with_format(chan, (time_t) unixtime, argv[3], chan->language, format, zone); + res = ast_say_date_with_format(chan, unixtime, argv[3], chan->language, format, zone); if (res == 1) return RESULT_SUCCESS; fdprintf(agi->fd, "200 result=%d\n", res); - - if (res >= 0) - return RESULT_SUCCESS; - else - return RESULT_FAILURE; + return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE; } static int handle_sayphonetic(struct ast_channel *chan, AGI *agi, int argc, char *argv[]) -- cgit v1.2.3