static switch_status_t ru_say_time(switch_say_file_handle_t *sh, char *tosay, switch_say_args_t *say_args,say_opt_t *say_opt) { int32_t t; char buf[80]; 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; const char *tz = NULL; tz = switch_say_file_handle_get_variable(sh, "timezone"); //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " ru_say_time %s type=%d method=%d\n", tosay, say_args->type, say_args->method); if (say_args->type == SST_TIME_MEASUREMENT) { int64_t hours = 0; int64_t minutes = 0; int64_t seconds = 0; int64_t r = 0; if (strchr(tosay, ':')) { char *tme = strdup(tosay); char *p; if ((p = strrchr(tme, ':'))) { *p++ = '\0'; seconds = atoi(p); if ((p = strchr(tme, ':'))) { *p++ = '\0'; minutes = atoi(p); if (tme) { hours = atoi(tme); } } else { minutes = atoi(tme); } } free(tme); } else { if ((seconds = atol(tosay)) <= 0) { seconds = (int64_t) switch_epoch_time_now(NULL); } if (seconds >= 60) { minutes = seconds / 60; r = seconds % 60; } if (minutes >= 60) { hours = minutes / 60; r = minutes % 60; minutes = r; } } switch_snprintf(buf, sizeof(buf), "%u", (unsigned) hours); ru_say_count(sh, buf, male, nominativus); if (((hours % 10) == 1) && (hours != 11)) { /* час */ switch_say_file(sh, "time/hour"); } else if (((hours % 10 > 1) && (hours % 10 < 5)) && ((hours < 12) || (hours > 14))) { switch_say_file(sh, "time/hours-a"); /* часа */ } else { switch_say_file(sh, "time/hours"); /* часов */ } switch_snprintf(buf, sizeof(buf), "%u", (unsigned) minutes); //перевести минуты в *char ru_say_count(sh, buf, female, nominativus); if (((minutes % 10) == 1) && (minutes != 11)) { switch_say_file(sh, "time/minute"); //минута } else if (((minutes % 10 > 1) && (minutes % 10 < 5)) && ((minutes < 12) || (minutes > 14))) { switch_say_file(sh, "time/minutes-i"); // минуты } else { switch_say_file(sh, "time/minutes"); //минут } if (seconds != 0) { switch_snprintf(buf, sizeof(buf), "%u", (unsigned) seconds); ru_say_count(sh, buf, female, nominativus); if (((seconds % 10) == 1) && (seconds != 11)) { switch_say_file(sh, "time/second"); // секунда } else if (((seconds % 10 > 1) && (seconds % 10 < 5)) && ((seconds < 12) || (seconds > 14))) { switch_say_file(sh, "time/seconds-i"); // секуны } else { switch_say_file(sh, "time/seconds"); //секунд } } return SWITCH_STATUS_SUCCESS; } 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) { int check = atoi(tz); //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) { case SST_CURRENT_DATE_TIME: say_date = say_time = 1; break; case SST_CURRENT_DATE: say_date = 1; break; case SST_CURRENT_TIME: say_time = 1; break; case SST_SHORT_DATE_TIME: say_time = 1; tm.tm_sec = 0; // В коротком варианте секунды не проговариваем 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_today) { switch_say_file(sh, "time/today"); } if (say_yesterday) { switch_say_file(sh, "time/yesterday"); } if (say_dow) { switch_say_file(sh, "time/day-%d", tm.tm_wday); } if (say_date) { say_year = say_month = say_day = say_dow = 1; say_today = say_yesterday = 0; } if (say_day) { switch_snprintf(buf, sizeof(buf), "%u", (unsigned) tm.tm_mday); ru_say_count(sh, buf, male_h, genitivus); } if (say_month) { switch_say_file(sh, "time/mon-%d", tm.tm_mon); } if (say_year) { switch_snprintf(buf, sizeof(buf), "%u", (unsigned) (tm.tm_year + 1900)); ru_say_count(sh, buf, male_h, genitivus); switch_say_file(sh, "time/h-year"); } if (say_time) { if (say_month || say_year || say_date || say_dow) { switch_say_file(sh, "time/at"); } switch_snprintf(buf, sizeof(buf), "%d:%d:%d", tm.tm_hour, tm.tm_min, tm.tm_sec); say_args->type = SST_TIME_MEASUREMENT; ru_say_time(sh, buf, say_args,say_opt); } return SWITCH_STATUS_SUCCESS; }
static switch_status_t hu_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, 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"); if (say_args->type == SST_TIME_MEASUREMENT) { int64_t hours = 0; int64_t minutes = 0; int64_t seconds = 0; int64_t r = 0; if (strchr(tosay, ':')) { char *tme = switch_core_session_strdup(session, tosay); char *p; if ((p = strrchr(tme, ':'))) { *p++ = '\0'; seconds = atoi(p); if ((p = strchr(tme, ':'))) { *p++ = '\0'; minutes = atoi(p); if (tme) { hours = atoi(tme); } } else { minutes = atoi(tme); } } } else { if ((seconds = atol(tosay)) <= 0) { seconds = (int64_t) switch_epoch_time_now(NULL); } if (seconds >= 60) { minutes = seconds / 60; r = seconds % 60; seconds = r; } if (minutes >= 60) { hours = minutes / 60; r = minutes % 60; minutes = r; } } if (hours) { say_num(hours, SSM_PRONOUNCED); say_file("time/hour.wav"); } else { say_file("digits/0.wav"); say_file("time/hour.wav"); } if (minutes) { say_num(minutes, SSM_PRONOUNCED); say_file("time/minute.wav"); } else { say_file("digits/0.wav"); say_file("time/minute.wav"); } if (seconds) { say_num(seconds, SSM_PRONOUNCED); say_file("time/second.wav"); } else { say_file("digits/0.wav"); say_file("time/second.wav"); } return SWITCH_STATUS_SUCCESS; } 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) { int check = atoi(tz); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), 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) { case SST_CURRENT_DATE_TIME: say_date = say_time = 1; break; case SST_CURRENT_DATE: say_date = 1; break; case SST_CURRENT_TIME: say_time = 1; break; case SST_SHORT_DATE_TIME: say_time = 1; 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_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_date) { say_year = say_month = say_day = say_dow = 1; say_today = say_yesterday = 0; } if (say_year) { say_num(tm.tm_year + 1900, SSM_PRONOUNCED); } if (say_month) { say_file("time/mon-%d.wav", tm.tm_mon); } if (say_day) { say_num(tm.tm_mday, SSM_PRONOUNCED); } if (say_time) { say_num(tm.tm_hour, SSM_PRONOUNCED); say_file("time/hour.wav"); say_num(tm.tm_min, SSM_PRONOUNCED); say_file("time/minute.wav"); } return SWITCH_STATUS_SUCCESS; }
static switch_status_t fr_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, 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"); if (say_args->type == SST_TIME_MEASUREMENT) { int64_t hours = 0; int64_t minutes = 0; int64_t seconds = 0; int64_t r = 0; if (strchr(tosay, ':')) { char *tme = switch_core_session_strdup(session, tosay); char *p; if ((p = strrchr(tme, ':'))) { *p++ = '\0'; seconds = atoi(p); if ((p = strchr(tme, ':'))) { *p++ = '\0'; minutes = atoi(p); if (tme) { hours = atoi(tme); } } else { minutes = atoi(tme); } } } else { if ((seconds = atol(tosay)) <= 0) { seconds = (int64_t) switch_epoch_time_now(NULL); } if (seconds >= 60) { minutes = seconds / 60; r = seconds % 60; seconds = r; } if (minutes >= 60) { hours = minutes / 60; r = minutes % 60; minutes = r; } } say_args->gender = SSG_FEMININE; if (hours) { say_num(hours, SSM_PRONOUNCED); say_file("time/hour.wav"); } else { /* TODO MINUIT */ say_file("digits/0.wav"); say_file("time/hour.wav"); } if (minutes) { say_num(minutes, SSM_PRONOUNCED); say_file("time/minute.wav"); } else { /* TODO Aucune idee quoi faire jouer icit */ say_file("digits/0.wav"); say_file("time/minute.wav"); } if (seconds) { say_num(seconds, SSM_PRONOUNCED); say_file("time/second.wav"); } else { /* TODO Aucune idee quoi faire jouer icit */ say_file("digits/0.wav"); say_file("time/second.wav"); } return SWITCH_STATUS_SUCCESS; } 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) { int check = atoi(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) { case SST_CURRENT_DATE_TIME: say_date = say_time = 1; break; case SST_CURRENT_DATE: say_date = 1; break; case SST_CURRENT_TIME: say_time = 1; break; case SST_SHORT_DATE_TIME: say_time = 1; 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_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_date) { say_year = say_month = say_day = say_dow = 1; say_today = say_yesterday = 0; } if (say_day) { if (tm.tm_mday == 1) { /* 1 er Janvier,... 2 feb, 23 dec... */ say_args->gender = SSG_MASCULINE; say_num(tm.tm_mday, SSM_COUNTED); } else { say_args->gender = SSG_FEMININE; say_num(tm.tm_mday, SSM_PRONOUNCED); } } if (say_month) { say_file("time/mon-%d.wav", tm.tm_mon); } if (say_year) { say_args->gender = SSG_MASCULINE; say_num(tm.tm_year + 1900, SSM_PRONOUNCED); } if (say_time) { if (say_date || say_today || say_yesterday || say_dow) { say_file("time/at.wav"); } say_args->gender = SSG_FEMININE; say_num(tm.tm_hour, SSM_PRONOUNCED); say_file("time/hour.wav"); if (tm.tm_min) { say_num(tm.tm_min, SSM_PRONOUNCED); } } return SWITCH_STATUS_SUCCESS; }
static switch_status_t nl_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_channel_t *channel = switch_core_session_get_channel(session); const char *tz = switch_channel_get_variable(channel, "timezone"); if (say_args->type == SST_TIME_MEASUREMENT) { int64_t hours = 0; int64_t minutes = 0; int64_t seconds = 0; int64_t r = 0; if (strchr(tosay, ':')) { char *tme = switch_core_session_strdup(session, tosay); char *p; if ((p = strrchr(tme, ':'))) { *p++ = '\0'; seconds = atoi(p); if ((p = strchr(tme, ':'))) { *p++ = '\0'; minutes = atoi(p); hours = atoi(tme); } else { minutes = atoi(tme); } } } else { if ((seconds = atoi(tosay)) <= 0) { seconds = (int64_t) switch_epoch_time_now(NULL); } if (seconds >= 60) { minutes = seconds / 60; r = seconds % 60; seconds = r; } if (minutes >= 60) { hours = minutes / 60; r = minutes % 60; minutes = r; } } if (hours) { say_num(hours, SSM_PRONOUNCED); if (hours == 1) { say_file("time/hour.wav"); } else { say_file("time/hours.wav"); } } else { say_file("digits/0.wav"); say_file("time/hours.wav"); } if (minutes) { say_num(minutes, SSM_PRONOUNCED); if (minutes == 1) { say_file("time/minute.wav"); } else { say_file("time/minutes.wav"); } } else { say_file("digits/0.wav"); say_file("time/minutes.wav"); } if (seconds) { say_num(seconds, SSM_PRONOUNCED); if (seconds == 1) { say_file("time/second.wav"); } else { say_file("time/seconds.wav"); } } else { say_file("digits/0.wav"); say_file("time/seconds.wav"); } return SWITCH_STATUS_SUCCESS; } if ((t = atoi(tosay)) > 0) { target = switch_time_make(t, 0); } else { target = switch_micro_time_now(); } if (tz) { int check = atoi(tz); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Timezone is [%s]\n", tz); if (check) { switch_time_exp_tz(&tm, target, check); } else { switch_time_exp_tz_name(tz, &tm, target); } } else { switch_time_exp_lt(&tm, target); } switch (say_args->type) { case SST_CURRENT_DATE_TIME: say_date = say_time = 1; break; case SST_CURRENT_DATE: say_date = 1; break; case SST_CURRENT_TIME: say_time = 1; break; default: break; } if (say_date) { say_file("time/day-%d.wav", tm.tm_wday); say_file("time/mon-%d.wav", tm.tm_mon); say_num(tm.tm_mday, SSM_COUNTED); say_num(tm.tm_year + 1900, SSM_PRONOUNCED); } if (say_time) { int32_t hour = tm.tm_hour, pm = 0; if (hour > 12) { hour -= 12; pm = 1; } else if (hour == 12) { pm = 1; } else if (hour == 0) { hour = 12; pm = 0; } say_num(hour, SSM_PRONOUNCED); if (tm.tm_min > 9) { say_num(tm.tm_min, SSM_PRONOUNCED); } else if (tm.tm_min) { say_file("time/oh.wav"); say_num(tm.tm_min, SSM_PRONOUNCED); } else { say_file("time/oclock.wav"); } say_file("time/%s.wav", pm ? "p-m" : "a-m"); } return SWITCH_STATUS_SUCCESS; }
static switch_status_t pl_say_time(switch_say_file_handle_t *sh, char *tosay, switch_say_args_t *say_args) { int32_t t; 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; const char *tz = NULL; tz = switch_say_file_handle_get_variable(sh, "timezone"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "SAY: %s\n", tosay); if (say_args->type == SST_TIME_MEASUREMENT) { int64_t hours = 0; int64_t minutes = 0; int64_t seconds = 0; int64_t r = 0; if (strchr(tosay, ':')) { char *tme = strdup(tosay); char *p; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse time string!\n"); if ((p = strrchr(tme, ':'))) { *p++ = '\0'; seconds = atoi(p); if ((p = strchr(tme, ':'))) { *p++ = '\0'; minutes = atoi(p); if (tme) { hours = atoi(tme); } } else { minutes = atoi(tme); } } free(tme); } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse time in seconds!\n"); if ((seconds = atol(tosay)) <= 0) { seconds = (int64_t) switch_epoch_time_now(NULL); } if (seconds >= 60) { minutes = seconds / 60; r = seconds % 60; seconds = r; } if (minutes >= 60) { hours = minutes / 60; r = minutes % 60; minutes = r; } } if (hours) { int hd = 0, hj = 0; say_num(sh, hours, SSM_PRONOUNCED, SSG_FEMININE); hj = hours % 10; hd = (hours/10) % 10; if (hours == 1) { switch_say_file(sh, "time/t_godzina"); }else if (hd != 1 && ( hj == 2 || hj == 3 || hj == 4)) { switch_say_file(sh, "time/t_godziny"); } else { switch_say_file(sh, "time/t_godzin"); } } else { switch_say_file(sh, "digits/0"); switch_say_file(sh, "time/t_godzin"); } if (minutes) { int md = 0, mj = 0; say_num(sh, minutes, SSM_PRONOUNCED, SSG_FEMININE); mj = minutes % 10; md = (minutes/10) % 10; if (minutes == 1) { switch_say_file(sh, "time/minuta"); }else if (md != 1 && ( mj == 2 || mj == 3 || mj == 4)) { switch_say_file(sh, "time/t_minuty"); } else { switch_say_file(sh, "time/t_minut"); } } else { switch_say_file(sh, "digits/0"); switch_say_file(sh, "time/t_minut"); } if (seconds) { int sd = 0, sj = 0; say_num(sh, seconds, SSM_PRONOUNCED, SSG_FEMININE); sj = seconds % 10; sd = (seconds/10) % 10; if (seconds == 1) { switch_say_file(sh, "time/t_sekunda"); }else if (sd != 1 && ( sj == 2 || sj == 3 || sj == 4)) { switch_say_file(sh, "time/t_sekundy"); } else { switch_say_file(sh, "time/t_sekund"); } } else { switch_say_file(sh, "digits/0"); switch_say_file(sh, "time/t_sekund"); } return SWITCH_STATUS_SUCCESS; } 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) { int check = atoi(tz); 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) { case SST_CURRENT_DATE_TIME: say_date = say_time = 1; break; case SST_CURRENT_DATE: say_date = 1; break; case SST_CURRENT_TIME: say_time = 1; break; case SST_SHORT_DATE_TIME: say_time = 1; 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_today) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SAY: today\n"); switch_say_file(sh, "time/t_dzisiaj"); } if (say_yesterday) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SAY: yesterday\n"); switch_say_file(sh, "time/t_wczoraj"); } if (say_dow) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SAY: dow\n"); switch_say_file(sh, "time/day-%d", tm.tm_wday); } if (say_date) { say_year = say_month = say_day = say_dow = 1; say_today = say_yesterday = 0; } if (say_day) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SAY: day\n"); //say_num(sh, tm.tm_mday, SSM_COUNTED, SSG_MASCULINE); switch_say_file(sh, "digits/%02d_pm", tm.tm_mday); } if (say_month) { switch_say_file(sh, "time/mon-%d_D", tm.tm_mon); } if (say_year) { say_num(sh, tm.tm_year + 1900, SSM_COUNTED, SSG_MASCULINE); //switch_say_file(sh, "time/t_roku"); } if (say_time) { switch_say_file(sh, "time/t_godzina"); say_num(sh, tm.tm_hour, SSM_COUNTED, SSG_FEMININE); //switch_say_file(sh, "digits/%da", tm.tm_hour); say_num(sh, tm.tm_min, SSM_PRONOUNCED, SSG_FEMININE); /* switch_say_file(sh, "digits/t_minut");*/ } return SWITCH_STATUS_SUCCESS; }
static switch_status_t sin_say_time(switch_say_file_handle_t *sh, char *tosay, switch_say_args_t *say_args) { int32_t t; 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; const char *tz = NULL; tz = switch_say_file_handle_get_variable(sh, "timezone"); if (say_args->type == SST_TIME_MEASUREMENT) { int64_t hours = 0; int64_t minutes = 0; int64_t seconds = 0; int64_t r = 0; if (strchr(tosay, ':')) { char *tme = strdup(tosay); char *p; if ((p = strrchr(tme, ':'))) { *p++ = '\0'; seconds = atoi(p); if ((p = strchr(tme, ':'))) { *p++ = '\0'; minutes = atoi(p); if (tme) { hours = atoi(tme); } } else { minutes = atoi(tme); } } free(tme); } else { if ((seconds = atol(tosay)) <= 0) { seconds = (int64_t) switch_epoch_time_now(NULL); } if (seconds >= 60) { minutes = seconds / 60; r = seconds % 60; seconds = r; } if (minutes >= 60) { hours = minutes / 60; r = minutes % 60; minutes = r; } } if (hours) { if (hours == 1) { switch_say_file(sh, "time/payai"); } else { switch_say_file(sh, "time/paya"); say_num(sh, hours, SSM_PRONOUNCED); } } else { /*switch_say_file(sh, "time/s_hours"); switch_say_file(sh, "digits/s_i-0"); */ } if (minutes) { if (minutes == 1) { switch_say_file(sh, "time/winadiyai"); } else { switch_say_file(sh, "time/winadi"); say_num(sh, minutes, SSM_PRONOUNCED); } } else { /*switch_say_file(sh, "time/s_minutes"); switch_say_file(sh, "digits/s_i-0");*/ } if (seconds) { if (seconds == 1) { switch_say_file(sh, "time/thathparayai"); } else { switch_say_file(sh, "time/thathpara"); say_num(sh, seconds, SSM_PRONOUNCED); } } else { /* switch_say_file(sh, "time/s_seconds"); switch_say_file(sh, "digits/s_i-0");*/ } return SWITCH_STATUS_SUCCESS; } 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) { int check = atoi(tz); 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) { case SST_CURRENT_DATE_TIME: say_date = say_time = 1; break; case SST_CURRENT_DATE: say_date = 1; break; case SST_CURRENT_TIME: say_time = 1; break; case SST_SHORT_DATE_TIME: say_time = 1; 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_today) { switch_say_file(sh, "time/today"); } if (say_yesterday) { switch_say_file(sh, "time/yesterday"); } if (say_dow) { switch_say_file(sh, "time/day-s_%d", tm.tm_wday); } if (say_date) { say_year = say_month = say_day = say_dow = 1; say_today = say_yesterday = 0; } if (say_month) { switch_say_file(sh, "time/mon-s_%d", tm.tm_mon); } if (say_day) { say_num(sh, tm.tm_mday, SSM_COUNTED); } if (say_year) { say_num(sh, tm.tm_year + 1900, SSM_PRONOUNCED_YEAR); } if (say_time) { int32_t hour = tm.tm_hour, pm = 0; if (say_date || say_today || say_yesterday || say_dow) { switch_say_file(sh, "time/at"); } if (hour > 12) { hour -= 12; pm = 1; } else if (hour == 12) { pm = 1; } else if (hour == 0) { hour = 12; pm = 0; } say_num(sh, hour, SSM_PRONOUNCED); if (tm.tm_min > 9) { say_num(sh, tm.tm_min, SSM_PRONOUNCED); } else if (tm.tm_min) { switch_say_file(sh, "time/oh"); say_num(sh, tm.tm_min, SSM_PRONOUNCED); } else { switch_say_file(sh, "time/oclock"); } switch_say_file(sh, "time/%s", pm ? "p-m" : "a-m"); } return SWITCH_STATUS_SUCCESS; }
static switch_status_t fa_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, 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"); int jalali_year = 1, jalali_month = 0, jalali_day = 0; if (say_args->type == SST_TIME_MEASUREMENT) { int64_t hours = 0; int64_t minutes = 0; int64_t seconds = 0; int64_t r = 0; if (strchr(tosay, ':')) { char *tme = switch_core_session_strdup(session, tosay); char *p; if ((p = strrchr(tme, ':'))) { *p++ = '\0'; seconds = atoi(p); if ((p = strchr(tme, ':'))) { *p++ = '\0'; minutes = atoi(p); if (tme) { hours = atoi(tme); } } else { minutes = atoi(tme); } } } else { if ((seconds = atol(tosay)) <= 0) { seconds = (int64_t) switch_epoch_time_now(NULL); } if (seconds >= 60) { minutes = seconds / 60; r = seconds % 60; seconds = r; } if (minutes >= 60) { hours = minutes / 60; r = minutes % 60; minutes = r; } } if (hours) { say_num(hours, SSM_PRONOUNCED); if(minutes || seconds) { say_file("time/hour+.wav"); } else say_file("time/hour.wav"); } if (minutes) { say_num(minutes, SSM_PRONOUNCED); if( seconds ) { say_file("time/minutes+.wav"); } else say_file("time/minutes.wav"); } if (seconds) { say_num(seconds, SSM_PRONOUNCED); say_file("time/seconds.wav"); } return SWITCH_STATUS_SUCCESS; } 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) { int check = atoi(tz); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), 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) { case SST_CURRENT_DATE_TIME: say_date = say_time = 1; break; case SST_CURRENT_DATE: say_date = 1; break; case SST_CURRENT_TIME: say_time = 1; break; case SST_SHORT_DATE_TIME: say_time = 1; 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_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_date) { say_year = say_month = say_day = say_dow = 1; say_today = say_yesterday = 0; } gregorian_to_jalali(&jalali_year,&jalali_month,&jalali_day,tm.tm_year + 1900,tm.tm_mon + 1,tm.tm_mday); if (say_day) { if(jalali_day > 20 && jalali_day != 30) { say_file("digits/%d+.wav", (jalali_day - jalali_day % 10)); say_file("digits/%de.wav", jalali_day % 10); } else say_file("digits/%de.wav", jalali_day); } if (say_month) { say_file("time/mon-%d.wav", jalali_month - 1); } if (say_year) { say_num(jalali_year, SSM_PRONOUNCED); } if (say_time) { int32_t hour = tm.tm_hour, pm = 0; if (say_date || say_today || say_yesterday || say_dow) { say_file("time/at.wav"); } if (hour > 12) { hour -= 12; pm = 1; } else if (hour == 12) { pm = 1; } else if (hour == 0) { hour = 12; pm = 0; } say_file("time/hour-e.wav"); say_file("digits/%do.wav",hour); play_group(SSM_PRONOUNCED, 0, (tm.tm_min - tm.tm_min % 10) / 10, tm.tm_min % 10, "time/minutes-e.wav", session, args); say_file("time/%s.wav", pm ? "p-m" : "a-m"); } return SWITCH_STATUS_SUCCESS; }
static switch_status_t hr_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, 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"); int sat_desetinka = 0; int sat_jedinica = 0; int minuta_desetinka = 0; int minuta_jedinica = 0; int sekunda_desetinka = 0; int sekunda_jedinica = 0; if (say_args->type == SST_TIME_MEASUREMENT) { int64_t hours = 0; int64_t minutes = 0; int64_t seconds = 0; int64_t r = 0; if (strchr(tosay, ':')) { char *tme = switch_core_session_strdup(session, tosay); char *p; if ((p = strrchr(tme, ':'))) { *p++ = '\0'; seconds = atoi(p); if ((p = strchr(tme, ':'))) { *p++ = '\0'; minutes = atoi(p); if (tme) { hours = atoi(tme); } } else { minutes = atoi(tme); } } } else { if ((seconds = atol(tosay)) <= 0) { seconds = (int64_t) switch_epoch_time_now(NULL); } if (seconds >= 60) { minutes = seconds / 60; r = seconds % 60; seconds = r; } if (minutes >= 60) { hours = minutes / 60; r = minutes % 60; minutes = r; } } sat_jedinica = hours % 10; if (hours > 10) sat_desetinka = (int) (hours / 10); if (hours) { say_num(hours, SSM_PRONOUNCED, ""); if (sat_desetinka == 0 && sat_jedinica == 0) { nop; } else if (sat_desetinka == 1) { say_file("time/sati.wav"); } else { switch(sat_jedinica) { case 1: say_file("time/sat.wav"); break; case 2: case 3: case 4: say_file("time/sata.wav"); break; case 0: case 5: case 6: case 7: case 8: case 9: say_file("time/sati.wav"); break; } } } minuta_jedinica = minutes % 10; if (minutes > 10) minuta_desetinka = (int) (minutes / 10); if (minutes) { if (minuta_desetinka == 1) { say_num(minutes, SSM_PRONOUNCED, ""); say_file("time/minuta.wav"); } else { switch(minuta_jedinica) { case 2: say_num(minutes, SSM_PRONOUNCED, "je"); say_file("time/minute.wav"); break; case 3: case 4: say_num(minutes, SSM_PRONOUNCED, ""); say_file("time/minute.wav"); break; case 1: say_num(minutes, SSM_PRONOUNCED, "a"); say_file("time/minuta.wav"); break; case 0: case 5: case 6: case 7: case 8: case 9: say_num(minutes, SSM_PRONOUNCED, ""); say_file("time/minuta.wav"); break; } } } sekunda_jedinica = seconds % 10; if (seconds > 10) sekunda_desetinka = (int) (seconds / 10); if (seconds) { if (sekunda_desetinka == 1) { say_num(seconds, SSM_PRONOUNCED, ""); say_file("time/sekundi.wav"); } else if (sekunda_desetinka == 0) { switch(sekunda_jedinica) { case 1: say_num(seconds, SSM_PRONOUNCED, "a"); say_file("time/sekunda.wav"); break; case 2: say_num(seconds, SSM_PRONOUNCED, "je"); say_file("time/sekunde.wav"); break; case 3: case 4: say_num(seconds, SSM_PRONOUNCED, ""); say_file("time/sekunde.wav"); break; case 0: case 5: case 6: case 7: case 8: case 9: say_file("time/sekundi.wav"); break; } } else { switch(sekunda_jedinica) { case 1: say_num(seconds, SSM_PRONOUNCED, "a"); say_file("time/sekunda.wav"); break; case 2: say_num(seconds, SSM_PRONOUNCED, "je"); say_file("time/sekunde.wav"); break; case 3: case 4: say_num(seconds, SSM_PRONOUNCED, ""); say_file("time/sekunde.wav"); break; case 0: case 5: case 6: case 7: case 8: case 9: say_num(seconds, SSM_PRONOUNCED, ""); say_file("time/sekundi.wav"); break; } } } return SWITCH_STATUS_SUCCESS; } 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) { int check = atoi(tz); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), 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) { case SST_CURRENT_DATE_TIME: say_date = say_time = 1; break; case SST_CURRENT_DATE: say_date = 1; break; case SST_CURRENT_TIME: say_time = 1; break; case SST_SHORT_DATE_TIME: say_time = 1; 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_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_date) { say_year = say_month = say_day = say_dow = 1; say_today = say_yesterday = 0; } if (say_day) { say_num(tm.tm_mday, SSM_COUNTED, ""); } if (say_month) { say_file("time/mon-%d.wav", tm.tm_mon); } if (say_year) { int y = tm.tm_year + 1900; int tis = 0; //say_num(tm.tm_year + 1900, SSM_PRONOUNCED, ""); //1 - 99 => h-1a.wav - h-99a.wav if (y >= 1 && y <= 99) { say_file("digits/h-%da.wav", y); } // [1-9]00 => h-[1-9]00a.wav else if (y >= 100 && y <= 900 && y % 100 == 0) { say_file("digits/h-%da.wav", y); } //[1-9]01 - [1-9]99 => [1-9]00.wav + (h-1a.wav - h-99a.wav) else if (y >= 100 && y <= 900 && y % 100 != 0) { say_file("digits/h-%da.wav", (int) y - (y % 100)); say_file("digits/h-%da.wav", (int) y % 100); } // 1000 => thousand-ta.wav else if (y == 1000) { say_file("digits/thousand-ta.wav"); } // 1001 - 1999 => thousand-u.wav + [1-9]00.wav + (h-1a.wav - h-99a.wav) else if (y >= 1001 && y <= 1999) { say_file("digits/thousand-u.wav"); if (0 != (int) ((y - 1000) - ((y - 1000) % 100))) say_file("digits/h-%da.wav", (int) ((y - 1000) - ((y - 1000) % 100))); say_file("digits/h-%da.wav", (int) y % 100); } //2000 => 2je.wav + thousand-ta.wav else if (y == 2000) { say_file("digits/2je.wav"); say_file("digits/thousand-ta.wav"); } // 2001 - 2999 => 2je.wav + thousands-e.wav + [1-9]00.wav + (h-1a.wav - h-99a.wav) else if (y >= 2001 && y <= 2999) { say_file("digits/2je.wav"); say_file("digits/thousands-e.wav"); if (0 != (int) ((y - 2000) - ((y - 2000) % 100))) say_file("digits/h-%da.wav", (int) ((y - 2000) - ((y - 2000) % 100))); say_file("digits/h-%da.wav", (int) y % 100); } // 3000 => [3-9].wav + thousand-ta.wav else if (y >= 3000 && y <= 9000 && y % 1000 == 0) { say_file("digits/%d.wav", (int) (y / 1000)); say_file("digits/thousand-ta.wav"); } // [3-9]001 - [3-9]999 => [3-9].wav + thousands-e.wav + [1-9]00.wav + (h-1a.wav - h-99a.wav) else if (y >= 3000 && y <= 9000 && y % 1000 != 0) { say_file("digits/%d.wav", (int) (y / 1000)); say_file("digits/thousands-e.wav"); tis = y - (y % 1000); if (0 != (int) ((y - tis) - ((y - tis) % 100))) say_file("digits/h-%da.wav", (int) ((y - tis) - ((y - tis) % 100))); say_file("digits/h-%da.wav", (int) y % 100); } //say_num(tm.tm_year + 1900, SSM_COUNTED, "a"); } if (say_time) { say_num(tm.tm_hour, SSM_PRONOUNCED, ""); sat_jedinica = tm.tm_hour % 10; if (tm.tm_hour >= 10) sat_desetinka = (int) (tm.tm_hour / 10); if (tm.tm_hour) { if (sat_desetinka == 0 && sat_jedinica == 0) { nop; } else if (sat_desetinka == 1) { say_file("time/sati.wav"); } else { switch(sat_jedinica) { case 1: say_file("time/sat.wav"); break; case 2: case 3: case 4: say_file("time/sata.wav"); break; case 0: case 5: case 6: case 7: case 8: case 9: say_file("time/sati.wav"); break; } } } minuta_jedinica = tm.tm_min % 10; if (tm.tm_min >= 10) minuta_desetinka = (int) (tm.tm_min / 10); if (tm.tm_min) { if (minuta_desetinka == 1) { say_num(tm.tm_min, SSM_PRONOUNCED, ""); say_file("time/minuta.wav"); } else { switch(minuta_jedinica) { case 2: say_num(tm.tm_min, SSM_PRONOUNCED, "je"); say_file("time/minute.wav"); break; case 3: case 4: say_num(tm.tm_min, SSM_PRONOUNCED, ""); say_file("time/minute.wav"); break; case 1: say_num(tm.tm_min, SSM_PRONOUNCED, "a"); say_file("time/minuta.wav"); break; case 0: case 5: case 6: case 7: case 8: case 9: say_num(tm.tm_min, SSM_PRONOUNCED, ""); say_file("time/minuta.wav"); break; } } } sekunda_jedinica = tm.tm_sec % 10; if (tm.tm_sec >= 10) sekunda_desetinka = (int) (tm.tm_sec / 10); if (tm.tm_sec) { if (sekunda_desetinka == 1) { say_num(tm.tm_sec, SSM_PRONOUNCED, ""); say_file("time/sekundi.wav"); } else if (sekunda_desetinka == 0) { switch(sekunda_jedinica) { case 1: say_num(tm.tm_sec, SSM_PRONOUNCED, "a"); say_file("time/sekunda.wav"); break; case 2: say_num(tm.tm_sec, SSM_PRONOUNCED, "je"); say_file("time/sekunde.wav"); break; case 3: case 4: say_num(tm.tm_sec, SSM_PRONOUNCED, ""); say_file("time/sekunde.wav"); break; case 0: case 5: case 6: case 7: case 8: case 9: say_file("time/sekundi.wav"); break; } } else { switch(sekunda_jedinica) { case 1: say_num(tm.tm_sec, SSM_PRONOUNCED, "a"); say_file("time/sekunda.wav"); break; case 2: say_num(tm.tm_sec, SSM_PRONOUNCED, "je"); say_file("time/sekunde.wav"); break; case 3: case 4: say_num(tm.tm_sec, SSM_PRONOUNCED, ""); say_file("time/sekunde.wav"); break; case 0: case 5: case 6: case 7: case 8: case 9: say_num(tm.tm_sec, SSM_PRONOUNCED, ""); say_file("time/sekundi.wav"); break; } } } } return SWITCH_STATUS_SUCCESS; }
static switch_status_t zh_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; switch_channel_t *channel = switch_core_session_get_channel(session); const char *tz = switch_channel_get_variable(channel, "timezone"); #if 0 switch_time_t this_morning; switch_time_exp_t tm2; #endif uint8_t say_date = 0; uint8_t say_time = 0; if (say_args->type == SST_TIME_MEASUREMENT) { int64_t hours = 0; int64_t minutes = 0; int64_t seconds = 0; int64_t r = 0; if (strchr(tosay, ':')) { char *tme = switch_core_session_strdup(session, tosay); char *p; if ((p = strrchr(tme, ':'))) { *p++ = '\0'; seconds = atoi(p); if ((p = strchr(tme, ':'))) { *p++ = '\0'; minutes = atoi(p); hours = atoi(tme); } else { minutes = atoi(tme); } } } else { if ((seconds = atoi(tosay)) <= 0) { seconds = (int64_t) switch_epoch_time_now(NULL); } if (seconds >= 60) { minutes = seconds / 60; r = seconds % 60; seconds = r; } if (minutes >= 60) { hours = minutes / 60; r = minutes % 60; minutes = r; } } if (hours) { if (hours == 2) { say_file("time/2s.wav"); } else { say_num(hours, SSM_PRONOUNCED); } say_file("time/hours.wav"); } if (minutes) { if (minutes == 2) { say_file("time/2s.wav"); } else { say_num(minutes, SSM_PRONOUNCED); } say_file("time/minute.wav"); } else { if (hours) { say_file("digits/0.wav"); say_file("time/minute.wav"); } } if (seconds) { if (seconds == 2) { say_file("time/2s.wav"); } else { say_num(hours, SSM_PRONOUNCED); } say_file("time/seconds.wav"); } else { if (hours || minutes) { say_file("digits/0.wav"); say_file("time/second.wav"); } } return SWITCH_STATUS_SUCCESS; } if ((t = atoi(tosay)) > 0) target = switch_time_make(t, 0); else target = switch_micro_time_now(); if (tz) { int check = atoi(tz); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Timezone is [%s]\n", tz); if (check) { switch_time_exp_tz(&tm, target, check); } else { switch_time_exp_tz_name(tz, &tm, target); } } else { switch_time_exp_lt(&tm, target); } switch (say_args->type) { case SST_CURRENT_DATE_TIME: say_date = say_time = 1; break; case SST_CURRENT_DATE: say_date = 1; break; case SST_CURRENT_TIME: say_time = 1; break; default: break; } if (say_date) { say_num(tm.tm_year + 1900, SSM_ITERATED); say_file("time/year.wav"); say_num(tm.tm_mon + 1, SSM_PRONOUNCED); say_file("time/month.wav"); say_num(tm.tm_mday, SSM_PRONOUNCED); say_file("time/day.wav"); say_file("time/day-%d.wav", tm.tm_wday); #if 0 tm = *localtime(&then); this_morning = switch_micro_time_now(); switch_time_exp_lt(&tm2, this_morning); tm2->tm_hour = 0; tm2->tm_min = 0; tm2->tm_sec = 0; this_morning = mktime(tm2); if (this_morning <= then && then < (this_morning + 86400L)) { say_file("time/today.wav"); } else if ((this_morning - 86400L) <= then && then < this_morning) { say_file("time/yesterday.wav"); } else if ((this_morning + 86400L) <= then && then < (this_morning + 2 * 86400L)) { say_file("time/tomorrow.wav"); } else if ((this_morning - 7 * 86400L) <= then && then < this_morning) { say_file("time/day-%d.wav", tm.tm_wday); } else { if (tm2->tm_year != tm.tm_year) { say_num(tm.tm_year + 1900, SSM_ITERATED); say_file("time/year.wav"); } /*endif */ if (tm2->tm_year != tm.tm_year || tm2->tm_mon != tm.tm_mon) { say_num(tm.tm_mon + 1, SSM_PRONOUNCED); say_file("time/month.wav"); } /*endif */ /* Always say the day and the day of the week */ say_num(tm.tm_mday, SSM_PRONOUNCED); say_file("time/day.wav"); say_file("time/day-%d.wav", tm.tm_wday); } #endif } if (say_time) { int32_t hour = tm.tm_hour; if (hour < 6) { say_file("time/morning.wav"); } else if (hour < 12) { say_file("time/am.wav"); } else if (tm.tm_hour < 18) { say_file("time/pm.wav"); } else { say_file("time/evening.wav"); } if (hour > 12) hour -= 12; if (hour == 0) hour = 12; if (hour == 2) { say_file("time/2s.wav"); } else { say_num(hour, SSM_PRONOUNCED); } say_file("time/hour.wav"); if (tm.tm_min == 2) { say_file("time/2s.wav"); } else { say_num(tm.tm_min, SSM_PRONOUNCED); } say_file("time/minute.wav"); } return SWITCH_STATUS_SUCCESS; }