Language fix up
[asterisk/asterisk.git] / say.c
1 /*
2  * Asterisk -- A telephony toolkit for Linux.
3  *
4  * Say numbers and dates (maybe words one day too)
5  * 
6  * Copyright (C) 1999, Mark Spencer
7  *
8  * Mark Spencer <markster@linux-support.net>
9  *
10  * This program is free software, distributed under the terms of
11  * the GNU General Public License
12  */
13
14 #include <sys/types.h>
15 #include <string.h>
16 #include <stdlib.h>
17 #include <netinet/in.h>
18 #include <time.h>
19 #include <asterisk/file.h>
20 #include <asterisk/channel.h>
21 #include <asterisk/logger.h>
22 #include <asterisk/say.h>
23 #include <asterisk/lock.h>
24 #include <asterisk/localtime.h>
25 #include "asterisk.h"
26 #include <stdio.h>
27
28 #define DIGITS_DIR      AST_SOUNDS "/digits/"
29
30 int ast_say_digit_str(struct ast_channel *chan, char *fn2, char *ints, char *lang)
31 {
32         /* XXX Merge with full version? XXX */
33         char fn[256] = "";
34         int num = 0;
35         int res = 0;
36         while(fn2[num] && !res) {
37                 switch (fn2[num]) {
38                         case ('*'):
39                                 snprintf(fn, sizeof(fn), "digits/star");
40                                 break;
41                         case ('#'):
42                                 snprintf(fn, sizeof(fn), "digits/pound");
43                                 break;
44                         default:
45                                 snprintf(fn, sizeof(fn), "digits/%c", fn2[num]);
46                         }
47                 res = ast_streamfile(chan, fn, lang);
48                 if (!res) 
49                         res = ast_waitstream(chan, ints);
50                 ast_stopstream(chan);
51                 num++;
52         }
53         return res;
54 }
55
56 int ast_say_digit_str_full(struct ast_channel *chan, char *fn2, char *ints, char *lang, int audiofd, int ctrlfd)
57 {
58         char fn[256] = "";
59         int num = 0;
60         int res = 0;
61         while(fn2[num] && !res) {
62                 snprintf(fn, sizeof(fn), "digits/%c", fn2[num]);
63                 res = ast_streamfile(chan, fn, lang);
64                 if (!res) 
65                         res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
66                 ast_stopstream(chan);
67                 num++;
68         }
69         return res;
70 }
71
72 int ast_say_digits(struct ast_channel *chan, int num, char *ints, char *lang)
73 {
74         /* XXX Should I be merged with say_digits_full XXX */
75         char fn2[256];
76         snprintf(fn2, sizeof(fn2), "%d", num);
77         return ast_say_digit_str(chan, fn2, ints, lang);
78 }
79
80 int ast_say_digits_full(struct ast_channel *chan, int num, char *ints, char *lang, int audiofd, int ctrlfd)
81 {
82         char fn2[256];
83         snprintf(fn2, sizeof(fn2), "%d", num);
84         return ast_say_digit_str_full(chan, fn2, ints, lang, audiofd, ctrlfd);
85 }
86
87 int ast_say_number_full(struct ast_channel *chan, int num, char *ints, char *language, int audiofd, int ctrlfd)
88 {
89         int res = 0;
90         int playh = 0;
91         char fn[256] = "";
92         if (!num) 
93                 return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd);
94         if (0) {
95         /* XXX Only works for english XXX */
96         } else {
97                 /* Use english numbers */
98                 language = "en";
99                 while(!res && (num || playh)) {
100                         if (playh) {
101                                 snprintf(fn, sizeof(fn), "digits/hundred");
102                                 playh = 0;
103                         } else
104                         if (num < 20) {
105                                 snprintf(fn, sizeof(fn), "digits/%d", num);
106                                 num = 0;
107                         } else
108                         if (num < 100) {
109                                 snprintf(fn, sizeof(fn), "digits/%d", (num /10) * 10);
110                                 num -= ((num / 10) * 10);
111                         } else {
112                                 if (num < 1000){
113                                         snprintf(fn, sizeof(fn), "digits/%d", (num/100));
114                                         playh++;
115                                         num -= ((num / 100) * 100);
116                                 } else {
117                                         if (num < 1000000) { /* 1,000,000 */
118                                                 res = ast_say_number_full(chan, num / 1000, ints, language, audiofd, ctrlfd);
119                                                 if (res)
120                                                         return res;
121                                                 num = num % 1000;
122                                                 snprintf(fn, sizeof(fn), "digits/thousand");
123                                         } else {
124                                                 if (num < 1000000000) { /* 1,000,000,000 */
125                                                         res = ast_say_number_full(chan, num / 1000000, ints, language, audiofd, ctrlfd);
126                                                         if (res)
127                                                                 return res;
128                                                         num = num % 1000000;
129                                                         snprintf(fn, sizeof(fn), "digits/million");
130                                                 } else {
131                                                         ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
132                                                         res = -1;
133                                                 }
134                                         }
135                                 }
136                         }
137                         if (!res) {
138                                 res = ast_streamfile(chan, fn, language);
139                                 if (!res) 
140                                         res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
141                                 ast_stopstream(chan);
142                         }
143                         
144                 }
145         }
146         return res;
147 }
148
149 int ast_say_number(struct ast_channel *chan, int num, char *ints, char *language)
150 {
151         /* XXX Should I be merged with ast_say_number_full XXX */
152         int res = 0;
153         int playh = 0;
154         char fn[256] = "";
155         if (!num) 
156                 return ast_say_digits(chan, 0,ints, language);
157         if (0) {
158         /* XXX Only works for english XXX */
159         } else {
160                 /* Use english numbers */
161                 language = "en";
162                 while(!res && (num || playh)) {
163                         if (playh) {
164                                 snprintf(fn, sizeof(fn), "digits/hundred");
165                                 playh = 0;
166                         } else
167                         if (num < 20) {
168                                 snprintf(fn, sizeof(fn), "digits/%d", num);
169                                 num = 0;
170                         } else
171                         if (num < 100) {
172                                 snprintf(fn, sizeof(fn), "digits/%d", (num /10) * 10);
173                                 num -= ((num / 10) * 10);
174                         } else {
175                                 if (num < 1000){
176                                         snprintf(fn, sizeof(fn), "digits/%d", (num/100));
177                                         playh++;
178                                         num -= ((num / 100) * 100);
179                                 } else {
180                                         if (num < 1000000) {
181                                                 res = ast_say_number(chan, num / 1000, ints, language);
182                                                 if (res)
183                                                         return res;
184                                                 num = num % 1000;
185                                                 snprintf(fn, sizeof(fn), "digits/thousand");
186                                         } else {
187                                                 if (num < 1000000000) {
188                                                         res = ast_say_number(chan, num / 1000000, ints, language);
189                                                         if (res)
190                                                                 return res;
191                                                         num = num % 1000000;
192                                                         snprintf(fn, sizeof(fn), "digits/million");
193                                                 } else {
194                                                         ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
195                                                         res = -1;
196                                                 }
197                                         }
198                                 }
199                         }
200                         if (!res) {
201                                 res = ast_streamfile(chan, fn, language);
202                                 if (!res) 
203                                         res = ast_waitstream(chan, ints);
204                                 ast_stopstream(chan);
205                         }
206                         
207                 }
208         }
209         return res;
210 }
211 int ast_say_date(struct ast_channel *chan, time_t t, char *ints, char *lang)
212 {
213         struct tm tm;
214         char fn[256];
215         int res = 0;
216         ast_localtime(&t,&tm,NULL);
217         if (!res) {
218                 snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
219                 res = ast_streamfile(chan, fn, lang);
220                 if (!res)
221                         res = ast_waitstream(chan, ints);
222         }
223         if (!res) {
224                 snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
225                 res = ast_streamfile(chan, fn, lang);
226                 if (!res)
227                         res = ast_waitstream(chan, ints);
228         }
229         if (!res)
230                 res = ast_say_number(chan, tm.tm_mday, ints, lang);
231
232         if (!res)
233                 res = ast_waitstream(chan, ints);
234         if (!res)
235                 res = ast_say_number(chan, tm.tm_year + 1900, ints, lang);
236         return res;
237 }
238
239 static int wait_file(struct ast_channel *chan, char *ints, char *file, char *lang) 
240 {
241         int res;
242         if ((res = ast_streamfile(chan, file, lang)))
243                 ast_log(LOG_WARNING, "Unable to play message %s\n", file);
244         if (!res)
245                 res = ast_waitstream(chan, ints);
246         return res;
247 }
248
249 int ast_say_date_with_format(struct ast_channel *chan, time_t time, char *ints, char *lang, char *format, char *timezone)
250 {
251         struct tm tm;
252         int res=0, offset, sndoffset;
253         char sndfile[256], nextmsg[256];
254
255         ast_localtime(&time,&tm,timezone);
256
257         for (offset=0 ; format[offset] != '\0' ; offset++) {
258                 ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
259                 switch (format[offset]) {
260                         /* NOTE:  if you add more options here, please try to be consistent with strftime(3) */
261                         case '\'':
262                                 /* Literal name of a sound file */
263                                 sndoffset=0;
264                                 for (sndoffset=0 ; (format[++offset] != '\'') && (sndoffset < 256) ; sndoffset++)
265                                         sndfile[sndoffset] = format[offset];
266                                 sndfile[sndoffset] = '\0';
267                                 snprintf(nextmsg,sizeof(nextmsg), AST_SOUNDS "/%s", sndfile);
268                                 res = wait_file(chan,ints,nextmsg,lang);
269                                 break;
270                         case 'A':
271                         case 'a':
272                                 /* Sunday - Saturday */
273                                 snprintf(nextmsg,sizeof(nextmsg), DIGITS_DIR "day-%d", tm.tm_wday);
274                                 res = wait_file(chan,ints,nextmsg,lang);
275                                 break;
276                         case 'B':
277                         case 'b':
278                         case 'h':
279                                 /* January - December */
280                                 snprintf(nextmsg,sizeof(nextmsg), DIGITS_DIR "mon-%d", tm.tm_mon);
281                                 res = wait_file(chan,ints,nextmsg,lang);
282                                 break;
283                         case 'd':
284                         case 'e':
285                                 /* First - Thirtyfirst */
286                                 if ((tm.tm_mday < 21) || (tm.tm_mday == 30)) {
287                                         snprintf(nextmsg,sizeof(nextmsg), DIGITS_DIR "h-%d", tm.tm_mday);
288                                         res = wait_file(chan,ints,nextmsg,lang);
289                                 } else if (tm.tm_mday == 31) {
290                                         /* "Thirty" and "first" */
291                                         res = wait_file(chan,ints,DIGITS_DIR "30",lang);
292                                         if (!res) {
293                                                 res = wait_file(chan,ints,DIGITS_DIR "h-1",lang);
294                                         }
295                                 } else {
296                                         /* Between 21 and 29 - two sounds */
297                                         res = wait_file(chan,ints,DIGITS_DIR "20",lang);
298                                         if (!res) {
299                                                 snprintf(nextmsg,sizeof(nextmsg),DIGITS_DIR "h-%d", tm.tm_mday - 20);
300                                                 res = wait_file(chan,ints,nextmsg,lang);
301                                         }
302                                 }
303                                 break;
304                         case 'Y':
305                                 /* Year */
306                                 if (tm.tm_year > 99) {
307                                         res = wait_file(chan,ints,DIGITS_DIR "2",lang);
308                                         if (!res) {
309                                                 res = wait_file(chan,ints,DIGITS_DIR "thousand",lang);
310                                         }
311                                         if (tm.tm_year > 100) {
312                                                 if (!res) {
313                                                         /* This works until the end of 2020 */
314                                                         snprintf(nextmsg,sizeof(nextmsg),DIGITS_DIR "%d", tm.tm_year - 100);
315                                                         res = wait_file(chan,ints,nextmsg,lang);
316                                                 }
317                                         }
318                                 } else {
319                                         if (tm.tm_year < 1) {
320                                                 /* I'm not going to handle 1900 and prior */
321                                                 /* We'll just be silent on the year, instead of bombing out. */
322                                         } else {
323                                                 res = wait_file(chan,ints,DIGITS_DIR "19",lang);
324                                                 if (!res) {
325                                                         if (tm.tm_year <= 9) {
326                                                                 /* 1901 - 1909 */
327                                                                 res = wait_file(chan,ints,DIGITS_DIR "oh",lang);
328                                                                 if (!res) {
329                                                                         snprintf(nextmsg,sizeof(nextmsg),DIGITS_DIR "%d", tm.tm_year);
330                                                                         res = wait_file(chan,ints,nextmsg,lang);
331                                                                 }
332                                                         } else if (tm.tm_year <= 20) {
333                                                                 /* 1910 - 1920 */
334                                                                 snprintf(nextmsg,sizeof(nextmsg),DIGITS_DIR "%d", tm.tm_year);
335                                                                 res = wait_file(chan,ints,nextmsg,lang);
336                                                         } else {
337                                                                 /* 1921 - 1999 */
338                                                                 int ten, one;
339                                                                 ten = tm.tm_year / 10;
340                                                                 one = tm.tm_year % 10;
341                                                                 snprintf(nextmsg,sizeof(nextmsg),DIGITS_DIR "%d", ten * 10);
342                                                                 res = wait_file(chan,ints,nextmsg,lang);
343                                                                 if (!res) {
344                                                                         if (one != 0) {
345                                                                                 snprintf(nextmsg,sizeof(nextmsg),DIGITS_DIR "%d", one);
346                                                                                 res = wait_file(chan,ints,nextmsg,lang);
347                                                                         }
348                                                                 }
349                                                         }
350                                                 }
351                                         }
352                                 }
353                                 break;
354                         case 'I':
355                         case 'l':
356                                 /* 12-Hour */
357                                 if (tm.tm_hour == 0)
358                                         snprintf(nextmsg,sizeof(nextmsg),DIGITS_DIR "12");
359                                 else if (tm.tm_hour > 12)
360                                         snprintf(nextmsg,sizeof(nextmsg),DIGITS_DIR "%d", tm.tm_hour - 12);
361                                 else
362                                         snprintf(nextmsg,sizeof(nextmsg),DIGITS_DIR "%d", tm.tm_hour);
363                                 res = wait_file(chan,ints,nextmsg,lang);
364                                 break;
365                         case 'H':
366                         case 'k':
367                                 /* 24-Hour */
368                                 if (format[offset] == 'H') {
369                                         /* e.g. oh-eight */
370                                         if (tm.tm_hour < 10) {
371                                                 res = wait_file(chan,ints,DIGITS_DIR "oh",lang);
372                                         }
373                                 } else {
374                                         /* e.g. eight */
375                                         if (tm.tm_hour == 0) {
376                                                 res = wait_file(chan,ints,DIGITS_DIR "oh",lang);
377                                         }
378                                 }
379                                 if (!res) {
380                                         if (tm.tm_hour != 0) {
381                                                 snprintf(nextmsg,sizeof(nextmsg), AST_SOUNDS "/digits/%d", tm.tm_hour);
382                                                 res = wait_file(chan,ints,nextmsg,lang);
383                                         }
384                                 }
385                                 break;
386                         case 'M':
387                                 /* Minute */
388                                 if (tm.tm_min == 0) {
389                                         res = wait_file(chan,ints,DIGITS_DIR "oclock",lang);
390                                 } else if (tm.tm_min < 10) {
391                                         res = wait_file(chan,ints,DIGITS_DIR "oh",lang);
392                                         if (!res) {
393                                                 snprintf(nextmsg,sizeof(nextmsg),DIGITS_DIR "%d", tm.tm_min);
394                                                 res = wait_file(chan,ints,nextmsg,lang);
395                                         }
396                                 } else if ((tm.tm_min < 21) || (tm.tm_min % 10 == 0)) {
397                                         snprintf(nextmsg,sizeof(nextmsg),DIGITS_DIR "%d", tm.tm_min);
398                                         res = wait_file(chan,ints,nextmsg,lang);
399                                 } else {
400                                         int ten, one;
401                                         ten = (tm.tm_min / 10) * 10;
402                                         one = (tm.tm_min % 10);
403                                         snprintf(nextmsg,sizeof(nextmsg),DIGITS_DIR "%d", ten);
404                                         res = wait_file(chan,ints,nextmsg,lang);
405                                         if (!res) {
406                                                 /* Fifty, not fifty-zero */
407                                                 if (one != 0) {
408                                                         snprintf(nextmsg,sizeof(nextmsg),DIGITS_DIR "%d", one);
409                                                         res = wait_file(chan,ints,nextmsg,lang);
410                                                 }
411                                         }
412                                 }
413                                 break;
414                         case 'P':
415                         case 'p':
416                                 /* AM/PM */
417                                 if (tm.tm_hour > 11)
418                                         snprintf(nextmsg,sizeof(nextmsg), DIGITS_DIR "p-m");
419                                 else
420                                         snprintf(nextmsg,sizeof(nextmsg), DIGITS_DIR "a-m");
421                                 res = wait_file(chan,ints,nextmsg,lang);
422                                 break;
423                         case 'Q':
424                                 /* Shorthand for "Today", "Yesterday", or ABdY */
425                                 {
426                                         struct timeval now;
427                                         struct tm tmnow;
428                                         time_t beg_today;
429
430                                         gettimeofday(&now,NULL);
431                                         ast_localtime(&now.tv_sec,&tmnow,timezone);
432                                         /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
433                                         /* In any case, it saves not having to do ast_mktime() */
434                                         beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
435                                         if (beg_today < time) {
436                                                 /* Today */
437                                                 res = wait_file(chan,ints,DIGITS_DIR "today",lang);
438                                         } else if (beg_today - 86400 < time) {
439                                                 /* Yesterday */
440                                                 res = wait_file(chan,ints,DIGITS_DIR "yesterday",lang);
441                                         } else {
442                                                 res = ast_say_date_with_format(chan, time, ints, lang, "ABdY", timezone);
443                                         }
444                                 }
445                                 break;
446                         case 'q':
447                                 /* Shorthand for "" (today), "Yesterday", A (weekday), or ABdY */
448                                 {
449                                         struct timeval now;
450                                         struct tm tmnow;
451                                         time_t beg_today;
452
453                                         gettimeofday(&now,NULL);
454                                         ast_localtime(&now.tv_sec,&tmnow,timezone);
455                                         /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
456                                         /* In any case, it saves not having to do ast_mktime() */
457                                         beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
458                                         if (beg_today < time) {
459                                                 /* Today */
460                                         } else if ((beg_today - 86400) < time) {
461                                                 /* Yesterday */
462                                                 res = wait_file(chan,ints,DIGITS_DIR "yesterday",lang);
463                                         } else if (beg_today - 86400 * 6 < time) {
464                                                 /* Within the last week */
465                                                 res = ast_say_date_with_format(chan, time, ints, lang, "A", timezone);
466                                         } else {
467                                                 res = ast_say_date_with_format(chan, time, ints, lang, "ABdY", timezone);
468                                         }
469                                 }
470                                 break;
471                         case 'R':
472                                 res = ast_say_date_with_format(chan, time, ints, lang, "HM", timezone);
473                                 break;
474                         case ' ':
475                         case '  ':
476                                 /* Just ignore spaces and tabs */
477                                 break;
478                         default:
479                                 /* Unknown character */
480                                 ast_log(LOG_WARNING, "Unknown character in datetime format %s: %c at pos %d\n", format, format[offset], offset);
481                 }
482                 /* Jump out on DTMF */
483                 if (res) {
484                         break;
485                 }
486         }
487         return res;
488 }
489
490 int ast_say_time(struct ast_channel *chan, time_t t, char *ints, char *lang)
491 {
492         struct tm tm;
493         int res = 0;
494         int hour, pm=0;
495         localtime_r(&t,&tm);
496         hour = tm.tm_hour;
497         if (!hour)
498                 hour = 12;
499         else if (hour == 12)
500                 pm = 1;
501         else if (hour > 12) {
502                 hour -= 12;
503                 pm = 1;
504         }
505         if (!res)
506                 res = ast_say_number(chan, hour, ints, lang);
507
508         if (tm.tm_min > 9) {
509                 if (!res)
510                         res = ast_say_number(chan, tm.tm_min, ints, lang);
511         } else if (tm.tm_min) {
512                 if (!res)
513                         res = ast_streamfile(chan, "digits/oh", lang);
514                 if (!res)
515                         res = ast_waitstream(chan, ints);
516                 if (!res)
517                         res = ast_say_number(chan, tm.tm_min, ints, lang);
518         } else {
519                 if (!res)
520                         res = ast_streamfile(chan, "digits/oclock", lang);
521                 if (!res)
522                         res = ast_waitstream(chan, ints);
523         }
524         if (pm) {
525                 if (!res)
526                         res = ast_streamfile(chan, "digits/p-m", lang);
527         } else {
528                 if (!res)
529                         res = ast_streamfile(chan, "digits/a-m", lang);
530         }
531         if (!res)
532                 res = ast_waitstream(chan, ints);
533         return res;
534 }
535
536 int ast_say_datetime(struct ast_channel *chan, time_t t, char *ints, char *lang)
537 {
538         struct tm tm;
539         char fn[256];
540         int res = 0;
541         int hour, pm=0;
542         localtime_r(&t,&tm);
543         if (!res) {
544                 snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
545                 res = ast_streamfile(chan, fn, lang);
546                 if (!res)
547                         res = ast_waitstream(chan, ints);
548         }
549         if (!res) {
550                 snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
551                 res = ast_streamfile(chan, fn, lang);
552                 if (!res)
553                         res = ast_waitstream(chan, ints);
554         }
555         if (!res)
556                 res = ast_say_number(chan, tm.tm_mday, ints, lang);
557
558         hour = tm.tm_hour;
559         if (!hour)
560                 hour = 12;
561         else if (hour == 12)
562                 pm = 1;
563         else if (hour > 12) {
564                 hour -= 12;
565                 pm = 1;
566         }
567         if (!res)
568                 res = ast_say_number(chan, hour, ints, lang);
569
570         if (tm.tm_min > 9) {
571                 if (!res)
572                         res = ast_say_number(chan, tm.tm_min, ints, lang);
573         } else if (tm.tm_min) {
574                 if (!res)
575                         res = ast_streamfile(chan, "digits/oh", lang);
576                 if (!res)
577                         res = ast_waitstream(chan, ints);
578                 if (!res)
579                         res = ast_say_number(chan, tm.tm_min, ints, lang);
580         } else {
581                 if (!res)
582                         res = ast_streamfile(chan, "digits/oclock", lang);
583                 if (!res)
584                         res = ast_waitstream(chan, ints);
585         }
586         if (pm) {
587                 if (!res)
588                         res = ast_streamfile(chan, "digits/p-m", lang);
589         } else {
590                 if (!res)
591                         res = ast_streamfile(chan, "digits/a-m", lang);
592         }
593         if (!res)
594                 res = ast_waitstream(chan, ints);
595         if (!res)
596                 res = ast_say_number(chan, tm.tm_year + 1900, ints, lang);
597         return res;
598 }
599
600 int ast_say_datetime_from_now(struct ast_channel *chan, time_t t, char *ints, char *lang)
601 {
602         int res=0;
603         time_t nowt;
604         int daydiff;
605         struct tm tm;
606         struct tm now;
607         char fn[256];
608
609         time(&nowt);
610
611         localtime_r(&t,&tm);
612         localtime_r(&nowt,&now);
613         daydiff = now.tm_yday - tm.tm_yday;
614         if ((daydiff < 0) || (daydiff > 6)) {
615                 /* Day of month and month */
616                 if (!res) {
617                         snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
618                         res = ast_streamfile(chan, fn, lang);
619                         if (!res)
620                                 res = ast_waitstream(chan, ints);
621                 }
622                 if (!res)
623                         res = ast_say_number(chan, tm.tm_mday, ints, lang);
624
625         } else if (daydiff) {
626                 /* Just what day of the week */
627                 if (!res) {
628                         snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
629                         res = ast_streamfile(chan, fn, lang);
630                         if (!res)
631                                 res = ast_waitstream(chan, ints);
632                 }
633         } /* Otherwise, it was today */
634         if (!res)
635                 res = ast_say_time(chan, t, ints, lang);
636         return res;
637 }
638