[Freeswitch-svn] [commit] r12072 - in freeswitch/trunk/src: . include mod/say/mod_say_en

FreeSWITCH SVN mikej at freeswitch.org
Mon Feb 16 14:24:26 PST 2009


Author: mikej
Date: Mon Feb 16 16:24:25 2009
New Revision: 12072

Log:
mod_say_en: add short form date/time (MODAPP-180)

Modified:
   freeswitch/trunk/src/include/switch_types.h
   freeswitch/trunk/src/mod/say/mod_say_en/mod_say_en.c
   freeswitch/trunk/src/switch_ivr_play_say.c

Modified: freeswitch/trunk/src/include/switch_types.h
==============================================================================
--- freeswitch/trunk/src/include/switch_types.h	(original)
+++ freeswitch/trunk/src/include/switch_types.h	Mon Feb 16 16:24:25 2009
@@ -281,7 +281,8 @@
 	SST_POSTAL_ADDRESS,
 	SST_ACCOUNT_NUMBER,
 	SST_NAME_SPELLED,
-	SST_NAME_PHONETIC
+	SST_NAME_PHONETIC,
+	SST_SHORT_DATE_TIME
 } switch_say_type_t;
 
 typedef enum {

Modified: freeswitch/trunk/src/mod/say/mod_say_en/mod_say_en.c
==============================================================================
--- freeswitch/trunk/src/mod/say/mod_say_en/mod_say_en.c	(original)
+++ freeswitch/trunk/src/mod/say/mod_say_en/mod_say_en.c	Mon Feb 16 16:24:25 2009
@@ -263,9 +263,9 @@
 								   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");
 	
@@ -351,19 +351,24 @@
 
 	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 (type) {
@@ -376,14 +381,58 @@
 	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_date) {
+	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_month) {
 		say_file("time/mon-%d.wav", tm.tm_mon);
+	}
+	if (say_day) {
 		say_num(tm.tm_mday, SSM_COUNTED);
+	}
+	if (say_year) {
 		say_num(tm.tm_year + 1900, SSM_PRONOUNCED);
 	}
 
@@ -495,6 +544,7 @@
 	case SST_CURRENT_DATE:
 	case SST_CURRENT_TIME:
 	case SST_CURRENT_DATE_TIME:
+	case SST_SHORT_DATE_TIME:
 		say_cb = en_say_time;
 		break;
 	case SST_IP_ADDRESS:

Modified: freeswitch/trunk/src/switch_ivr_play_say.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_play_say.c	(original)
+++ freeswitch/trunk/src/switch_ivr_play_say.c	Mon Feb 16 16:24:25 2009
@@ -62,6 +62,7 @@
 	"ACCOUNT_NUMBER",
 	"NAME_SPELLED",
 	"NAME_PHONETIC",
+	"SHORT_DATE_TIME",
 	NULL
 };
 



More information about the Freeswitch-svn mailing list