提交 e42aeb9b 编写于 作者: E ester.zhou

Update doc (11419)

Signed-off-by: Nester.zhou <ester.zhou@huawei.com>
上级 fa2d85ae
...@@ -4,16 +4,14 @@ The **systemTime** module provides system time and time zone features. You can u ...@@ -4,16 +4,14 @@ The **systemTime** module provides system time and time zone features. You can u
> **NOTE** > **NOTE**
> >
> - The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import ## Modules to Import
```js
```
import systemTime from '@ohos.systemTime'; import systemTime from '@ohos.systemTime';
``` ```
## systemTime.setTime ## systemTime.setTime
setTime(time : number, callback : AsyncCallback&lt;void&gt;) : void setTime(time : number, callback : AsyncCallback&lt;void&gt;) : void
...@@ -27,24 +25,23 @@ Sets the system time. This API uses an asynchronous callback to return the resul ...@@ -27,24 +25,23 @@ Sets the system time. This API uses an asynchronous callback to return the resul
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ------------------------------------------ | | -------- | ----------- | ---- | ---------------- |
| time | number | Yes | Timestamp to set, in milliseconds. | | time | number | Yes | Timestamp to set, in milliseconds. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Example** **Example**
```js ```js
// Set the system time to 2021-01-20 02:36:25. // Set the system time to 2021-01-20 02:36:25.
var time = 1611081385000; let time = 1611081385000;
systemTime.setTime(time, (error, data) => { systemTime.setTime(time, (error, data) => {
if (error) { if (error) {
console.error(`failed to systemTime.setTime because ` + JSON.stringify(error)); console.error(`Failed to set systemTime. Cause:` + JSON.stringify(error));
return; return;
} }
console.log(`systemTime.setTime success data : ` + JSON.stringify(data)); console.log(`Succeeded in setting systemTime. Data:` + JSON.stringify(data));
}); });
``` ```
## systemTime.setTime ## systemTime.setTime
...@@ -65,21 +62,20 @@ Sets the system time. This API uses a promise to return the result. ...@@ -65,21 +62,20 @@ Sets the system time. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | -------------------- | | ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
```js ```js
// Set the system time to 2021-01-20 02:36:25. // Set the system time to 2021-01-20 02:36:25.
var time = 1611081385000; let time = 1611081385000;
systemTime.setTime(time).then((data) => { systemTime.setTime(time).then((data) => {
console.log(`systemTime.setTime success data : ` + JSON.stringify(data)); console.log(`Succeeded in setting systemTime. Data:` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
console.error(`failed to systemTime.setTime because ` + JSON.stringify(error)); console.error(`Failed to set systemTime. Cause:` + JSON.stringify(error));
}); });
``` ```
## systemTime.getCurrentTime<sup>8+</sup> ## systemTime.getCurrentTime<sup>8+</sup>
...@@ -92,22 +88,21 @@ Obtains the time elapsed since the Unix epoch. This API uses an asynchronous cal ...@@ -92,22 +88,21 @@ Obtains the time elapsed since the Unix epoch. This API uses an asynchronous cal
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | ------------------------------------------------------------ | | -------- | -------------- | ---- | ------------------ |
| isNano | boolean | Yes | Whether the time to return is in nanoseconds.<br>- **true**: in nanoseconds.<br>- **false**: in milliseconds. | | isNano | boolean | Yes | Whether the time to return is in nanoseconds.<br>- **true**: in nanoseconds (ns).<br>- **false**: in milliseconds (ms).|
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the time. | | callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the time elapsed since the Unix epoch. |
**Example** **Example**
```js ```js
systemTime.getCurrentTime(true, (error, data) => { systemTime.getCurrentTime(true, (error, data) => {
if (error) { if (error) {
console.error(`failed to systemTime.getCurrentTime because ` + JSON.stringify(error)); console.error(`Failed to get systemTime. Cause:` + JSON.stringify(error));
return; return;
} }
console.log(`systemTime.getCurrentTime success data : ` + JSON.stringify(data)); console.log(`Succeeded in getting systemTime. Data:` + JSON.stringify(data));
}); });
``` ```
## systemTime.getCurrentTime<sup>8+</sup> ## systemTime.getCurrentTime<sup>8+</sup>
...@@ -120,21 +115,20 @@ Obtains the time elapsed since the Unix epoch. This API uses an asynchronous cal ...@@ -120,21 +115,20 @@ Obtains the time elapsed since the Unix epoch. This API uses an asynchronous cal
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | ------------------------------------------------------------ | | -------- | ----------- | ---- | ---------------------------------- |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the time. | | callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the time elapsed since the Unix epoch. |
**Example** **Example**
```js ```js
systemTime.getCurrentTime((error, data) => { systemTime.getCurrentTime((error, data) => {
if (error) { if (error) {
console.error(`failed to systemTime.getCurrentTime because ` + JSON.stringify(error)); console.error(`Succeeded in getting systemTime. Data:` + JSON.stringify(error));
return; return;
} }
console.log(`systemTime.getCurrentTime success data : ` + JSON.stringify(data)); console.log(`Failed to get systemTime. Cause:` + JSON.stringify(data));
}); });
``` ```
## systemTime.getCurrentTime<sup>8+</sup> ## systemTime.getCurrentTime<sup>8+</sup>
...@@ -147,196 +141,190 @@ Obtains the time elapsed since the Unix epoch. This API uses a promise to return ...@@ -147,196 +141,190 @@ Obtains the time elapsed since the Unix epoch. This API uses a promise to return
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------- | ---- | ------------------------------------------------------------ | | ------ | ------- | ---- | ------------------------- |
| isNano | boolean | No | Whether the time to return is in nanoseconds.<br/>- **true**: in nanoseconds.<br>- **false**: in milliseconds. | | isNano | boolean | No | Whether the time to return is in nanoseconds.<br>- **true**: in nanoseconds (ns).<br>- **false**: in milliseconds (ms).|
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ------------------------------------------------------------ | | --------------------- | --------------------------- |
| Promise&lt;number&gt; | Promise used to return the time.| | Promise&lt;number&gt; | Promise used to return the time elapsed since the Unix epoch.|
**Example** **Example**
```js ```js
systemTime.getCurrentTime().then((data) => { systemTime.getCurrentTime().then((data) => {
console.log(`systemTime.getCurrentTime success data : ` + JSON.stringify(data)); console.log(`Succeeded in getting systemTime. Data:` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
console.error(`failed to systemTime.getCurrentTime because ` + JSON.stringify(error)); console.error(`Failed to get systemTime. Cause:` + JSON.stringify(error));
}); });
``` ```
## systemTime.getRealActiveTime<sup>8+</sup> ## systemTime.getRealActiveTime<sup>8+</sup>
getRealActiveTime(isNano: boolean, callback: AsyncCallback&lt;number&gt;): void getRealActiveTime(isNano: boolean, callback: AsyncCallback&lt;number&gt;): void
Obtains the time elapsed since system start, excluding the deep sleep time. This API uses an asynchronous callback to return the result. Obtains the time elapsed since system startup, excluding the deep sleep time. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MiscServices.Time **System capability**: SystemCapability.MiscServices.Time
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | ------------------------------------------------------------ | | -------- | ---------- | ---- | -------------------------- |
| isNano | boolean | Yes | Whether the time to return is in nanoseconds.<br/>- **true**: in nanoseconds.<br>- **false**: in milliseconds. | | isNano | boolean | Yes | Whether the time to return is in nanoseconds.<br>- **true**: in nanoseconds (ns).<br>- **false**: in milliseconds (ms).|
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the time.| | callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the time.|
**Example** **Example**
```js ```js
systemTime.getRealActiveTime(true, (error, data) => { systemTime.getRealActiveTime(true, (error, data) => {
if (error) { if (error) {
console.error(`failed to systemTime.getRealActiveTimebecause ` + JSON.stringify(error)); console.error(`Failed to get real active time. Cause:` + JSON.stringify(error));
return; return;
} }
console.log(`systemTime.getRealActiveTime success data : ` + JSON.stringify(data)); console.log(`Succeeded in getting real active time. Data:` + JSON.stringify(data));
}); });
``` ```
## systemTime.getRealActiveTime<sup>8+</sup> ## systemTime.getRealActiveTime<sup>8+</sup>
getRealActiveTime(callback: AsyncCallback&lt;number&gt;): void getRealActiveTime(callback: AsyncCallback&lt;number&gt;): void
Obtains the time elapsed since system start, excluding the deep sleep time. This API uses an asynchronous callback to return the result. Obtains the time elapsed since system startup, excluding the deep sleep time. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MiscServices.Time **System capability**: SystemCapability.MiscServices.Time
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | ------------------------------------------------------------ | | -------- | -------------- | ---- | --------------------- |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the time.| | callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the time.|
**Example** **Example**
```js ```js
systemTime.getRealActiveTime((error, data) => { systemTime.getRealActiveTime((error, data) => {
if (error) { if (error) {
console.error(`failed to systemTime.getRealActiveTimebecause ` + JSON.stringify(error)); console.error(`Failed to get real active time. Cause:` + JSON.stringify(error));
return; return;
} }
console.log(`systemTime.getRealActiveTime success data : ` + JSON.stringify(data)); console.log(`Succeeded in getting real active time. Data:` + JSON.stringify(data));
}); });
``` ```
## systemTime.getRealActiveTime<sup>8+</sup> ## systemTime.getRealActiveTime<sup>8+</sup>
getRealActiveTime(isNano?: boolean): Promise&lt;number&gt; getRealActiveTime(isNano?: boolean): Promise&lt;number&gt;
Obtains the time elapsed since system start, excluding the deep sleep time. This API uses a promise to return the result. Obtains the time elapsed since system startup, excluding the deep sleep time. This API uses a promise to return the result.
**System capability**: SystemCapability.MiscServices.Time **System capability**: SystemCapability.MiscServices.Time
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------- | ---- | ------------------------------------------------------------ | | ------ | ------- | ---- | ----------------------------------- |
| isNano | boolean | No | Whether the time to return is in nanoseconds.<br/>- **true**: in nanoseconds.<br>- **false**: in milliseconds. | | isNano | boolean | No | Whether the time to return is in nanoseconds.<br>- **true**: in nanoseconds (ns).<br>- **false**: in milliseconds (ms).|
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ------------------------------------------------------------ | | -------------- | -------------------------------- |
| Promise&lt;number&gt; | Promise used to return the time.| | Promise&lt;number&gt; | Promise used to return the time elapsed since system startup, excluding the deep sleep time.|
**Example** **Example**
```js ```js
systemTime.getRealActiveTime().then((data) => { systemTime.getRealActiveTime().then((data) => {
console.log(`systemTime.getRealActiveTime success data : ` + JSON.stringify(data)); console.log(`Succeeded in getting real active time. Data:` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
console.error(`failed to systemTime.getRealActiveTime because ` + JSON.stringify(error)); console.error(`Failed to get real active time. Cause:` + JSON.stringify(error));
}); });
``` ```
## systemTime.getRealTime<sup>8+</sup> ## systemTime.getRealTime<sup>8+</sup>
getRealTime(isNano: boolean, callback: AsyncCallback&lt;number&gt;): void getRealTime(isNano: boolean, callback: AsyncCallback&lt;number&gt;): void
Obtains the time elapsed since system start, including the deep sleep time. This API uses an asynchronous callback to return the result. Obtains the time elapsed since system startup, including the deep sleep time. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MiscServices.Time **System capability**: SystemCapability.MiscServices.Time
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | ------------------------------------------------------------ | | -------- | --------------- | ---- | ------------------------------- |
| isNano | boolean | Yes | Whether the time to return is in nanoseconds.<br/>- **true**: in nanoseconds.<br>- **false**: in milliseconds. | | isNano | boolean | Yes | Whether the time to return is in nanoseconds.<br>- **true**: in nanoseconds (ns).<br>- **false**: in milliseconds (ms).|
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the time. | | callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the time. |
**Example** **Example**
```js ```js
systemTime.getRealTime(true, (error, data) => { systemTime.getRealTime(true, (error, data) => {
if (error) { if (error) {
console.error(`failed to systemTime.getRealTime because ` + JSON.stringify(error)); console.error(`Failed to get real time. Cause:` + JSON.stringify(error));
return; return;
} }
console.log(`systemTime.getRealTime success data: ` + JSON.stringify(data)); console.log(`Succeeded in getting real time. Data:` + JSON.stringify(data));
}); });
``` ```
## systemTime.getRealTime<sup>8+</sup> ## systemTime.getRealTime<sup>8+</sup>
getRealTime(callback: AsyncCallback&lt;number&gt;): void getRealTime(callback: AsyncCallback&lt;number&gt;): void
Obtains the time elapsed since system start, including the deep sleep time. This API uses an asynchronous callback to return the result. Obtains the time elapsed since system startup, including the deep sleep time. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MiscServices.Time **System capability**: SystemCapability.MiscServices.Time
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | ------------------------------------------------------------ | | -------- | --------- | ---- | --------------------------- |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the time. | | callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the time. |
**Example** **Example**
```js ```js
systemTime.getRealTime((error, data) => { systemTime.getRealTime((error, data) => {
if (error) { if (error) {
console.error(`failed to systemTime.getRealTime because ` + JSON.stringify(error)); console.error(`Failed to get real time. Cause:` + JSON.stringify(error));
return; return;
} }
console.log(`systemTime.getRealTime success data: ` + JSON.stringify(data)); console.log(`Succeeded in getting real time. Data:` + JSON.stringify(data));
}); });
``` ```
## systemTime.getRealTime<sup>8+</sup> ## systemTime.getRealTime<sup>8+</sup>
getRealTime(isNano?: boolean): Promise&lt;number&gt; getRealTime(isNano?: boolean): Promise&lt;number&gt;
Obtains the time elapsed since system start, including the deep sleep time. This API uses a promise to return the result. Obtains the time elapsed since system startup, including the deep sleep time. This API uses a promise to return the result.
**System capability**: SystemCapability.MiscServices.Time **System capability**: SystemCapability.MiscServices.Time
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------- | ---- | ------------------------------------------------------------ | | ------ | ------- | ---- | ------------------------------- |
| isNano | boolean | No | Whether the time to return is in nanoseconds.<br/>- **true**: in nanoseconds.<br>- **false**: in milliseconds. | | isNano | boolean | No | Whether the time to return is in nanoseconds.<<br>- **true**: in nanoseconds (ns).<br>- **false**: in milliseconds (ms).|
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ------------------------------------------------------------ | | --------------------- | ------------------------------- |
| Promise&lt;number&gt; | Promise used to return the time.| | Promise&lt;number&gt; | Promise used to return the time elapsed since system startup, including the deep sleep time.|
**Example** **Example**
```js ```js
systemTime.getRealTime().then((data) => { systemTime.getRealTime().then((data) => {
console.log(`systemTime.getRealTime success data: ` + JSON.stringify(data)); console.log(`Succeeded in getting real time. Data:` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
console.error(`failed to systemTime.getRealTime because ` + JSON.stringify(error)); console.error(`Failed to get real time. Cause:` + JSON.stringify(error));
}); });
``` ```
## systemTime.setDate ## systemTime.setDate
...@@ -351,23 +339,22 @@ Sets the system date. This API uses an asynchronous callback to return the resul ...@@ -351,23 +339,22 @@ Sets the system date. This API uses an asynchronous callback to return the resul
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ------------------------------------------ | | -------- | ------------- | ---- | --------------------- |
| date | Date | Yes | Target date to set. | | date | Date | Yes | Target date to set. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Example** **Example**
```js ```js
var data = new Date(); let data = new Date();
systemTime.setDate(data,(error, data) => { systemTime.setDate(data,(error, data) => {
if (error) { if (error) {
console.error('failed to systemTime.setDate because ' + JSON.stringify(error)); console.error('Failed to set system date. Cause:' + JSON.stringify(error));
return; return;
} }
console.info('systemTime.setDate success data : ' + JSON.stringify(data)); console.info('Succeeded in setting system date. Data:' + JSON.stringify(data));
}); });
``` ```
## systemTime.setDate ## systemTime.setDate
...@@ -389,19 +376,18 @@ Sets the system date. This API uses a promise to return the result. ...@@ -389,19 +376,18 @@ Sets the system date. This API uses a promise to return the result.
| Type | Description | | Type | Description |
| ------------------- | -------------------- | | ------------------- | -------------------- |
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
```js ```js
var data = new Date(); let data = new Date();
systemTime.setDate(data).then((value) => { systemTime.setDate(data).then((value) => {
console.log(`systemTime.setDate success data : ` + JSON.stringify(value)); console.log(`Succeeded in setting system date. Data:` + JSON.stringify(value));
}).catch((error) => { }).catch((error) => {
console.error(`failed to systemTime.setDate because: ` + JSON.stringify(error)); console.error(`Failed to set system date. Cause:` + JSON.stringify(error));
}); });
``` ```
## systemTime.getDate<sup>8+</sup> ## systemTime.getDate<sup>8+</sup>
...@@ -414,21 +400,20 @@ Obtains the current system date. This API uses an asynchronous callback to retur ...@@ -414,21 +400,20 @@ Obtains the current system date. This API uses an asynchronous callback to retur
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ---------------------------- | | -------- | -------------- | ---- | --------------------- |
| callback | AsyncCallback&lt;Date&gt; | Yes | Callback used to return the current system date.| | callback | AsyncCallback&lt;Date&gt; | Yes | Callback used to return the current system date.|
**Example** **Example**
```js ```js
systemTime.getDate((error, data) => { systemTime.getDate((error, data) => {
if (error) { if (error) {
console.error(`failed to systemTime.getDate because ` + JSON.stringify(error)); console.error(`Failed to get system date. Cause:` + JSON.stringify(error));
return; return;
} }
console.log(`systemTime.getDate success data : ` + JSON.stringify(data)); console.log(`Succeeded in getting system date. Data:` + JSON.stringify(data));
}); });
``` ```
## systemTime.getDate<sup>8+</sup> ## systemTime.getDate<sup>8+</sup>
...@@ -446,14 +431,13 @@ Obtains the current system date. This API uses a promise to return the result. ...@@ -446,14 +431,13 @@ Obtains the current system date. This API uses a promise to return the result.
**Example** **Example**
```js ```js
systemTime.getDate().then((data) => { systemTime.getDate().then((data) => {
console.log(`systemTime.getDate success data : ` + JSON.stringify(data)); console.log(`Succeeded in getting system date. Data:` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
console.error(`failed to systemTime.getDate because ` + JSON.stringify(error)); console.error(`Failed to get system date. Cause:` + JSON.stringify(error));
}); });
``` ```
## systemTime.setTimezone ## systemTime.setTimezone
...@@ -468,22 +452,21 @@ Sets the system time zone. This API uses an asynchronous callback to return the ...@@ -468,22 +452,21 @@ Sets the system time zone. This API uses an asynchronous callback to return the
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ------------------------------------------ | | -------- | ------------- | ---- | -------------------------- |
| timezone | string | Yes | System time zone to set. | | timezone | string | Yes | System time zone to set. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Example** **Example**
```js ```js
systemTime.setTimezone('Asia/Shanghai', (error, data) => { systemTime.setTimezone('Asia/Shanghai', (error, data) => {
if (error) { if (error) {
console.error('failed to systemTime.setTimezone because ' + JSON.stringify(error)); console.error('Failed to set system time zone. Cause:' + JSON.stringify(error));
return; return;
} }
console.info('SystemTimePlugin systemTime.setTimezone success data : ' + JSON.stringify(data)); console.info('Succeeded in setting system time zone. Data:' + JSON.stringify(data));
}); });
``` ```
## systemTime.setTimezone ## systemTime.setTimezone
...@@ -505,18 +488,17 @@ Sets the system time zone. This API uses a promise to return the result. ...@@ -505,18 +488,17 @@ Sets the system time zone. This API uses a promise to return the result.
| Type | Description | | Type | Description |
| ------------------- | -------------------- | | ------------------- | -------------------- |
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise that returns no value.|
**Example** **Example**
```js ```js
systemTime.setTimezone('Asia/Shanghai').then((data) => { systemTime.setTimezone('Asia/Shanghai').then((data) => {
console.log(`systemTime.setTimezone success data : ` + JSON.stringify(data)); console.log(`Succeeded in setting system time zone. Data:` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
console.error(`failed to systemTime.setTimezone because: ` + JSON.stringify(error)); console.error(`Failed to set system time zone. Cause:` + JSON.stringify(error));
}); });
``` ```
## systemTime.getTimezone<sup>8+</sup> ## systemTime.getTimezone<sup>8+</sup>
...@@ -529,21 +511,20 @@ Obtains the system time zone. This API uses an asynchronous callback to return t ...@@ -529,21 +511,20 @@ Obtains the system time zone. This API uses an asynchronous callback to return t
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | ------------------------ | | -------- | --------- | ---- | ------------------------ |
| callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the system time zone.| | callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the system time zone.|
**Example** **Example**
```js ```js
systemTime.getTimezone((error, data) => { systemTime.getTimezone((error, data) => {
if (error) { if (error) {
console.error(`failed to systemTime.getTimezone because ` + JSON.stringify(error)); console.error(`Failed to get system time zone. Cause:` + JSON.stringify(error));
return; return;
} }
console.log(`systemTime.getTimezone success data : ` + JSON.stringify(data)); console.log(`Succeeded in getting system time zone. Data:` + JSON.stringify(data));
}); });
``` ```
## systemTime.getTimezone<sup>8+</sup> ## systemTime.getTimezone<sup>8+</sup>
...@@ -561,10 +542,10 @@ Obtains the system time zone. This API uses a promise to return the result. ...@@ -561,10 +542,10 @@ Obtains the system time zone. This API uses a promise to return the result.
**Example** **Example**
```js ```js
systemTime.getTimezone().then((data) => { systemTime.getTimezone().then((data) => {
console.log(`systemTime.getTimezone success data : ` + JSON.stringify(data)); console.log(`Succeeded in getting system time zone. Data:` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
console.error(`failed to systemTime.getTimezone because ` + JSON.stringify(error)); console.error(`Failed to get system time zone. Cause:` + JSON.stringify(error));
}); });
``` ```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册