From ae124bfb4f3285bae92a0bb8a141d49f7e13ad2f Mon Sep 17 00:00:00 2001 From: Steve Underwood Date: Sun, 26 Oct 2008 04:20:33 +0000 Subject: [PATCH] Added smarter date reading, but its currently disabled. A freeswitch style equivalent of mktime() is needed to make this a proper piece of Freeswitch code. git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@10155 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/mod/say/mod_say_zh/mod_say_zh.c | 123 ++++++++++++++++++++-------- 1 file changed, 88 insertions(+), 35 deletions(-) diff --git a/src/mod/say/mod_say_zh/mod_say_zh.c b/src/mod/say/mod_say_zh/mod_say_zh.c index 29a16b5e55..49647508d2 100644 --- a/src/mod/say/mod_say_zh/mod_say_zh.c +++ b/src/mod/say/mod_say_zh/mod_say_zh.c @@ -290,41 +290,41 @@ static switch_status_t zh_say_general_count(switch_core_session_t *session, } -static switch_status_t zh_ip(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args) -{ - char *a, *b, *c, *d; - if (!(a = switch_core_session_strdup(session, tosay))) { - return SWITCH_STATUS_FALSE; - } - - if (!(b = strchr(a, '.'))) { - return SWITCH_STATUS_FALSE; - } - - *b++ = '\0'; - - if (!(c = strchr(b, '.'))) { - return SWITCH_STATUS_FALSE; - } - - *c++ = '\0'; - - if (!(d = strchr(c, '.'))) { - return SWITCH_STATUS_FALSE; - } - - *d++ = '\0'; - - say_num(atoi(a), method); - say_file("digits/dot.wav"); - say_num(atoi(b), method); - say_file("digits/dot.wav"); - say_num(atoi(c), method); - say_file("digits/dot.wav"); - say_num(atoi(d), method); - - return SWITCH_STATUS_SUCCESS; -} +static switch_status_t zh_ip(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args) +{ + char *a, *b, *c, *d; + if (!(a = switch_core_session_strdup(session, tosay))) { + return SWITCH_STATUS_FALSE; + } + + if (!(b = strchr(a, '.'))) { + return SWITCH_STATUS_FALSE; + } + + *b++ = '\0'; + + if (!(c = strchr(b, '.'))) { + return SWITCH_STATUS_FALSE; + } + + *c++ = '\0'; + + if (!(d = strchr(c, '.'))) { + return SWITCH_STATUS_FALSE; + } + + *d++ = '\0'; + + say_num(atoi(a), method); + say_file("digits/dot.wav"); + say_num(atoi(b), method); + say_file("digits/dot.wav"); + say_num(atoi(c), method); + say_file("digits/dot.wav"); + say_num(atoi(d), method); + + return SWITCH_STATUS_SUCCESS; +} static switch_status_t zh_say_time(switch_core_session_t *session, char *tosay, @@ -335,6 +335,10 @@ static switch_status_t zh_say_time(switch_core_session_t *session, int32_t t; switch_time_t target = 0; switch_time_exp_t tm; +#if 0 + switch_time_t this_morning; + switch_time_exp_t tm2; +#endif uint8_t say_date = 0; uint8_t say_time = 0; @@ -447,6 +451,55 @@ static switch_status_t zh_say_time(switch_core_session_t *session, 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_timestamp_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) {