Newer
Older
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';
res = wait_file(chan,ints,sndfile,lang);
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
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 % 10) || (tm.tm_mday < 10)) {
snprintf(nextmsg,sizeof(nextmsg), "digits/h-%d", tm.tm_mday);
res = wait_file(chan,ints,nextmsg,lang);
} else {
snprintf(nextmsg,sizeof(nextmsg), "digits/h-%dh", tm.tm_mday - (tm.tm_mday % 10));
res = wait_file(chan,ints,nextmsg,lang);
if(!res) {
snprintf(nextmsg,sizeof(nextmsg), "digits/h-%d", tm.tm_mday % 10);
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) {
snprintf(nextmsg,sizeof(nextmsg), "digits/%d", (tm.tm_year - 100) / 10);
res = wait_file(chan,ints,nextmsg,lang);
if (!res) {
snprintf(nextmsg,sizeof(nextmsg), "digits/%d", (tm.tm_year - 100) % 10);
res = wait_file(chan,ints,nextmsg,lang);
}
}
}
if (!res) {
res = wait_file(chan,ints, "digits/year",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/1",lang);
if (!res) {
res = wait_file(chan,ints, "digits/9",lang);
}
if (!res) {
if (tm.tm_year <= 9) {
/* 1901 - 1909 */
res = wait_file(chan,ints, "digits/0",lang);
if (!res) {
snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_year);
res = wait_file(chan,ints,nextmsg,lang);
}
} else {
/* 1910 - 1999 */
snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_year / 10);
res = wait_file(chan,ints,nextmsg,lang);
if (!res) {
snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_year % 10);
res = wait_file(chan,ints,nextmsg,lang);
}
}
}
}
if (!res) {
res = wait_file(chan,ints, "digits/year",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);
if (!res) {
res = wait_file(chan,ints, "digits/oclock",lang);
}
break;
case 'H':
case 'k':
/* 24-Hour */
if (!(tm.tm_hour % 10) || tm.tm_hour < 10) {
if (tm.tm_hour < 10) {
res = wait_file(chan, ints, "digits/0", lang);
}
snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour);
res = wait_file(chan,ints,nextmsg,lang);
} else {
snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour - (tm.tm_hour % 10));
res = wait_file(chan,ints,nextmsg,lang);
if (!res) {
snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_hour % 10);
res = wait_file(chan,ints,nextmsg,lang);
}
}
if (!res) {
res = wait_file(chan,ints, "digits/oclock",lang);
}
break;
case 'M':
/* Minute */
if (!(tm.tm_min % 10) || tm.tm_min < 10) {
if (tm.tm_min < 10) {
res = wait_file(chan, ints, "digits/0", lang);
}
snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_min);
res = wait_file(chan,ints,nextmsg,lang);
} else {
snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_min - (tm.tm_min % 10));
res = wait_file(chan,ints,nextmsg,lang);
if (!res) {
snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_min % 10);
res = wait_file(chan,ints,nextmsg,lang);
}
}
if (!res) {
res = wait_file(chan,ints, "digits/minute",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, "YBdA", 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, "YBdA", timezone);
}
}
break;
case 'R':
res = ast_say_date_with_format(chan, time, ints, lang, "HM", timezone);
break;
case 'S':
/* Seconds */
if (!(tm.tm_sec % 10) || tm.tm_sec < 10) {
if (tm.tm_sec < 10) {
res = wait_file(chan, ints, "digits/0", lang);
}
snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_sec);
res = wait_file(chan,ints,nextmsg,lang);
} else {
snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_sec - (tm.tm_sec % 10));
res = wait_file(chan,ints,nextmsg,lang);
if (!res) {
snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_sec % 10);
res = wait_file(chan,ints,nextmsg,lang);
}
}
if (!res) {
res = wait_file(chan,ints, "digits/second",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;
}
int ast_say_time(struct ast_channel *chan, time_t t, char *ints, char *lang)
{
if (!strcasecmp(lang, "en") ) { /* English syntax */
return(ast_say_time_en(chan, t, ints, lang));
} else if (!strcasecmp(lang, "nl") ) { /* Dutch syntax */
return(ast_say_time_nl(chan, t, ints, lang));
} else if (!strcasecmp(lang, "pt") ) { /* Portuguese syntax */
return(ast_say_time_pt(chan, t, ints, lang));
} else if (!strcasecmp(lang, "tw") ) { /* Taiwanese syntax */
return(ast_say_time_tw(chan, t, ints, lang));
}
/* Default to English */
return(ast_say_time_en(chan, t, ints, lang));
}
/* English syntax */
int ast_say_time_en(struct ast_channel *chan, time_t t, char *ints, char *lang)
localtime_r(&t,&tm);
hour = tm.tm_hour;
if (!hour)
hour = 12;
else if (hour == 12)
pm = 1;
else if (hour > 12) {
hour -= 12;
pm = 1;
}
if (!res)
Mark Spencer
committed
res = ast_say_number(chan, hour, ints, lang, (char *) NULL);
Mark Spencer
committed
res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
res = ast_streamfile(chan, "digits/oh", lang);
if (!res)
res = ast_waitstream(chan, ints);
if (!res)
Mark Spencer
committed
res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
res = ast_streamfile(chan, "digits/oclock", lang);
if (!res)
res = ast_waitstream(chan, ints);
}
if (pm) {
if (!res)
res = ast_streamfile(chan, "digits/p-m", lang);
} else {
if (!res)
res = ast_streamfile(chan, "digits/a-m", lang);
}
if (!res)
res = ast_waitstream(chan, ints);
return res;
}
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
/* Dutch syntax */
int ast_say_time_nl(struct ast_channel *chan, time_t t, char *ints, char *lang)
{
struct tm tm;
int res = 0;
int hour;
localtime_r(&t,&tm);
hour = tm.tm_hour;
if (!res)
res = ast_say_number(chan, hour, ints, lang, (char *) NULL);
if (!res)
res = ast_streamfile(chan, "digits/nl-uur", lang);
if (!res)
res = ast_waitstream(chan, ints);
if (!res)
if (tm.tm_min > 0)
res = ast_say_number(chan, tm.tm_min, ints, lang, NULL);
return res;
}
/* Portuguese syntax */
int ast_say_time_pt(struct ast_channel *chan, time_t t, char *ints, char *lang)
{
struct tm tm;
int res = 0;
int hour;
localtime_r(&t,&tm);
hour = tm.tm_hour;
if (!res)
res = ast_say_number(chan, hour, ints, lang, "f");
if (tm.tm_min) {
if (!res)
res = wait_file(chan, ints, "digits/pt-e", lang);
if (!res)
res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
} else {
if (!res)
res = wait_file(chan, ints, "digits/pt-hora", lang);
if (tm.tm_hour != 1)
if (!res)
res = wait_file(chan, ints, "digits/pt-sss", lang);
}
if (!res)
res = ast_say_number(chan, hour, ints, lang, (char *) NULL);
return res;
}
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
/* Taiwanese syntax */
int ast_say_time_tw(struct ast_channel *chan, time_t t, char *ints, char *lang)
{
struct tm tm;
int res = 0;
int hour, pm=0;
localtime_r(&t,&tm);
hour = tm.tm_hour;
if (!hour)
hour = 12;
else if (hour == 12)
pm = 1;
else if (hour > 12) {
hour -= 12;
pm = 1;
}
if (pm) {
if (!res)
res = ast_streamfile(chan, "digits/p-m", lang);
} else {
if (!res)
res = ast_streamfile(chan, "digits/a-m", lang);
}
if (!res)
res = ast_waitstream(chan, ints);
if (!res)
res = ast_say_number(chan, hour, ints, lang, (char *) NULL);
if (!res)
res = ast_streamfile(chan, "digits/oclock", lang);
if (!res)
res = ast_waitstream(chan, ints);
if (!res)
res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
if (!res)
res = ast_streamfile(chan, "digits/minute", lang);
if (!res)
res = ast_waitstream(chan, ints);
return res;
}
int ast_say_datetime(struct ast_channel *chan, time_t t, char *ints, char *lang)
{
if (!strcasecmp(lang, "en") ) { /* English syntax */
return(ast_say_datetime_en(chan, t, ints, lang));
} else if (!strcasecmp(lang, "nl") ) { /* Dutch syntax */
return(ast_say_datetime_nl(chan, t, ints, lang));
} else if (!strcasecmp(lang, "pt") ) { /* Portuguese syntax */
return(ast_say_datetime_pt(chan, t, ints, lang));
} else if (!strcasecmp(lang, "tw") ) { /* Taiwanese syntax */
return(ast_say_datetime_tw(chan, t, ints, lang));
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
}
/* Default to English */
return(ast_say_datetime_en(chan, t, ints, lang));
}
/* English syntax */
int ast_say_datetime_en(struct ast_channel *chan, time_t t, char *ints, char *lang)
{
struct tm tm;
char fn[256];
int res = 0;
int hour, pm=0;
localtime_r(&t,&tm);
if (!res) {
snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
res = ast_streamfile(chan, fn, lang);
if (!res)
res = ast_waitstream(chan, ints);
}
if (!res) {
snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
res = ast_streamfile(chan, fn, lang);
if (!res)
res = ast_waitstream(chan, ints);
}
if (!res)
res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL);
hour = tm.tm_hour;
if (!hour)
hour = 12;
else if (hour == 12)
pm = 1;
else if (hour > 12) {
hour -= 12;
pm = 1;
}
if (!res)
res = ast_say_number(chan, hour, ints, lang, (char *) NULL);
if (tm.tm_min > 9) {
if (!res)
res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
} else if (tm.tm_min) {
if (!res)
res = ast_streamfile(chan, "digits/oh", lang);
if (!res)
res = ast_waitstream(chan, ints);
if (!res)
res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
} else {
if (!res)
res = ast_streamfile(chan, "digits/oclock", lang);
if (!res)
res = ast_waitstream(chan, ints);
}
if (pm) {
if (!res)
res = ast_streamfile(chan, "digits/p-m", lang);
} else {
if (!res)
res = ast_streamfile(chan, "digits/a-m", lang);
}
if (!res)
res = ast_waitstream(chan, ints);
if (!res)
res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL);
return res;
}
/* Dutch syntax */
int ast_say_datetime_nl(struct ast_channel *chan, time_t t, char *ints, char *lang)
{
struct tm tm;
int res = 0;
localtime_r(&t,&tm);
res = ast_say_date(chan, t, ints, lang);
if (!res) {
res = ast_streamfile(chan, "digits/nl-om", lang);
if (!res)
res = ast_waitstream(chan, ints);
}
if (!res)
ast_say_time(chan, t, ints, lang);
return res;
}
/* Portuguese syntax */
int ast_say_datetime_pt(struct ast_channel *chan, time_t t, char *ints, char *lang)
char fn[256];
int res = 0;
int hour, pm=0;
snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
res = ast_streamfile(chan, fn, lang);
if (!res)
res = ast_waitstream(chan, ints);
}
if (!res) {
snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
res = ast_streamfile(chan, fn, lang);
if (!res)
res = ast_waitstream(chan, ints);
}
if (!res)
Mark Spencer
committed
res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL);
if (!hour)
hour = 12;
else if (hour == 12)
pm = 1;
else if (hour > 12) {
hour -= 12;
pm = 1;
}
if (!res)
Mark Spencer
committed
res = ast_say_number(chan, hour, ints, lang, (char *) NULL);
Mark Spencer
committed
res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
if (!res)
res = ast_streamfile(chan, "digits/oh", lang);
if (!res)
res = ast_waitstream(chan, ints);
if (!res)
Mark Spencer
committed
res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
} else {
if (!res)
res = ast_streamfile(chan, "digits/oclock", lang);
if (!res)
res = ast_waitstream(chan, ints);
}
if (pm) {
if (!res)
res = ast_streamfile(chan, "digits/p-m", lang);
} else {
if (!res)
res = ast_streamfile(chan, "digits/a-m", lang);
}
if (!res)
res = ast_waitstream(chan, ints);
if (!res)
Mark Spencer
committed
res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL);
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
/* Taiwanese syntax */
int ast_say_datetime_tw(struct ast_channel *chan, time_t t, char *ints, char *lang)
{
struct tm tm;
char fn[256];
int res = 0;
int hour, pm=0;
localtime_r(&t,&tm);
if (!res)
res = ast_say_number(chan, tm.tm_year + 1900, ints, lang, (char *) NULL);
if (!res) {
snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
res = ast_streamfile(chan, fn, lang);
if (!res)
res = ast_waitstream(chan, ints);
}
if (!res)
res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL);
if (!res) {
snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
res = ast_streamfile(chan, fn, lang);
if (!res)
res = ast_waitstream(chan, ints);
}
hour = tm.tm_hour;
if (!hour)
hour = 12;
else if (hour == 12)
pm = 1;
else if (hour > 12) {
hour -= 12;
pm = 1;
}
if (pm) {
if (!res)
res = ast_streamfile(chan, "digits/p-m", lang);
} else {
if (!res)
res = ast_streamfile(chan, "digits/a-m", lang);
}
if (!res)
res = ast_waitstream(chan, ints);
if (!res)
res = ast_say_number(chan, hour, ints, lang, (char *) NULL);
if (!res)
res = ast_streamfile(chan, "digits/oclock", lang);
if (!res)
res = ast_waitstream(chan, ints);
if (!res)
res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
if (!res)
res = ast_streamfile(chan, "digits/minute", lang);
if (!res)
res = ast_waitstream(chan, ints);
return res;
}
int ast_say_datetime_from_now(struct ast_channel *chan, time_t t, char *ints, char *lang)
{
if (!strcasecmp(lang, "en") ) { /* English syntax */
return(ast_say_datetime_from_now_en(chan, t, ints, lang));
} else if (!strcasecmp(lang, "pt") ) { /* Portuguese syntax */
return(ast_say_datetime_from_now_pt(chan, t, ints, lang));
}
/* Default to English */
return(ast_say_datetime_from_now_en(chan, t, ints, lang));
}
/* English syntax */
int ast_say_datetime_from_now_en(struct ast_channel *chan, time_t t, char *ints, char *lang)
{
int res=0;
time_t nowt;
int daydiff;
struct tm tm;
struct tm now;
localtime_r(&t,&tm);
localtime_r(&nowt,&now);
daydiff = now.tm_yday - tm.tm_yday;
if ((daydiff < 0) || (daydiff > 6)) {
/* Day of month and month */
if (!res) {
snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
res = ast_streamfile(chan, fn, lang);
if (!res)
res = ast_waitstream(chan, ints);
}
if (!res)
Mark Spencer
committed
res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL);
} else if (daydiff) {
/* Just what day of the week */
if (!res) {
snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
res = ast_streamfile(chan, fn, lang);
if (!res)
res = ast_waitstream(chan, ints);
}
} /* Otherwise, it was today */
if (!res)
res = ast_say_time(chan, t, ints, lang);
return res;
}
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
/* Portuguese syntax */
int ast_say_datetime_from_now_pt(struct ast_channel *chan, time_t t, char *ints, char *lang)
{
int res=0;
time_t nowt;
int daydiff;
struct tm tm;
struct tm now;
char fn[256];
time(&nowt);
localtime_r(&t,&tm);
localtime_r(&nowt,&now);
daydiff = now.tm_yday - tm.tm_yday;
if ((daydiff < 0) || (daydiff > 6)) {
/* Day of month and month */
if (!res)
res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL);
if (!res)
res = wait_file(chan, ints, "digits/pt-de", lang);
snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
if (!res)
res = wait_file(chan, ints, fn, lang);
} else if (daydiff) {
/* Just what day of the week */
snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
if (!res)
res = wait_file(chan, ints, fn, lang);
} /* Otherwise, it was today */
snprintf(fn, sizeof(fn), "digits/pt-ah");
if (!res)
res = wait_file(chan, ints, fn, lang);
if (tm.tm_hour != 1)
if (!res)
res = wait_file(chan, ints, "digits/pt-sss", lang);
if (!res)
res = ast_say_time(chan, t, ints, lang);
return res;
}