diff --git a/src/mod/say/mod_say_de/mod_say_de.c b/src/mod/say/mod_say_de/mod_say_de.c index 7b4aa75457..09ba7f77e3 100644 --- a/src/mod/say/mod_say_de/mod_say_de.c +++ b/src/mod/say/mod_say_de/mod_say_de.c @@ -87,7 +87,7 @@ static switch_status_t play_group(switch_say_method_t method, switch_say_gender_ if (a) { /*german nominativ for "one" in numbers like 21, 171, 4591 is flexed("ein" instead of "eins"), 2-9 are not*/ if ( a == 1 ) { - say_file("digits/s-1.wav"); + say_file("digits/1_n.wav"); } else { say_file("digits/%d.wav", a); } @@ -99,7 +99,7 @@ static switch_status_t play_group(switch_say_method_t method, switch_say_gender_ /*german nominativ for "one" in numbers like 21, 171, 4591 is flexed, 2-9 are not*/ if (c > 0) { if ( c == 1 ) { - say_file("digits/s-1.wav"); + say_file("digits/1_n.wav"); } else { say_file("digits/%d.wav", c); } @@ -145,9 +145,9 @@ static switch_status_t play_group(switch_say_method_t method, switch_say_gender_ /*"one" used as an article is feminine or masculine in german, e.g. voicemail-message is feminine only applies to the likes of 1, 101, 1001 etc.*/ if ( b == 0 && c == 1 && gender == SSG_FEMININE ) { - say_file("digits/1_f.wav"); + say_file("digits/1_f.wav"); } else if ( b == 0 && c == 1 && what ) { - say_file("digits/s-1.wav"); + say_file("digits/1_n.wav"); } else { say_file("digits/%d.wav", c); } @@ -163,7 +163,7 @@ static switch_status_t play_group(switch_say_method_t method, switch_say_gender_ static switch_status_t de_say_general_count(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args) { - int in; + long in; int x = 0; int places[9] = { 0 }; char sbuf[128] = ""; @@ -187,7 +187,7 @@ static switch_status_t de_say_general_count(switch_core_session_t *session, char return SWITCH_STATUS_GENERR; } - in = atoi(tosay); + in = atol(tosay); if (in != 0) { /*fills the places-array with tosay(resp. in) from tail to front e.g. 84371 would be places[|1|7|3|4|8|0|0|0|], up to 1 billion minus 1*/ for (x = 8; x >= 0; x--) { @@ -223,9 +223,9 @@ static switch_status_t de_say_general_count(switch_core_session_t *session, char static switch_status_t de_say_time(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args) { int32_t t; - switch_time_t target = 0; - switch_time_exp_t tm; - uint8_t say_date = 0, say_time = 0; + switch_time_t target = 0, target_now = 0; + switch_time_exp_t tm, tm_now; + uint8_t say_date = 0, say_time = 0, say_year = 0, say_month = 0, say_dow = 0, say_day = 0, say_yesterday = 0, say_today = 0; switch_channel_t *channel = switch_core_session_get_channel(session); const char *tz = switch_channel_get_variable(channel, "timezone"); @@ -250,8 +250,9 @@ static switch_status_t de_say_time(switch_core_session_t *session, char *tosay, minutes = atoi(tme); } } + free(tme); } else { - if ((seconds = atoi(tosay)) <= 0) { + if ((seconds = atol(tosay)) <= 0) { seconds = (int64_t) switch_epoch_time_now(NULL); } @@ -270,7 +271,7 @@ static switch_status_t de_say_time(switch_core_session_t *session, char *tosay, if (hours) { if (hours == 1) { - say_file("digits/1_f.wav"); + say_file("digits/1_n.wav"); say_file("time/hour.wav"); } else { say_num(hours, SSM_PRONOUNCED); @@ -311,10 +312,12 @@ static switch_status_t de_say_time(switch_core_session_t *session, char *tosay, return SWITCH_STATUS_SUCCESS; } - if ((t = atoi(tosay)) > 0) { + if ((t = atol(tosay)) > 0) { target = switch_time_make(t, 0); + target_now = switch_micro_time_now(); } else { target = switch_micro_time_now(); + target_now = switch_micro_time_now(); } if (tz) { @@ -322,11 +325,14 @@ static switch_status_t de_say_time(switch_core_session_t *session, char *tosay, switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Timezone is [%s]\n", tz); if (check) { switch_time_exp_tz(&tm, target, check); + switch_time_exp_tz(&tm_now, target_now, check); } else { switch_time_exp_tz_name(tz, &tm, target); + switch_time_exp_tz_name(tz, &tm_now, target_now); } } else { switch_time_exp_lt(&tm, target); + switch_time_exp_lt(&tm_now, target_now); } switch (say_args->type) { @@ -338,41 +344,95 @@ static switch_status_t de_say_time(switch_core_session_t *session, char *tosay, break; case SST_CURRENT_TIME: say_time = 1; + break; + case SST_SHORT_DATE_TIME: + say_time = 1; + //Time is in the future + if ((tm.tm_year > tm_now.tm_year) || + (tm.tm_year == tm_now.tm_year && tm.tm_mon > tm_now.tm_mon) || + (tm.tm_year == tm_now.tm_year && tm.tm_mon == tm_now.tm_mon && tm.tm_mday > tm_now.tm_mday)) + { + say_date = 1; + break; + } + //Time is today or earlier + if (tm.tm_year != tm_now.tm_year) { + say_date = 1; + break; + } + if (tm.tm_yday == tm_now.tm_yday) { + say_today = 1; + break; + } + if (tm.tm_yday == tm_now.tm_yday - 1) { + say_yesterday = 1; + break; + } + if (tm.tm_yday >= tm_now.tm_yday - 5) { + say_dow = 1; + break; + } + if (tm.tm_mon != tm_now.tm_mon) { + say_month = say_day = say_dow = 1; + break; + } + + say_month = say_day = say_dow = 1; + break; default: break; } - if (say_date) { - say_args->gender = SSG_MASCULINE; - say_file("time/day-%d.wav", tm.tm_wday); - say_num(tm.tm_mday, SSM_COUNTED); - say_file("time/mon-%d.wav", tm.tm_mon); - say_num(tm.tm_year + 1900, SSM_PRONOUNCED); + if (say_today) { + say_file("time/today.wav"); } + if (say_yesterday) { + say_file("time/yesterday.wav"); + } + if (say_dow) { + say_file("time/day-%d.wav", tm.tm_wday); + } + + if (say_month) { + say_file("time/mon-%d.wav", tm.tm_mon); + } + + if (say_day) { + say_args->gender = SSG_MASCULINE; + say_num(tm.tm_mday, SSM_COUNTED); + } + + if (say_year) { + say_args->gender = SSG_NEUTER; + say_num(tm.tm_year + 1900, SSM_PRONOUNCED_YEAR); + } + + if (say_date) { + say_dow = say_day = say_month = say_year = 1; + say_today = say_yesterday = 0; + } if (say_time) { - if (say_date) { - say_file("time/at.wav"); - } + if (say_date || say_today || say_yesterday || say_dow) { + say_file("time/at.wav"); + } - if (tm.tm_hour == 1) { - say_file("digits/s-1.wav"); - } else { - say_num(tm.tm_hour, SSM_PRONOUNCED); - } - say_file("time/oclock.wav"); + if (tm.tm_hour == 1) { + say_args->gender = SSG_NEUTER; + say_num(tm.tm_hour, SSM_PRONOUNCED); + } else { + say_num(tm.tm_hour, SSM_PRONOUNCED); + } + + say_file("time/oclock.wav"); - if (tm.tm_min > 0) { - say_file("currency/and.wav"); - if (tm.tm_min == 1) { - say_file("digits/1_f.wav") - say_file("time/minute.wav"); - } else { - say_num(tm.tm_min, SSM_PRONOUNCED); - say_file("time/minutes.wav"); - } - } + if (tm.tm_min < 10) { + say_file("digits/0.wav"); + say_num(tm.tm_min, SSM_PRONOUNCED); + } else { + say_num(tm.tm_min, SSM_PRONOUNCED); + } } return SWITCH_STATUS_SUCCESS; @@ -413,7 +473,7 @@ static switch_status_t de_say_money(switch_core_session_t *session, char *tosay, /* Say dollar amount */ if (atoi(dollars) == 1) { - say_file("digits/1.wav"); + say_file("digits/1_n.wav"); say_file("currency/dollar.wav"); } else { de_say_general_count(session, dollars, say_args, args); @@ -425,7 +485,7 @@ static switch_status_t de_say_money(switch_core_session_t *session, char *tosay, /* Say "and" */ say_file("currency/and.wav"); if (atoi(cents) == 1) { - say_file("digits/1.wav"); + say_file("digits/1_n.wav"); say_file("currency/cent.wav"); } else { de_say_general_count(session, cents, say_args, args);