mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-02 11:58:40 +00:00
German language improvements (bug #1606)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@2948 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -4,63 +4,133 @@
|
||||
exten => 841,1,Answer
|
||||
exten => 841,2,Wait,1 ; Allow VoIP sessions time to initialise
|
||||
exten => 841,3,SetLanguage(en)
|
||||
exten => 841,4,SayNumber(183) ; one hundred eighty three (NB This sounds wrong to me!)
|
||||
exten => 841,4,SayNumber(183) ; one hundred eighty three (NB UK English would say one hundred & eighty three)
|
||||
exten => 841,5,Wait,1
|
||||
exten => 841,6,SayUnixTime() ; Say current date & time in "ABdY 'digits/at' IMp" format
|
||||
; French
|
||||
exten => 842,1,Answer
|
||||
exten => 842,2,Wait,1 ; Allow VoIP sessions time to initialise
|
||||
exten => 842,3,SetLanguage(fr)
|
||||
exten => 842,4,SayNumber(183) ; hundred eighty three
|
||||
exten => 842,5,SayNumber(283) ; two hundred eighty three
|
||||
exten => 842,6,SayNumber(1063) ; thousand sixty three
|
||||
exten => 842,7,SayNumber(2063) ; two thousand sixty three
|
||||
exten => 842,4,SayNumber(1) ; one
|
||||
exten => 842,5,Wait,1
|
||||
exten => 842,6,SayNumber(1,f) ; one (feminine)
|
||||
exten => 842,7,Wait,1
|
||||
exten => 842,8,SayNumber(181) ; hundred eighty three
|
||||
exten => 842,9,Wait,1
|
||||
exten => 842,10,SayNumber(281) ; two hundred eighty three
|
||||
exten => 842,11,Wait,1
|
||||
exten => 842,12,SayNumber(1061) ; thousand sixty three
|
||||
exten => 842,13,Wait,1
|
||||
exten => 842,14,SayNumber(2061) ; two thousand sixty three
|
||||
exten => 842,15,Wait,1
|
||||
exten => 842,16,SayUnixTime()
|
||||
; Spanish
|
||||
exten => 843,1,Answer
|
||||
exten => 843,2,Wait,1 ; Allow VoIP sessions time to initialise
|
||||
exten => 843,3,SetLanguage(es)
|
||||
exten => 843,4,SayNumber(21) ; "twentyone"
|
||||
exten => 843,5,SayNumber(200) ; "twohundred"
|
||||
exten => 843,6,SayNumber(1000000) ; one million
|
||||
exten => 843,7,SayNumber(2000000) ; two millions
|
||||
exten => 843,4,Playback(digits/hundred)
|
||||
exten => 843,5,Wait,1
|
||||
exten => 843,6,SayNumber(1) ; one
|
||||
exten => 843,7,Wait,1
|
||||
exten => 843,8,SayNumber(1,f) ; one (feminine)
|
||||
exten => 843,9,Wait,1
|
||||
exten => 843,10,SayNumber(11) ; "dieci uno"
|
||||
exten => 843,11,Wait,1
|
||||
exten => 843,12,SayNumber(21) ; "veinti uno"
|
||||
exten => 843,13,Wait,1
|
||||
exten => 843,14,SayNumber(31) ; "thirty & one"
|
||||
exten => 843,15,Wait,1
|
||||
exten => 843,16,SayNumber(100) ; "cien"
|
||||
exten => 843,17,Wait,1
|
||||
exten => 843,18,SayNumber(101) ; "ciento uno"
|
||||
exten => 843,19,Wait,1
|
||||
exten => 843,20,SayNumber(200) ; "twohundred"
|
||||
exten => 843,21,Wait,1
|
||||
exten => 843,22,SayNumber(1000000) ; one million
|
||||
exten => 843,23,Wait,1
|
||||
exten => 843,24,SayNumber(2000000) ; two millions
|
||||
exten => 843,25,Wait,1
|
||||
exten => 843,26,SayUnixTime()
|
||||
; Portuguese
|
||||
exten => 844,1,Answer
|
||||
exten => 844,2,Wait,1 ; Allow VoIP sessions time to initialise
|
||||
exten => 844,3,SetLanguage(pt)
|
||||
exten => 844,4,SayNumber(1) ; one
|
||||
exten => 844,5,SayNumber(1,f) ; one (feminine)
|
||||
exten => 844,6,SayNumber(2) ; two
|
||||
exten => 844,7,SayNumber(2,f) ; two (feminine)
|
||||
exten => 844,8,SayNumber(183) ; hundred& eighty three
|
||||
exten => 844,5,Wait,1
|
||||
exten => 844,6,SayNumber(1,f) ; one (feminine)
|
||||
exten => 844,7,Wait,1
|
||||
exten => 844,8,SayNumber(2) ; two
|
||||
exten => 844,9,Wait,1
|
||||
exten => 844,10,SayNumber(2,f) ; two (feminine)
|
||||
exten => 844,11,Wait,1
|
||||
exten => 844,12,SayNumber(183) ; hundred& eighty three
|
||||
exten => 844,13,Wait,1
|
||||
exten => 844,14,SayUnixTime()
|
||||
; Italian
|
||||
exten => 845,1,Answer
|
||||
exten => 845,2,Wait,1 ; Allow VoIP sessions time to initialise
|
||||
exten => 845,3,SetLanguage(it)
|
||||
exten => 845,4,SayNumber(21) ; "twentyone"
|
||||
exten => 845,5,SayNumber(183) ; hundred eighty three
|
||||
exten => 845,6,SayNumber(283) ; two hundred eighty three
|
||||
exten => 845,7,SayNumber(1063) ; thousand sixty three
|
||||
exten => 845,8,SayNumber(2063) ; two thousands sixty three
|
||||
exten => 845,5,Wait,1
|
||||
exten => 845,6,SayNumber(183) ; hundred eighty three
|
||||
exten => 845,7,Wait,1
|
||||
exten => 845,8,SayNumber(283) ; two hundred eighty three
|
||||
exten => 845,9,SayNumber(1063) ; thousand sixty three
|
||||
exten => 845,10,Wait,1
|
||||
exten => 845,11,SayNumber(2063) ; two thousands sixty three
|
||||
exten => 845,12,Wait,1
|
||||
exten => 845,13,SayUnixTime()
|
||||
; Dutch
|
||||
exten => 846,1,Answer
|
||||
exten => 846,2,Wait,1 ; Allow VoIP sessions time to initialise
|
||||
exten => 846,3,SetLanguage(nl)
|
||||
exten => 846,4,SayUnixTime(||ABdY'digits/at'R)
|
||||
exten => 846,5,Wait,1
|
||||
; Danish
|
||||
exten => 847,1,Answer
|
||||
exten => 847,2,Wait,1 ; Allow VoIP sessions time to initialise
|
||||
exten => 847,3,SetLanguage(da)
|
||||
exten => 847,4,SayNumber(68) ; eight-& sixty
|
||||
exten => 847,5,SayNumber(2034) ; two thousand & four-& thirty
|
||||
exten => 847,6,SayNumber(1000000) ; one million
|
||||
exten => 847,7,SayNumber(2000000) ; two millions
|
||||
; German (not yet implemented)
|
||||
exten => 847,5,Wait,1
|
||||
exten => 847,6,SayNumber(2034) ; two thousand & four-& thirty
|
||||
exten => 847,7,Wait,1
|
||||
exten => 847,8,SayNumber(1000000) ; one million
|
||||
exten => 847,9,Wait,1
|
||||
exten => 847,10,SayNumber(2000000) ; two millions
|
||||
exten => 847,11,Wait,1
|
||||
exten => 847,12,SayUnixTime()
|
||||
; German
|
||||
exten => 848,1,Answer
|
||||
exten => 848,2,Wait,1 ; Allow VoIP sessions time to initialise
|
||||
exten => 848,3,SetLanguage(de)
|
||||
exten => 848,4,SayNumber(68) ; eight-& sixty
|
||||
exten => 848,5,SayNumber(2034) ; two thousand & four-& thirty
|
||||
exten => 848,6,SayNumber(1000000) ; one million
|
||||
exten => 848,7,SayNumber(2000000) ; two millions
|
||||
exten => 848,5,Wait,1
|
||||
exten => 848,6,SayNumber(100) ; "hundert"
|
||||
exten => 848,7,Wait,1
|
||||
exten => 848,8,SayNumber(101) ; "einhundert-einS"
|
||||
exten => 848,9,Wait,1
|
||||
exten => 848,10,SayNumber(1000) ; "tausend"
|
||||
exten => 848,11,Wait,1
|
||||
exten => 848,12,SayNumber(1001) ; "eintausend-einS" X tausend-einS
|
||||
exten => 848,13,Wait,1
|
||||
exten => 848,14,SayNumber(2134) ; two thousand one hundred four-& thirty
|
||||
exten => 848,15,Wait,1
|
||||
exten => 848,16,SayNumber(1001000) ; one million one thousand X million tausend
|
||||
exten => 848,17,Wait,1
|
||||
exten => 848,18,SayNumber(2002000) ; two millions two thousand
|
||||
exten => 848,19,Wait,1
|
||||
exten => 848,20,SayUnixTime()
|
||||
; Swedish
|
||||
exten => 849,1,Answer
|
||||
exten => 849,2,Wait,1 ; Allow VoIP sessions time to initialise
|
||||
exten => 849,3,SetLanguage(se)
|
||||
|
||||
exten => 849,4,SayUnixTime()
|
||||
exten => 849,5,Wait,1
|
||||
; Temp
|
||||
exten => 850,1,Answer
|
||||
exten => 850,2,Wait,1 ; Allow VoIP sessions time to initialise
|
||||
exten => 850,3,SetLanguage(de)
|
||||
exten => 850,4,Playback(digits/1)
|
||||
exten => 850,5,Wait,1
|
||||
exten => 850,6,Playback(digits/de-eins)
|
||||
exten => 850,7,Wait,1
|
||||
|
||||
398
say.c
398
say.c
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user