]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Added smarter date reading, but its currently disabled. A freeswitch
authorSteve Underwood <steveu@coppice.org>
Sun, 26 Oct 2008 04:20:33 +0000 (04:20 +0000)
committerSteve Underwood <steveu@coppice.org>
Sun, 26 Oct 2008 04:20:33 +0000 (04:20 +0000)
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

index 29a16b5e55fa3a2c08eb130bdd7a4dad23914349..49647508d2f61dc6c4aa82ac701f72ab8bb3d23f 100644 (file)
@@ -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)\r
-{\r
-       char *a, *b, *c, *d;\r
-       if (!(a = switch_core_session_strdup(session, tosay))) {\r
-               return SWITCH_STATUS_FALSE;\r
-       }\r
-\r
-       if (!(b = strchr(a, '.'))) {\r
-               return SWITCH_STATUS_FALSE;\r
-       }\r
-\r
-       *b++ = '\0';\r
-\r
-       if (!(c = strchr(b, '.'))) {\r
-               return SWITCH_STATUS_FALSE;\r
-       }\r
-\r
-       *c++ = '\0';\r
-\r
-       if (!(d = strchr(c, '.'))) {\r
-               return SWITCH_STATUS_FALSE;\r
-       }\r
-\r
-       *d++ = '\0';\r
-\r
-       say_num(atoi(a), method);\r
-       say_file("digits/dot.wav");\r
-       say_num(atoi(b), method);\r
-       say_file("digits/dot.wav");\r
-       say_num(atoi(c), method);\r
-       say_file("digits/dot.wav");\r
-       say_num(atoi(d), method);\r
-\r
-       return SWITCH_STATUS_SUCCESS;\r
-}\r
+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) {