mod_say_en: add short form date/time (MODAPP-180)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12072 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
411797aeb3
commit
b0fa96a32d
|
@ -281,7 +281,8 @@ typedef enum {
|
||||||
SST_POSTAL_ADDRESS,
|
SST_POSTAL_ADDRESS,
|
||||||
SST_ACCOUNT_NUMBER,
|
SST_ACCOUNT_NUMBER,
|
||||||
SST_NAME_SPELLED,
|
SST_NAME_SPELLED,
|
||||||
SST_NAME_PHONETIC
|
SST_NAME_PHONETIC,
|
||||||
|
SST_SHORT_DATE_TIME
|
||||||
} switch_say_type_t;
|
} switch_say_type_t;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|
|
@ -263,9 +263,9 @@ static switch_status_t en_say_time(switch_core_session_t *session, char *tosay,
|
||||||
switch_input_args_t *args)
|
switch_input_args_t *args)
|
||||||
{
|
{
|
||||||
int32_t t;
|
int32_t t;
|
||||||
switch_time_t target = 0;
|
switch_time_t target = 0, target_now = 0;
|
||||||
switch_time_exp_t tm;
|
switch_time_exp_t tm, tm_now;
|
||||||
uint8_t say_date = 0, say_time = 0;
|
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);
|
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||||
const char *tz = switch_channel_get_variable(channel, "timezone");
|
const char *tz = switch_channel_get_variable(channel, "timezone");
|
||||||
|
|
||||||
|
@ -351,19 +351,24 @@ static switch_status_t en_say_time(switch_core_session_t *session, char *tosay,
|
||||||
|
|
||||||
if ((t = atol(tosay)) > 0) {
|
if ((t = atol(tosay)) > 0) {
|
||||||
target = switch_time_make(t, 0);
|
target = switch_time_make(t, 0);
|
||||||
|
target_now = switch_micro_time_now();
|
||||||
} else {
|
} else {
|
||||||
target = switch_micro_time_now();
|
target = switch_micro_time_now();
|
||||||
|
target_now = switch_micro_time_now();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tz) {
|
if (tz) {
|
||||||
int check = atoi(tz);
|
int check = atoi(tz);
|
||||||
if (check) {
|
if (check) {
|
||||||
switch_time_exp_tz(&tm, target, check);
|
switch_time_exp_tz(&tm, target, check);
|
||||||
|
switch_time_exp_tz(&tm_now, target_now, check);
|
||||||
} else {
|
} else {
|
||||||
switch_time_exp_tz_name(tz, &tm, target);
|
switch_time_exp_tz_name(tz, &tm, target);
|
||||||
|
switch_time_exp_tz_name(tz, &tm_now, target_now);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch_time_exp_lt(&tm, target);
|
switch_time_exp_lt(&tm, target);
|
||||||
|
switch_time_exp_lt(&tm_now, target_now);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
@ -375,15 +380,59 @@ static switch_status_t en_say_time(switch_core_session_t *session, char *tosay,
|
||||||
break;
|
break;
|
||||||
case SST_CURRENT_TIME:
|
case SST_CURRENT_TIME:
|
||||||
say_time = 1;
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
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);
|
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);
|
say_file("time/mon-%d.wav", tm.tm_mon);
|
||||||
|
}
|
||||||
|
if (say_day) {
|
||||||
say_num(tm.tm_mday, SSM_COUNTED);
|
say_num(tm.tm_mday, SSM_COUNTED);
|
||||||
|
}
|
||||||
|
if (say_year) {
|
||||||
say_num(tm.tm_year + 1900, SSM_PRONOUNCED);
|
say_num(tm.tm_year + 1900, SSM_PRONOUNCED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -495,6 +544,7 @@ static switch_status_t en_say(switch_core_session_t *session, char *tosay, switc
|
||||||
case SST_CURRENT_DATE:
|
case SST_CURRENT_DATE:
|
||||||
case SST_CURRENT_TIME:
|
case SST_CURRENT_TIME:
|
||||||
case SST_CURRENT_DATE_TIME:
|
case SST_CURRENT_DATE_TIME:
|
||||||
|
case SST_SHORT_DATE_TIME:
|
||||||
say_cb = en_say_time;
|
say_cb = en_say_time;
|
||||||
break;
|
break;
|
||||||
case SST_IP_ADDRESS:
|
case SST_IP_ADDRESS:
|
||||||
|
|
|
@ -62,6 +62,7 @@ static char *SAY_TYPE_NAMES[] = {
|
||||||
"ACCOUNT_NUMBER",
|
"ACCOUNT_NUMBER",
|
||||||
"NAME_SPELLED",
|
"NAME_SPELLED",
|
||||||
"NAME_PHONETIC",
|
"NAME_PHONETIC",
|
||||||
|
"SHORT_DATE_TIME",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue