Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
8ff6ec1b
D
Docs
项目概览
OpenHarmony
/
Docs
1 年多 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
8ff6ec1b
编写于
1月 16, 2023
作者:
O
openharmony_ci
提交者:
Gitee
1月 16, 2023
浏览文件
操作
浏览文件
下载
差异文件
!13555 资料需求回合
Merge pull request !13555 from wTong888/cherry-pick-1673572732
上级
75468e2c
424e39c5
变更
4
展开全部
显示空白变更内容
内联
并排
Showing
4 changed file
with
1252 addition
and
300 deletion
+1252
-300
zh-cn/application-dev/reference/apis/js-apis-system-date-time.md
...pplication-dev/reference/apis/js-apis-system-date-time.md
+665
-0
zh-cn/application-dev/reference/apis/js-apis-system-time.md
zh-cn/application-dev/reference/apis/js-apis-system-time.md
+415
-187
zh-cn/application-dev/reference/apis/js-apis-system-timer.md
zh-cn/application-dev/reference/apis/js-apis-system-timer.md
+148
-113
zh-cn/application-dev/reference/errorcodes/errorcode-time.md
zh-cn/application-dev/reference/errorcodes/errorcode-time.md
+24
-0
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-system-date-time.md
0 → 100644
浏览文件 @
8ff6ec1b
此差异已折叠。
点击以展开。
zh-cn/application-dev/reference/apis/js-apis-system-time.md
浏览文件 @
8ff6ec1b
此差异已折叠。
点击以展开。
zh-cn/application-dev/reference/apis/js-apis-system-timer.md
浏览文件 @
8ff6ec1b
...
@@ -21,7 +21,7 @@ import systemTimer from '@ohos.systemTimer';
...
@@ -21,7 +21,7 @@ import systemTimer from '@ohos.systemTimer';
**系统能力:**
SystemCapability.MiscServices.Time
**系统能力:**
SystemCapability.MiscServices.Time
| 名称 | 类型 | 值 | 说明 |
| 名称 | 类型 | 值 | 说明 |
| ------------------- | ------ | ---- | ---------------------------- |
| ------------------- | ------ | ---- | ----------------------------
--------------------------------
|
| TIMER_TYPE_REALTIME | number | 1 | 系统启动时间定时器。(定时器启动时间不能晚于当前设置的系统时间) |
| TIMER_TYPE_REALTIME | number | 1 | 系统启动时间定时器。(定时器启动时间不能晚于当前设置的系统时间) |
| TIMER_TYPE_WAKEUP | number | 2 | 唤醒定时器。 |
| TIMER_TYPE_WAKEUP | number | 2 | 唤醒定时器。 |
| TIMER_TYPE_EXACT | number | 4 | 精准定时器。 |
| TIMER_TYPE_EXACT | number | 4 | 精准定时器。 |
...
@@ -34,11 +34,11 @@ import systemTimer from '@ohos.systemTimer';
...
@@ -34,11 +34,11 @@ import systemTimer from '@ohos.systemTimer';
**系统能力:**
SystemCapability.MiscServices.Time
**系统能力:**
SystemCapability.MiscServices.Time
| 名称 | 类型 | 必填 | 说明 |
| 名称 | 类型 | 必填 | 说明 |
| --------- | --------------------------------- | ---- | ------------------------------------------------------------ |
| --------- | ---------------------------------
------------
| ---- | ------------------------------------------------------------ |
| type | number
| 是 | 定时器类型。
<br>
取值为1时,表示为系统启动时间定时器(定时器启动时间不能晚于当前设置的系统时间) ;
<br>
取值为2时,表示为唤醒定时器;
<br>
取值为4时,表示为精准定时器;
<br>
取值为5时
,表示为IDLE模式定时器(暂不支持)。 |
| type | number
| 是 | 定时器类型。
<br>
取值为1,表示为系统启动时间定时器(定时器启动时间不能晚于当前设置的系统时间) ;
<br>
取值为2,表示为唤醒定时器;
<br>
取值为4,表示为精准定时器;
<br>
取值为8
,表示为IDLE模式定时器(暂不支持)。 |
| repeat | boolean | 是 | true为循环定时器,false为单次定时器。 |
| repeat | boolean | 是 | true为循环定时器,false为单次定时器。 |
| interval | number | 否 | 如果是循环定时器,repeat值应大于5000毫秒,非重复定时器置为0。 |
| interval | number | 否 | 如果是循环定时器,repeat值应大于5000毫秒,非重复定时器置为0。 |
| wantAgent |
[
WantAgent
](
js-apis-wantAgent.md
)
| 否 | 设置通知的WantAgent,定时器到期后通知。(支持拉起应用MainAbility,暂不支持拉起ServiceAbility。) |
| wantAgent |
[
WantAgent
](
js-apis-
app-ability-
wantAgent.md
)
| 否 | 设置通知的WantAgent,定时器到期后通知。(支持拉起应用MainAbility,暂不支持拉起ServiceAbility。) |
| callback | number | 是 | 以回调函数的形式返回定时器的ID。 |
| callback | number | 是 | 以回调函数的形式返回定时器的ID。 |
...
@@ -66,13 +66,17 @@ export default {
...
@@ -66,13 +66,17 @@ export default {
type
:
systemTimer
.
TIMER_TYPE_REALTIME
,
type
:
systemTimer
.
TIMER_TYPE_REALTIME
,
repeat
:
false
repeat
:
false
};
};
systemTimer
.
createTimer
(
options
,
(
error
,
data
)
=>
{
try
{
systemTimer
.
createTimer
(
options
,
(
error
,
timerId
)
=>
{
if
(
error
)
{
if
(
error
)
{
console
.
error
(
`Failed to create timer. Cause:`
+
JSON
.
stringify
(
error
)
);
console
.
info
(
`Failed to create timer. message:
${
error
.
message
}
, code:
${
error
.
code
}
`
);
return
;
return
;
}
}
console
.
log
(
`Succeeded in creating timer. Data:`
+
JSON
.
stringify
(
data
)
);
console
.
info
(
`Succeeded in creating timer. timerId:
${
timerId
}
`
);
});
});
}
catch
(
e
)
{
console
.
info
(
`Failed to create timer. message:
${
e
.
message
}
, code:
${
e
.
code
}
`
);
}
}
}
}
}
```
```
...
@@ -106,11 +110,15 @@ export default {
...
@@ -106,11 +110,15 @@ export default {
type
:
systemTimer
.
TIMER_TYPE_REALTIME
,
type
:
systemTimer
.
TIMER_TYPE_REALTIME
,
repeat
:
false
repeat
:
false
};
};
systemTimer
.
createTimer
(
options
).
then
((
data
)
=>
{
try
{
console
.
log
(
`Succeeded in creating timer. Data:`
+
JSON
.
stringify
(
data
));
systemTimer
.
createTimer
(
options
).
then
((
timerId
)
=>
{
console
.
info
(
`Succeeded in creating timer. timerId:
${
timerId
}
`
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
)
=>
{
console
.
error
(
`Failed to create timer. Cause:`
+
JSON
.
stringify
(
error
)
);
console
.
info
(
`Failed to create timer. message:
${
error
.
message
}
, code:
${
error
.
code
}
`
);
});
});
}
catch
(
e
)
{
console
.
info
(
`Failed to create timer. message:
${
e
.
message
}
, code:
${
e
.
code
}
`
);
}
}
}
}
}
```
```
...
@@ -140,15 +148,20 @@ export default {
...
@@ -140,15 +148,20 @@ export default {
type
:
systemTimer
.
TIMER_TYPE_REALTIME
,
type
:
systemTimer
.
TIMER_TYPE_REALTIME
,
repeat
:
false
repeat
:
false
}
}
let
timerId
=
await
systemTimer
.
createTimer
(
options
)
let
timerId
=
await
systemTimer
.
createTimer
(
options
);
let
triggerTime
=
new
Date
().
getTime
()
let
triggerTime
=
new
Date
().
getTime
();
triggerTime
+=
3000
triggerTime
+=
3000
;
try
{
systemTimer
.
startTimer
(
timerId
,
triggerTime
,
(
error
)
=>
{
systemTimer
.
startTimer
(
timerId
,
triggerTime
,
(
error
)
=>
{
if
(
error
)
{
if
(
error
)
{
console
.
error
(
`Failed to start timer. Cause:`
+
JSON
.
stringify
(
error
)
);
console
.
info
(
`Failed to start timer. message:
${
error
.
message
}
, code:
${
error
.
code
}
`
);
return
;
return
;
}
}
console
.
info
(
`Succeeded in starting timer.`
);
});
});
}
catch
(
e
)
{
console
.
info
(
`Failed to start timer. message:
${
e
.
message
}
, code:
${
e
.
code
}
`
);
}
}
}
}
}
```
```
...
@@ -183,14 +196,18 @@ export default {
...
@@ -183,14 +196,18 @@ export default {
type
:
systemTimer
.
TIMER_TYPE_REALTIME
,
type
:
systemTimer
.
TIMER_TYPE_REALTIME
,
repeat
:
false
repeat
:
false
}
}
let
timerId
=
await
systemTimer
.
createTimer
(
options
)
let
timerId
=
await
systemTimer
.
createTimer
(
options
);
let
triggerTime
=
new
Date
().
getTime
()
let
triggerTime
=
new
Date
().
getTime
();
triggerTime
+=
3000
triggerTime
+=
3000
;
systemTimer
.
startTimer
(
timerId
,
triggerTime
).
then
((
data
)
=>
{
try
{
console
.
log
(
`Succeeded in startting timer. Data:`
+
JSON
.
stringify
(
data
));
systemTimer
.
startTimer
(
timerId
,
triggerTime
).
then
(()
=>
{
console
.
info
(
`Succeeded in starting timer.`
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
)
=>
{
console
.
error
(
`Failed to start timer. Cause:`
+
JSON
.
stringify
(
error
)
);
console
.
info
(
`Failed to start timer. message:
${
error
.
message
}
, code:
${
error
.
code
}
`
);
});
});
}
catch
(
e
)
{
console
.
info
(
`Failed to start timer. message:
${
e
.
message
}
, code:
${
e
.
code
}
`
);
}
}
}
}
}
```
```
...
@@ -219,16 +236,21 @@ export default {
...
@@ -219,16 +236,21 @@ export default {
type
:
systemTimer
.
TIMER_TYPE_REALTIME
,
type
:
systemTimer
.
TIMER_TYPE_REALTIME
,
repeat
:
false
repeat
:
false
}
}
let
timerId
=
await
systemTimer
.
createTimer
(
options
)
let
timerId
=
await
systemTimer
.
createTimer
(
options
);
let
triggerTime
=
new
Date
().
getTime
()
let
triggerTime
=
new
Date
().
getTime
();
triggerTime
+=
3000
triggerTime
+=
3000
;
systemTimer
.
startTimer
(
timerId
,
triggerTime
)
systemTimer
.
startTimer
(
timerId
,
triggerTime
);
try
{
systemTimer
.
stopTimer
(
timerId
,
(
error
)
=>
{
systemTimer
.
stopTimer
(
timerId
,
(
error
)
=>
{
if
(
error
)
{
if
(
error
)
{
console
.
error
(
`Failed to stop timer. Cause:`
+
JSON
.
stringify
(
error
)
);
console
.
info
(
`Failed to stop timer. message:
${
error
.
message
}
, code:
${
error
.
code
}
`
);
return
;
return
;
}
}
console
.
info
(
`Succeeded in stopping timer.`
);
});
});
}
catch
(
e
)
{
console
.
info
(
`Failed to stop timer. message:
${
e
.
message
}
, code:
${
e
.
code
}
`
);
}
}
}
}
}
```
```
...
@@ -262,15 +284,19 @@ export default {
...
@@ -262,15 +284,19 @@ export default {
type
:
systemTimer
.
TIMER_TYPE_REALTIME
,
type
:
systemTimer
.
TIMER_TYPE_REALTIME
,
repeat
:
false
repeat
:
false
}
}
let
timerId
=
await
systemTimer
.
createTimer
(
options
)
let
timerId
=
await
systemTimer
.
createTimer
(
options
);
let
triggerTime
=
new
Date
().
getTime
()
let
triggerTime
=
new
Date
().
getTime
();
triggerTime
+=
3000
triggerTime
+=
3000
;
systemTimer
.
startTimer
(
timerId
,
triggerTime
)
systemTimer
.
startTimer
(
timerId
,
triggerTime
);
systemTimer
.
stopTimer
(
timerId
).
then
((
data
)
=>
{
try
{
console
.
log
(
`Succeeded in stopping timer. Data:`
+
JSON
.
stringify
(
data
));
systemTimer
.
stopTimer
(
timerId
).
then
(()
=>
{
console
.
info
(
`Succeeded in stopping timer.`
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
)
=>
{
console
.
error
(
`Failed to stop timer. Cause:`
+
JSON
.
stringify
(
error
)
);
console
.
info
(
`Failed to stop timer. message:
${
error
.
message
}
, code:
${
error
.
code
}
`
);
});
});
}
catch
(
e
)
{
console
.
info
(
`Failed to stop timer. message:
${
e
.
message
}
, code:
${
e
.
code
}
`
);
}
}
}
}
}
```
```
...
@@ -299,17 +325,22 @@ export default {
...
@@ -299,17 +325,22 @@ export default {
type
:
systemTimer
.
TIMER_TYPE_REALTIME
,
type
:
systemTimer
.
TIMER_TYPE_REALTIME
,
repeat
:
false
repeat
:
false
}
}
let
timerId
=
await
systemTimer
.
createTimer
(
options
)
let
timerId
=
await
systemTimer
.
createTimer
(
options
);
let
triggerTime
=
new
Date
().
getTime
()
let
triggerTime
=
new
Date
().
getTime
();
triggerTime
+=
3000
triggerTime
+=
3000
;
systemTimer
.
startTimer
(
timerId
,
triggerTime
)
systemTimer
.
startTimer
(
timerId
,
triggerTime
);
systemTimer
.
stopTimer
(
timerId
)
systemTimer
.
stopTimer
(
timerId
);
try
{
systemTimer
.
destroyTimer
(
timerId
,
(
error
)
=>
{
systemTimer
.
destroyTimer
(
timerId
,
(
error
)
=>
{
if
(
error
)
{
if
(
error
)
{
console
.
error
(
`Failed to destroy timer. Cause:`
+
JSON
.
stringify
(
error
)
);
console
.
info
(
`Failed to destroy timer. message:
${
error
.
message
}
, code:
${
error
.
code
}
`
);
return
;
return
;
}
}
console
.
info
(
`Succeeded in destroying timer.`
);
});
});
}
catch
(
e
)
{
console
.
info
(
`Failed to destroying timer. message:
${
e
.
message
}
, code:
${
e
.
code
}
`
);
}
}
}
}
}
```
```
...
@@ -343,16 +374,20 @@ export default {
...
@@ -343,16 +374,20 @@ export default {
type
:
systemTimer
.
TIMER_TYPE_REALTIME
,
type
:
systemTimer
.
TIMER_TYPE_REALTIME
,
repeat
:
false
repeat
:
false
}
}
let
timerId
=
await
systemTimer
.
createTimer
(
options
)
let
timerId
=
await
systemTimer
.
createTimer
(
options
);
let
triggerTime
=
new
Date
().
getTime
()
let
triggerTime
=
new
Date
().
getTime
();
triggerTime
+=
3000
triggerTime
+=
3000
;
systemTimer
.
startTimer
(
timerId
,
triggerTime
)
systemTimer
.
startTimer
(
timerId
,
triggerTime
);
systemTimer
.
stopTimer
(
timerId
)
systemTimer
.
stopTimer
(
timerId
);
systemTimer
.
destroyTimer
(
timerId
).
then
((
data
)
=>
{
try
{
console
.
log
(
`Succeeded in destroying timer. Data:`
+
JSON
.
stringify
(
data
));
systemTimer
.
destroyTimer
(
timerId
).
then
(()
=>
{
console
.
info
(
`Succeeded in destroying timer.`
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
)
=>
{
console
.
error
(
`Failed to destroy timer. Cause:`
+
JSON
.
stringify
(
error
)
);
console
.
info
(
`Failed to destroy timer. message:
${
error
.
message
}
, code:
${
error
.
code
}
`
);
});
});
}
catch
(
e
)
{
console
.
info
(
`Failed to destroying timer. message:
${
e
.
message
}
, code:
${
e
.
code
}
`
);
}
}
}
}
}
```
```
\ No newline at end of file
zh-cn/application-dev/reference/errorcodes/errorcode-time.md
0 → 100644
浏览文件 @
8ff6ec1b
# 时间时区服务错误码
## -1 锁屏服务异常
**错误信息**
The parameter check failed or permission denied or system error.
**错误描述**
参数校验失败、权限校验失败或者时间时区服务异常。
**可能原因**
该错误码代表一种通用错误码,可根据错误信息判断具体异常,可能原因如下:
1.
参数校验失败,传入参数无效。
2.
权限校验失败,权限未配置。应用设置时间未配置ohos.permission.SET_TIME或者设置时区未配置ohos.permission.SET_TIME_ZONE。
3.
系统运行异常。内存申请、多线程处理等内核通用错误。
**处理步骤**
1.
参数校验失败,传入参数无效。检查参数是否按照要求传入。
2.
权限校验失败,应用设置时间配置ohos.permission.SET_TIME或者设置时区配置ohos.permission.SET_TIME_ZONE。
3.
系统运行异常。确认内存是否足够。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录