diff --git a/res/res_agi.c b/res/res_agi.c index 3930d67e9d..7c7f6e3d95 100755 --- a/res/res_agi.c +++ b/res/res_agi.c @@ -649,6 +649,43 @@ static int handle_saytime(struct ast_channel *chan, AGI *agi, int argc, char *ar return RESULT_FAILURE; } +static int handle_saydatetime(struct ast_channel *chan, AGI *agi, int argc, char *argv[]) +{ + int res=0; + long unixtime; + char *format, *zone=NULL; + + if (argc < 4) + return RESULT_SHOWUSAGE; + + if (argc > 4) { + format = argv[4]; + } else { + if (!strcasecmp(chan->language, "de")) { + format = "A dBY HMS"; + } else { + format = "ABdY 'digits/at' IMp"; + } + } + + if (argc > 5 && !ast_strlen_zero(argv[5])) + zone = argv[5]; + + if (sscanf(argv[2], "%ld", &unixtime) != 1) + return RESULT_SHOWUSAGE; + + res = ast_say_date_with_format(chan, (time_t) 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; +} + static int handle_sayphonetic(struct ast_channel *chan, AGI *agi, int argc, char *argv[]) { int res; @@ -1389,6 +1426,17 @@ static char usage_saytime[] = " completes without a digit being pressed, or the ASCII numerical value of the\n" " digit if one was pressed or -1 on error/hangup.\n"; +static char usage_saydatetime[] = +" Usage: SAY DATETIME