Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
97438725
提交
97438725
authored
2月 03, 2017
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-10008: [mod_say_en] Add military time to say_en #resolve
上级
202dda4e
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
93 行增加
和
27 行删除
+93
-27
mod_say_en.c
src/mod/say/mod_say_en/mod_say_en.c
+61
-19
switch_utils.c
src/switch_utils.c
+32
-8
没有找到文件。
src/mod/say/mod_say_en/mod_say_en.c
浏览文件 @
97438725
...
@@ -184,7 +184,7 @@ static switch_status_t en_say_general_count(switch_say_file_handle_t *sh, char *
...
@@ -184,7 +184,7 @@ static switch_status_t en_say_general_count(switch_say_file_handle_t *sh, char *
static
switch_status_t
en_say_time
(
switch_say_file_handle_t
*
sh
,
char
*
tosay
,
switch_say_args_t
*
say_args
)
static
switch_status_t
en_say_time
(
switch_say_file_handle_t
*
sh
,
char
*
tosay
,
switch_say_args_t
*
say_args
)
{
{
int32_t
t
;
int32_t
t
=
0
;
switch_time_t
target
=
0
,
target_now
=
0
;
switch_time_t
target
=
0
,
target_now
=
0
;
switch_time_exp_t
tm
,
tm_now
;
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
;
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
;
...
@@ -192,6 +192,7 @@ static switch_status_t en_say_time(switch_say_file_handle_t *sh, char *tosay, sw
...
@@ -192,6 +192,7 @@ static switch_status_t en_say_time(switch_say_file_handle_t *sh, char *tosay, sw
tz
=
switch_say_file_handle_get_variable
(
sh
,
"timezone"
);
tz
=
switch_say_file_handle_get_variable
(
sh
,
"timezone"
);
if
(
say_args
->
type
==
SST_TIME_MEASUREMENT
)
{
if
(
say_args
->
type
==
SST_TIME_MEASUREMENT
)
{
int64_t
hours
=
0
;
int64_t
hours
=
0
;
int64_t
minutes
=
0
;
int64_t
minutes
=
0
;
...
@@ -215,6 +216,7 @@ static switch_status_t en_say_time(switch_say_file_handle_t *sh, char *tosay, sw
...
@@ -215,6 +216,7 @@ static switch_status_t en_say_time(switch_say_file_handle_t *sh, char *tosay, sw
}
}
free
(
tme
);
free
(
tme
);
}
else
{
}
else
{
if
((
seconds
=
atol
(
tosay
))
<=
0
)
{
if
((
seconds
=
atol
(
tosay
))
<=
0
)
{
seconds
=
(
int64_t
)
switch_epoch_time_now
(
NULL
);
seconds
=
(
int64_t
)
switch_epoch_time_now
(
NULL
);
}
}
...
@@ -271,12 +273,22 @@ static switch_status_t en_say_time(switch_say_file_handle_t *sh, char *tosay, sw
...
@@ -271,12 +273,22 @@ static switch_status_t en_say_time(switch_say_file_handle_t *sh, char *tosay, sw
return
SWITCH_STATUS_SUCCESS
;
return
SWITCH_STATUS_SUCCESS
;
}
}
if
((
t
=
atol
(
tosay
))
>
0
)
{
if
(
strchr
(
tosay
,
':'
))
{
switch_time_t
tme
=
switch_str_time
(
tosay
);
t
=
(
int32_t
)
((
tme
)
/
(
int64_t
)
(
1000000
));
target
=
switch_time_make
(
t
,
0
);
target
=
switch_time_make
(
t
,
0
);
target_now
=
switch_micro_time_now
();
target_now
=
switch_micro_time_now
();
}
else
{
}
target
=
switch_micro_time_now
();
target_now
=
switch_micro_time_now
();
if
(
!
t
)
{
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
)
{
if
(
tz
)
{
...
@@ -369,34 +381,64 @@ static switch_status_t en_say_time(switch_say_file_handle_t *sh, char *tosay, sw
...
@@ -369,34 +381,64 @@ static switch_status_t en_say_time(switch_say_file_handle_t *sh, char *tosay, sw
}
}
if
(
say_time
)
{
if
(
say_time
)
{
int32_t
hour
=
tm
.
tm_hour
,
pm
=
0
;
int32_t
hour
=
tm
.
tm_hour
,
pm
=
0
,
mil
=
0
;
if
(
say_args
->
method
==
SSM_ITERATED
)
{
mil
=
1
;
}
if
(
say_date
||
say_today
||
say_yesterday
||
say_dow
)
{
if
(
say_date
||
say_today
||
say_yesterday
||
say_dow
)
{
switch_say_file
(
sh
,
"time/at"
);
switch_say_file
(
sh
,
"time/at"
);
}
}
if
(
hour
>
12
)
{
if
(
hour
>
12
)
{
hour
-=
12
;
mil
++
;
pm
=
1
;
}
else
if
(
hour
==
12
)
{
}
else
if
(
hour
==
12
)
{
pm
=
1
;
pm
=
1
;
}
else
if
(
hour
==
0
)
{
}
else
if
(
hour
==
0
)
{
hour
=
12
;
if
(
mil
)
{
pm
=
0
;
if
(
tm
.
tm_min
==
0
)
{
hour
=
24
;
}
}
else
{
hour
=
12
;
pm
=
0
;
}
}
}
say_num
(
sh
,
hour
,
SSM_PRONOUNCED
);
if
(
mil
)
{
if
(
hour
<
10
)
{
say_num
(
sh
,
0
,
SSM_PRONOUNCED
);
}
say_num
(
sh
,
hour
,
SSM_PRONOUNCED
);
if
(
tm
.
tm_min
>
9
)
{
say_num
(
sh
,
tm
.
tm_min
,
SSM_PRONOUNCED
);
}
else
if
(
tm
.
tm_min
)
{
say_num
(
sh
,
0
,
SSM_PRONOUNCED
);
say_num
(
sh
,
tm
.
tm_min
,
SSM_PRONOUNCED
);
}
else
{
switch_say_file
(
sh
,
"digits/hundred"
);
}
switch_say_file
(
sh
,
"time/hours"
);
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
{
}
else
{
switch_say_file
(
sh
,
"time/oclock"
);
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"
);
switch_say_file
(
sh
,
"time/%s"
,
pm
?
"p-m"
:
"a-m"
);
}
}
}
return
SWITCH_STATUS_SUCCESS
;
return
SWITCH_STATUS_SUCCESS
;
...
...
src/switch_utils.c
浏览文件 @
97438725
...
@@ -1890,22 +1890,46 @@ SWITCH_DECLARE(switch_status_t) switch_find_interface_ip(char *buf, int len, int
...
@@ -1890,22 +1890,46 @@ SWITCH_DECLARE(switch_status_t) switch_find_interface_ip(char *buf, int len, int
SWITCH_DECLARE
(
switch_time_t
)
switch_str_time
(
const
char
*
in
)
SWITCH_DECLARE
(
switch_time_t
)
switch_str_time
(
const
char
*
in
)
{
{
switch_time_exp_t
tm
=
{
0
},
local_tm
=
{
0
};
switch_time_exp_t
tm
=
{
0
},
local_tm
=
{
0
};
int
proceed
=
0
,
ovector
[
30
];
int
proceed
=
0
,
ovector
[
30
]
,
time_only
=
0
;
switch_regex_t
*
re
=
NULL
;
switch_regex_t
*
re
=
NULL
;
char
replace
[
1024
]
=
""
;
char
replace
[
1024
]
=
""
;
switch_time_t
ret
=
0
,
local_time
=
0
;
switch_time_t
ret
=
0
,
local_time
=
0
;
char
*
pattern
=
"^(
\\
d+)-(
\\
d+)-(
\\
d+)
\\
s*(
\\
d*):{0,1}(
\\
d*):{0,1}(
\\
d*)"
;
char
*
pattern
=
"^(
\\
d+)-(
\\
d+)-(
\\
d+)
\\
s*(
\\
d*):{0,1}(
\\
d*):{0,1}(
\\
d*)"
;
char
*
pattern2
=
"^(
\\
d{4})(
\\
d{2})(
\\
d{2})(
\\
d{2})(
\\
d{2})(
\\
d{2})"
;
char
*
pattern2
=
"^(
\\
d{4})(
\\
d{2})(
\\
d{2})(
\\
d{2})(
\\
d{2})(
\\
d{2})"
;
char
*
pattern3
=
"^(
\\
d*):{0,1}(
\\
d*):{0,1}(
\\
d*)$"
;
switch_time_exp_lt
(
&
tm
,
switch_micro_time_now
());
switch_time_exp_lt
(
&
tm
,
switch_micro_time_now
());
tm
.
tm_year
=
tm
.
tm_mon
=
tm
.
tm_mday
=
tm
.
tm_hour
=
tm
.
tm_min
=
tm
.
tm_sec
=
tm
.
tm_usec
=
0
;
if
(
!
(
proceed
=
switch_regex_perform
(
in
,
pattern
,
&
re
,
ovector
,
sizeof
(
ovector
)
/
sizeof
(
ovector
[
0
]))))
{
switch_regex_safe_free
(
re
);
if
((
time_only
=
switch_regex_perform
(
in
,
pattern3
,
&
re
,
ovector
,
sizeof
(
ovector
)
/
sizeof
(
ovector
[
0
]))))
{
proceed
=
switch_regex_perform
(
in
,
pattern2
,
&
re
,
ovector
,
sizeof
(
ovector
)
/
sizeof
(
ovector
[
0
]));
tm
.
tm_hour
=
0
;
tm
.
tm_min
=
0
;
tm
.
tm_sec
=
0
;
}
else
{
tm
.
tm_year
=
tm
.
tm_mon
=
tm
.
tm_mday
=
tm
.
tm_hour
=
tm
.
tm_min
=
tm
.
tm_sec
=
tm
.
tm_usec
=
0
;
if
(
!
(
proceed
=
switch_regex_perform
(
in
,
pattern
,
&
re
,
ovector
,
sizeof
(
ovector
)
/
sizeof
(
ovector
[
0
]))))
{
switch_regex_safe_free
(
re
);
proceed
=
switch_regex_perform
(
in
,
pattern2
,
&
re
,
ovector
,
sizeof
(
ovector
)
/
sizeof
(
ovector
[
0
]));
}
}
}
if
(
proceed
)
{
if
(
proceed
||
time_only
)
{
if
(
time_only
>
1
)
{
switch_regex_copy_substring
(
in
,
ovector
,
time_only
,
1
,
replace
,
sizeof
(
replace
));
tm
.
tm_hour
=
atoi
(
replace
);
}
if
(
time_only
>
2
)
{
switch_regex_copy_substring
(
in
,
ovector
,
time_only
,
2
,
replace
,
sizeof
(
replace
));
tm
.
tm_min
=
atoi
(
replace
);
}
if
(
time_only
>
3
)
{
switch_regex_copy_substring
(
in
,
ovector
,
time_only
,
3
,
replace
,
sizeof
(
replace
));
tm
.
tm_sec
=
atoi
(
replace
);
}
if
(
proceed
>
1
)
{
if
(
proceed
>
1
)
{
switch_regex_copy_substring
(
in
,
ovector
,
proceed
,
1
,
replace
,
sizeof
(
replace
));
switch_regex_copy_substring
(
in
,
ovector
,
proceed
,
1
,
replace
,
sizeof
(
replace
));
...
@@ -1936,7 +1960,7 @@ SWITCH_DECLARE(switch_time_t) switch_str_time(const char *in)
...
@@ -1936,7 +1960,7 @@ SWITCH_DECLARE(switch_time_t) switch_str_time(const char *in)
switch_regex_copy_substring
(
in
,
ovector
,
proceed
,
6
,
replace
,
sizeof
(
replace
));
switch_regex_copy_substring
(
in
,
ovector
,
proceed
,
6
,
replace
,
sizeof
(
replace
));
tm
.
tm_sec
=
atoi
(
replace
);
tm
.
tm_sec
=
atoi
(
replace
);
}
}
switch_regex_safe_free
(
re
);
switch_regex_safe_free
(
re
);
switch_time_exp_get
(
&
local_time
,
&
tm
);
switch_time_exp_get
(
&
local_time
,
&
tm
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论