|
|
|
@ -456,6 +456,7 @@ static int ast_say_date_nl(struct ast_channel *chan, time_t t, char *ints, char
|
|
|
|
|
static int ast_say_date_pt(struct ast_channel *chan, time_t t, char *ints, char *lang);
|
|
|
|
|
|
|
|
|
|
static int ast_say_date_with_format_en(struct ast_channel *chan, time_t time, char *ints, char *lang, char *format, char *timezone);
|
|
|
|
|
static int ast_say_date_with_format_de(struct ast_channel *chan, time_t time, char *ints, char *lang, char *format, char *timezone);
|
|
|
|
|
static int ast_say_date_with_format_es(struct ast_channel *chan, time_t time, char *ints, char *lang, char *format, char *timezone);
|
|
|
|
|
static int ast_say_date_with_format_nl(struct ast_channel *chan, time_t time, char *ints, char *lang, char *format, char *timezone);
|
|
|
|
|
static int ast_say_date_with_format_pt(struct ast_channel *chan, time_t time, char *ints, char *lang, char *format, char *timezone);
|
|
|
|
@ -699,33 +700,44 @@ static int ast_say_number_full_da(struct ast_channel *chan, int num, char *ints,
|
|
|
|
|
|
|
|
|
|
/*--- ast_say_number_full_de: German syntax */
|
|
|
|
|
/* New files:
|
|
|
|
|
In addition to English, the following sounds are required: "millions", "and" and "1-and" through "9-and"
|
|
|
|
|
In addition to English, the following sounds are required:
|
|
|
|
|
"millions"
|
|
|
|
|
"1-and" through "9-and"
|
|
|
|
|
"1F" (eine)
|
|
|
|
|
"1N" (ein)
|
|
|
|
|
NB "1" is recorded as 'eins'
|
|
|
|
|
*/
|
|
|
|
|
static int ast_say_number_full_de(struct ast_channel *chan, int num, char *ints, char *language, char *options, int audiofd, int ctrlfd)
|
|
|
|
|
{
|
|
|
|
|
int res = 0;
|
|
|
|
|
int playh = 0;
|
|
|
|
|
int playa = 0;
|
|
|
|
|
int t = 0;
|
|
|
|
|
int mf = 1; /* +1 = Male, Neutrum; -1 = Female */
|
|
|
|
|
char fn[256] = "";
|
|
|
|
|
char fna[256] = "";
|
|
|
|
|
if (!num)
|
|
|
|
|
return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd);
|
|
|
|
|
|
|
|
|
|
while(!res && (num || playh || playa )) {
|
|
|
|
|
if (options && (!strncasecmp(options, "f",1)))
|
|
|
|
|
mf = -1;
|
|
|
|
|
|
|
|
|
|
while(!res && (num || playh)) {
|
|
|
|
|
/* The grammar for German numbers is the same as for English except
|
|
|
|
|
* for the following:
|
|
|
|
|
* - numbers 20 through 99 are said in reverse order, i.e. 21 is
|
|
|
|
|
* "one-and twenty" and 68 is "eight-and sixty".
|
|
|
|
|
* - "one" varies according to gender
|
|
|
|
|
* - 100 is 'hundert', however all other instances are 'ein hundert'
|
|
|
|
|
* - 1000 is 'tausend', however all other instances are 'ein tausend'
|
|
|
|
|
* - 1000000 is always 'ein million'
|
|
|
|
|
* - "million" is different in singular and plural form
|
|
|
|
|
* - numbers > 1000 with zero as the third digit from last have an
|
|
|
|
|
* "and" before the last two digits, i.e. 2034 is "two thousand and
|
|
|
|
|
* four-and thirty" and 1000012 is "one million and twelve".
|
|
|
|
|
*/
|
|
|
|
|
if (playh) {
|
|
|
|
|
snprintf(fn, sizeof(fn), "digits/hundred");
|
|
|
|
|
playh = 0;
|
|
|
|
|
} else if (playa) {
|
|
|
|
|
snprintf(fn, sizeof(fn), "digits/and");
|
|
|
|
|
playa = 0;
|
|
|
|
|
} else if (num == 1 && mf == -1) {
|
|
|
|
|
snprintf(fn, sizeof(fn), "digits/%dF", num);
|
|
|
|
|
num = 0;
|
|
|
|
|
} else if (num < 20) {
|
|
|
|
|
snprintf(fn, sizeof(fn), "digits/%d", num);
|
|
|
|
|
num = 0;
|
|
|
|
@ -738,43 +750,49 @@ static int ast_say_number_full_de(struct ast_channel *chan, int num, char *ints,
|
|
|
|
|
snprintf(fn, sizeof(fn), "digits/%d", num);
|
|
|
|
|
num = 0;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (num < 1000) {
|
|
|
|
|
int hundreds = num / 100;
|
|
|
|
|
if (hundreds == 1)
|
|
|
|
|
snprintf(fn, sizeof(fn), "digits/1N");
|
|
|
|
|
else
|
|
|
|
|
snprintf(fn, sizeof(fn), "digits/%d", (num / 100));
|
|
|
|
|
playh++;
|
|
|
|
|
num -= 100 * hundreds;
|
|
|
|
|
if (num)
|
|
|
|
|
playa++;
|
|
|
|
|
} else if (num == 100) {
|
|
|
|
|
snprintf(fn, sizeof(fn), "digits/hundred");
|
|
|
|
|
num = num - 100;
|
|
|
|
|
} else if (num < 1000) {
|
|
|
|
|
int hundreds = num / 100;
|
|
|
|
|
if (hundreds == 1)
|
|
|
|
|
snprintf(fn, sizeof(fn), "digits/1N");
|
|
|
|
|
else
|
|
|
|
|
snprintf(fn, sizeof(fn), "digits/%d", (num / 100));
|
|
|
|
|
playh++;
|
|
|
|
|
num -= 100 * hundreds;
|
|
|
|
|
} else if (num == 1000 && t == 0) {
|
|
|
|
|
snprintf(fn, sizeof(fn), "digits/thousand");
|
|
|
|
|
num = 0;
|
|
|
|
|
} else if (num < 1000000) {
|
|
|
|
|
t = 1;
|
|
|
|
|
int thousands = num / 1000;
|
|
|
|
|
if (thousands == 1) {
|
|
|
|
|
snprintf(fn, sizeof(fn), "digits/1N");
|
|
|
|
|
snprintf(fna, sizeof(fna), "digits/thousand");
|
|
|
|
|
} else {
|
|
|
|
|
if (num < 1000000) {
|
|
|
|
|
res = ast_say_number_full_de(chan, num / 1000, ints, language, options, audiofd, ctrlfd);
|
|
|
|
|
if (res)
|
|
|
|
|
return res;
|
|
|
|
|
num = num % 1000;
|
|
|
|
|
snprintf(fn, sizeof(fn), "digits/thousand");
|
|
|
|
|
} else {
|
|
|
|
|
if (num < 1000000000) {
|
|
|
|
|
int millions = num / 1000000;
|
|
|
|
|
res = ast_say_number_full_de(chan, millions, ints, language, options, audiofd, ctrlfd);
|
|
|
|
|
if (res)
|
|
|
|
|
return res;
|
|
|
|
|
if (millions == 1)
|
|
|
|
|
snprintf(fn, sizeof(fn), "digits/million");
|
|
|
|
|
else
|
|
|
|
|
snprintf(fn, sizeof(fn), "digits/millions");
|
|
|
|
|
num = num % 1000000;
|
|
|
|
|
} else {
|
|
|
|
|
ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
|
|
|
|
|
res = -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (num && num < 100)
|
|
|
|
|
playa++;
|
|
|
|
|
res = ast_say_number_full_de(chan, thousands, ints, language, options, audiofd, ctrlfd);
|
|
|
|
|
if (res)
|
|
|
|
|
return res;
|
|
|
|
|
snprintf(fn, sizeof(fn), "digits/thousand");
|
|
|
|
|
}
|
|
|
|
|
num = num % 1000;
|
|
|
|
|
} else if (num < 1000000000) {
|
|
|
|
|
t = 1;
|
|
|
|
|
int millions = num / 1000000;
|
|
|
|
|
if (millions == 1) {
|
|
|
|
|
snprintf(fn, sizeof(fn), "digits/1N");
|
|
|
|
|
snprintf(fna, sizeof(fna), "digits/million");
|
|
|
|
|
} else {
|
|
|
|
|
res = ast_say_number_full_de(chan, millions, ints, language, options, audiofd, ctrlfd);
|
|
|
|
|
if (res)
|
|
|
|
|
return res;
|
|
|
|
|
snprintf(fn, sizeof(fn), "digits/millions");
|
|
|
|
|
}
|
|
|
|
|
num = num % 1000000;
|
|
|
|
|
} else {
|
|
|
|
|
ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
|
|
|
|
|
res = -1;
|
|
|
|
|
}
|
|
|
|
|
if (!res) {
|
|
|
|
|
if(!ast_streamfile(chan, fn, language)) {
|
|
|
|
@ -784,6 +802,14 @@ static int ast_say_number_full_de(struct ast_channel *chan, int num, char *ints,
|
|
|
|
|
res = ast_waitstream(chan, ints);
|
|
|
|
|
}
|
|
|
|
|
ast_stopstream(chan);
|
|
|
|
|
if(!ast_streamfile(chan, fna, language)) {
|
|
|
|
|
if (audiofd && ctrlfd)
|
|
|
|
|
res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
|
|
|
|
|
else
|
|
|
|
|
res = ast_waitstream(chan, ints);
|
|
|
|
|
}
|
|
|
|
|
ast_stopstream(chan);
|
|
|
|
|
strcpy(fna, "");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return res;
|
|
|
|
@ -1431,6 +1457,8 @@ int ast_say_date_with_format(struct ast_channel *chan, time_t time, char *ints,
|
|
|
|
|
{
|
|
|
|
|
if (!strcasecmp(lang, "en") ) { /* English syntax */
|
|
|
|
|
return(ast_say_date_with_format_en(chan, time, ints, lang, format, timezone));
|
|
|
|
|
} else if (!strcasecmp(lang, "de") ) { /* German syntax */
|
|
|
|
|
return(ast_say_date_with_format_de(chan, time, ints, lang, format, timezone));
|
|
|
|
|
} else if (!strcasecmp(lang, "es") || !strcasecmp(lang, "mx")) { /* Spanish syntax */
|
|
|
|
|
return(ast_say_date_with_format_es(chan, time, ints, lang, format, timezone));
|
|
|
|
|
} else if (!strcasecmp(lang, "nl") ) { /* Dutch syntax */
|
|
|
|
@ -1724,6 +1752,288 @@ int ast_say_date_with_format_en(struct ast_channel *chan, time_t time, char *int
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* German syntax */
|
|
|
|
|
/* NB This currently is a 100% clone of the English syntax, just getting ready to make changes... */
|
|
|
|
|
int ast_say_date_with_format_de(struct ast_channel *chan, time_t time, char *ints, char *lang, char *format, char *timezone)
|
|
|
|
|
{
|
|
|
|
|
struct tm tm;
|
|
|
|
|
int res=0, offset, sndoffset;
|
|
|
|
|
char sndfile[256], nextmsg[256];
|
|
|
|
|
|
|
|
|
|
ast_localtime(&time,&tm,timezone);
|
|
|
|
|
|
|
|
|
|
for (offset=0 ; format[offset] != '\0' ; offset++) {
|
|
|
|
|
ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
|
|
|
|
|
switch (format[offset]) {
|
|
|
|
|
/* NOTE: if you add more options here, please try to be consistent with strftime(3) */
|
|
|
|
|
case '\'':
|
|
|
|
|
/* Literal name of a sound file */
|
|
|
|
|
sndoffset=0;
|
|
|
|
|
for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < 256) ; sndoffset++)
|
|
|
|
|
sndfile[sndoffset] = format[offset];
|
|
|
|
|
sndfile[sndoffset] = '\0';
|
|
|
|
|
snprintf(nextmsg,sizeof(nextmsg), AST_SOUNDS "/%s", sndfile);
|
|
|
|
|
res = wait_file(chan,ints,nextmsg,lang);
|
|
|
|
|
break;
|
|
|
|
|
case 'A':
|
|
|
|
|
case 'a':
|
|
|
|
|
/* Sunday - Saturday */
|
|
|
|
|
snprintf(nextmsg,sizeof(nextmsg), "digits/day-%d", tm.tm_wday);
|
|
|
|
|
res = wait_file(chan,ints,nextmsg,lang);
|
|
|
|
|
break;
|
|
|
|
|
case 'B':
|
|
|
|
|
case 'b':
|
|
|
|
|
case 'h':
|
|
|
|
|
/* January - December */
|
|
|
|
|
snprintf(nextmsg,sizeof(nextmsg), "digits/mon-%d", tm.tm_mon);
|
|
|
|
|
res = wait_file(chan,ints,nextmsg,lang);
|
|
|
|
|
break;
|
|
|
|
|
case 'd':
|
|
|
|
|
case 'e':
|
|
|
|
|
/* First - Thirtyfirst */
|
|
|
|
|
if ((tm.tm_mday < 21) || (tm.tm_mday == 30)) {
|
|
|
|
|
snprintf(nextmsg,sizeof(nextmsg), "digits/h-%d", tm.tm_mday);
|
|
|
|
|
res = wait_file(chan,ints,nextmsg,lang);
|
|
|
|
|
} else if (tm.tm_mday == 31) {
|
|
|
|
|
/* "Thirty" and "first" */
|
|
|
|
|
res = wait_file(chan,ints, "digits/30",lang);
|
|
|
|
|
if (!res) {
|
|
|
|
|
res = wait_file(chan,ints, "digits/h-1",lang);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
/* Between 21 and 29 - two sounds */
|
|
|
|
|
res = wait_file(chan,ints, "digits/20",lang);
|
|
|
|
|
if (!res) {
|
|
|
|
|
snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_mday - 20);
|
|
|
|
|
res = wait_file(chan,ints,nextmsg,lang);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 'Y':
|
|
|
|
|
/* Year */
|
|
|
|
|
if (tm.tm_year > 99) {
|
|
|
|
|
res = wait_file(chan,ints, "digits/2",lang);
|
|
|
|
|
if (!res) {
|
|
|
|
|
res = wait_file(chan,ints, "digits/thousand",lang);
|
|
|
|
|
}
|
|
|
|
|
if (tm.tm_year > 100) {
|
|
|
|
|
if (!res) {
|
|
|
|
|
/* This works until the end of 2020 */
|
|
|
|
|
snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_year - 100);
|
|
|
|
|
res = wait_file(chan,ints,nextmsg,lang);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (tm.tm_year < 1) {
|
|
|
|
|
/* I'm not going to handle 1900 and prior */
|
|
|
|
|
/* We'll just be silent on the year, instead of bombing out. */
|
|
|
|
|
} else {
|
|
|
|
|
res = wait_file(chan,ints, "digits/19",lang);
|
|
|
|
|
if (!res) {
|
|
|
|
|
if (tm.tm_year <= 9) {
|
|
|
|
|
/* 1901 - 1909 */
|
|
|
|
|
res = wait_file(chan,ints, "digits/oh",lang);
|
|
|
|
|
if (!res) {
|
|
|
|
|
snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_year);
|
|
|
|
|
res = wait_file(chan,ints,nextmsg,lang);
|
|
|
|
|
}
|
|
|
|
|
} else if (tm.tm_year <= 20) {
|
|
|
|
|
/* 1910 - 1920 */
|
|
|
|
|
snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_year);
|
|
|
|
|
res = wait_file(chan,ints,nextmsg,lang);
|
|
|
|
|
} else {
|
|
|
|
|
/* 1921 - 1999 */
|
|
|
|
|
int ten, one;
|
|
|
|
|
ten = tm.tm_year / 10;
|
|
|
|
|
one = tm.tm_year % 10;
|
|
|
|
|
snprintf(nextmsg,sizeof(nextmsg), "digits/%d", ten * 10);
|
|
|
|
|
res = wait_file(chan,ints,nextmsg,lang);
|
|
|
|
|
if (!res) {
|
|
|
|
|
if (one != 0) {
|
|
|
|
|
snprintf(nextmsg,sizeof(nextmsg), "digits/%d", one);
|
|
|
|
|
res = wait_file(chan,ints,nextmsg,lang);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 'I':
|
|
|
|
|
case 'l':
|
|
|
|
|
/* 12-Hour */
|
|
|
|
|
if (tm.tm_hour == 0)
|
|
|
|
|
snprintf(nextmsg,sizeof(nextmsg), "digits/12");
|
|
|
|
|
else if (tm.tm_hour > 12)
|
|
|
|
|
snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour - 12);
|
|
|
|
|
else
|
|
|
|
|
snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour);
|
|
|
|
|
res = wait_file(chan,ints,nextmsg,lang);
|
|
|
|
|
break;
|
|
|
|
|
case 'H':
|
|
|
|
|
case 'k':
|
|
|
|
|
/* 24-Hour */
|
|
|
|
|
if (format[offset] == 'H') {
|
|
|
|
|
/* e.g. oh-eight */
|
|
|
|
|
if (tm.tm_hour < 10) {
|
|
|
|
|
res = wait_file(chan,ints, "digits/oh",lang);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
/* e.g. eight */
|
|
|
|
|
if (tm.tm_hour == 0) {
|
|
|
|
|
res = wait_file(chan,ints, "digits/oh",lang);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!res) {
|
|
|
|
|
if (tm.tm_hour != 0) {
|
|
|
|
|
int remainder = tm.tm_hour;
|
|
|
|
|
if (tm.tm_hour > 20) {
|
|
|
|
|
res = wait_file(chan,ints, "digits/20",lang);
|
|
|
|
|
remainder -= 20;
|
|
|
|
|
}
|
|
|
|
|
if (!res) {
|
|
|
|
|
snprintf(nextmsg,sizeof(nextmsg), "digits/%d", remainder);
|
|
|
|
|
res = wait_file(chan,ints,nextmsg,lang);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 'M':
|
|
|
|
|
/* Minute */
|
|
|
|
|
if (tm.tm_min == 0) {
|
|
|
|
|
res = wait_file(chan,ints, "digits/oclock",lang);
|
|
|
|
|
} else if (tm.tm_min < 10) {
|
|
|
|
|
res = wait_file(chan,ints, "digits/oh",lang);
|
|
|
|
|
if (!res) {
|
|
|
|
|
snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_min);
|
|
|
|
|
res = wait_file(chan,ints,nextmsg,lang);
|
|
|
|
|
}
|
|
|
|
|
} else if ((tm.tm_min < 21) || (tm.tm_min % 10 == 0)) {
|
|
|
|
|
snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_min);
|
|
|
|
|
res = wait_file(chan,ints,nextmsg,lang);
|
|
|
|
|
} else {
|
|
|
|
|
int ten, one;
|
|
|
|
|
ten = (tm.tm_min / 10) * 10;
|
|
|
|
|
one = (tm.tm_min % 10);
|
|
|
|
|
snprintf(nextmsg,sizeof(nextmsg), "digits/%d", ten);
|
|
|
|
|
res = wait_file(chan,ints,nextmsg,lang);
|
|
|
|
|
if (!res) {
|
|
|
|
|
/* Fifty, not fifty-zero */
|
|
|
|
|
if (one != 0) {
|
|
|
|
|
snprintf(nextmsg,sizeof(nextmsg), "digits/%d", one);
|
|
|
|
|
res = wait_file(chan,ints,nextmsg,lang);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 'P':
|
|
|
|
|
case 'p':
|
|
|
|
|
/* AM/PM */
|
|
|
|
|
if (tm.tm_hour > 11)
|
|
|
|
|
snprintf(nextmsg,sizeof(nextmsg), "digits/p-m");
|
|
|
|
|
else
|
|
|
|
|
snprintf(nextmsg,sizeof(nextmsg), "digits/a-m");
|
|
|
|
|
res = wait_file(chan,ints,nextmsg,lang);
|
|
|
|
|
break;
|
|
|
|
|
case 'Q':
|
|
|
|
|
/* Shorthand for "Today", "Yesterday", or ABdY */
|
|
|
|
|
{
|
|
|
|
|
struct timeval now;
|
|
|
|
|
struct tm tmnow;
|
|
|
|
|
time_t beg_today;
|
|
|
|
|
|
|
|
|
|
gettimeofday(&now,NULL);
|
|
|
|
|
ast_localtime(&now.tv_sec,&tmnow,timezone);
|
|
|
|
|
/* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
|
|
|
|
|
/* In any case, it saves not having to do ast_mktime() */
|
|
|
|
|
beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
|
|
|
|
|
if (beg_today < time) {
|
|
|
|
|
/* Today */
|
|
|
|
|
res = wait_file(chan,ints, "digits/today",lang);
|
|
|
|
|
} else if (beg_today - 86400 < time) {
|
|
|
|
|
/* Yesterday */
|
|
|
|
|
res = wait_file(chan,ints, "digits/yesterday",lang);
|
|
|
|
|
} else {
|
|
|
|
|
res = ast_say_date_with_format(chan, time, ints, lang, "ABdY", timezone);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 'q':
|
|
|
|
|
/* Shorthand for "" (today), "Yesterday", A (weekday), or ABdY */
|
|
|
|
|
{
|
|
|
|
|
struct timeval now;
|
|
|
|
|
struct tm tmnow;
|
|
|
|
|
time_t beg_today;
|
|
|
|
|
|
|
|
|
|
gettimeofday(&now,NULL);
|
|
|
|
|
ast_localtime(&now.tv_sec,&tmnow,timezone);
|
|
|
|
|
/* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
|
|
|
|
|
/* In any case, it saves not having to do ast_mktime() */
|
|
|
|
|
beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
|
|
|
|
|
if (beg_today < time) {
|
|
|
|
|
/* Today */
|
|
|
|
|
} else if ((beg_today - 86400) < time) {
|
|
|
|
|
/* Yesterday */
|
|
|
|
|
res = wait_file(chan,ints, "digits/yesterday",lang);
|
|
|
|
|
} else if (beg_today - 86400 * 6 < time) {
|
|
|
|
|
/* Within the last week */
|
|
|
|
|
res = ast_say_date_with_format(chan, time, ints, lang, "A", timezone);
|
|
|
|
|
} else {
|
|
|
|
|
res = ast_say_date_with_format(chan, time, ints, lang, "ABdY", timezone);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 'R':
|
|
|
|
|
res = ast_say_date_with_format(chan, time, ints, lang, "HM", timezone);
|
|
|
|
|
break;
|
|
|
|
|
case 'S':
|
|
|
|
|
/* Seconds */
|
|
|
|
|
if (tm.tm_sec == 0) {
|
|
|
|
|
snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_sec);
|
|
|
|
|
res = wait_file(chan,ints,nextmsg,lang);
|
|
|
|
|
} else if (tm.tm_sec < 10) {
|
|
|
|
|
res = wait_file(chan,ints, "digits/oh",lang);
|
|
|
|
|
if (!res) {
|
|
|
|
|
snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_sec);
|
|
|
|
|
res = wait_file(chan,ints,nextmsg,lang);
|
|
|
|
|
}
|
|
|
|
|
} else if ((tm.tm_sec < 21) || (tm.tm_sec % 10 == 0)) {
|
|
|
|
|
snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_sec);
|
|
|
|
|
res = wait_file(chan,ints,nextmsg,lang);
|
|
|
|
|
} else {
|
|
|
|
|
int ten, one;
|
|
|
|
|
ten = (tm.tm_sec / 10) * 10;
|
|
|
|
|
one = (tm.tm_sec % 10);
|
|
|
|
|
snprintf(nextmsg,sizeof(nextmsg), "digits/%d", ten);
|
|
|
|
|
res = wait_file(chan,ints,nextmsg,lang);
|
|
|
|
|
if (!res) {
|
|
|
|
|
/* Fifty, not fifty-zero */
|
|
|
|
|
if (one != 0) {
|
|
|
|
|
snprintf(nextmsg,sizeof(nextmsg), "digits/%d", one);
|
|
|
|
|
res = wait_file(chan,ints,nextmsg,lang);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 'T':
|
|
|
|
|
res = ast_say_date_with_format(chan, time, ints, lang, "HMS", timezone);
|
|
|
|
|
break;
|
|
|
|
|
case ' ':
|
|
|
|
|
case ' ':
|
|
|
|
|
/* Just ignore spaces and tabs */
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
/* Unknown character */
|
|
|
|
|
ast_log(LOG_WARNING, "Unknown character in datetime format %s: %c at pos %d\n", format, format[offset], offset);
|
|
|
|
|
}
|
|
|
|
|
/* Jump out on DTMF */
|
|
|
|
|
if (res) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Spanish syntax */
|
|
|
|
|
int ast_say_date_with_format_es(struct ast_channel *chan, time_t time, char *ints, char *lang, char *format, char *timezone)
|
|
|
|
|
{
|
|
|
|
|