From ad8cb140dbce5940ad31540e0a4a884468f8726a Mon Sep 17 00:00:00 2001 From: "ester.zhou" Date: Tue, 13 Dec 2022 20:42:07 +0800 Subject: [PATCH] Update timer docs (11864) Signed-off-by: ester.zhou --- .../reference/apis/js-apis-system-time.md | 46 +++++++++++++++++-- .../reference/apis/js-apis-timer.md | 14 +++--- 2 files changed, 49 insertions(+), 11 deletions(-) diff --git a/en/application-dev/reference/apis/js-apis-system-time.md b/en/application-dev/reference/apis/js-apis-system-time.md index 5247364504..4ce32e28d4 100644 --- a/en/application-dev/reference/apis/js-apis-system-time.md +++ b/en/application-dev/reference/apis/js-apis-system-time.md @@ -453,7 +453,7 @@ Sets the system time zone. This API uses an asynchronous callback to return the | Name | Type | Mandatory| Description | | -------- | ------------- | ---- | -------------------------- | -| timezone | string | Yes | System time zone to set. | +| timezone | string | Yes | System time zone to set. For details, see [Supported System Time Zones](#supported-system-time-zones). | | callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Example** @@ -482,7 +482,7 @@ Sets the system time zone. This API uses a promise to return the result. | Name | Type | Mandatory| Description | | -------- | ------ | ---- | ---------- | -| timezone | string | Yes | System time zone to set.| +| timezone | string | Yes | System time zone to set. For details, see [Supported System Time Zones](#supported-system-time-zones).| **Return value** @@ -512,7 +512,7 @@ Obtains the system time zone. This API uses an asynchronous callback to return t | Name | Type | Mandatory| Description | | -------- | --------- | ---- | ------------------------ | -| callback | AsyncCallback<string> | Yes | Callback used to return the system time zone.| +| callback | AsyncCallback<string> | Yes | Callback used to return the system time zone. For details, see [Supported System Time Zones](#supported-system-time-zones).| **Example** @@ -538,7 +538,7 @@ Obtains the system time zone. This API uses a promise to return the result. | Type | Description | | --------------------- | ------------------------------------- | -| Promise<string> | Promise used to return the system time zone.| +| Promise<string> | Promise used to return the system time zone. For details, see [Supported System Time Zones](#supported-system-time-zones).| **Example** @@ -549,3 +549,41 @@ systemTime.getTimezone().then((data) => { console.error(`Failed to get system time zone. Cause:` + JSON.stringify(error)); }); ``` + +## Supported System Time Zones + +The following table lists the supported system time zones and the respective offset (unit: h) between each time zone and time zone 0. + +| Time Zone | Offset | +| ------------------------------ | --------------------- | +| Antarctica/McMurdo | 12 | +| America/Argentina/Buenos_Aires | -3 | +| Australia/Sydney | 10 | +| America/Noronha | -2 | +| America/St_Johns | -3 | +| Africa/Kinshasa | 1 | +| America/Santiago | -3 | +| Asia/Shanghai | 8 | +| Asia/Nicosia | 3 | +| Europe/Berlin | 2 | +| America/Guayaquil | -5 | +| Europe/Madrid | 2 | +| Pacific/Pohnpei | 11 | +| America/Godthab | -2 | +| Asia/Jakarta | 7 | +| Pacific/Tarawa | 12 | +| Asia/Almaty | 6 | +| Pacific/Majuro | 12 | +| Asia/Ulaanbaatar | 8 | +| America/Mexico_City | -5 | +| Asia/Kuala_Lumpur | 8 | +| Pacific/Auckland | 12 | +| Pacific/Tahiti | -10 | +| Pacific/Port_Moresby | 10 | +| Asia/Gaza | 3 | +| Europe/Lisbon | 1 | +| Europe/Moscow | 3 | +| Europe/Kiev | 3 | +| Pacific/Wake | 12 | +| America/New_York | -4 | +| Asia/Tashkent | 5 | diff --git a/en/application-dev/reference/apis/js-apis-timer.md b/en/application-dev/reference/apis/js-apis-timer.md index cf8ca596bd..f1fabcf335 100644 --- a/en/application-dev/reference/apis/js-apis-timer.md +++ b/en/application-dev/reference/apis/js-apis-timer.md @@ -8,7 +8,7 @@ The **Timer** module provides basic timer capabilities. You can use the APIs of ## setTimeout -setTimeout(handler[,delay[,…args]]): number +setTimeout(handler: Function | string, delay?: number, ...arguments: any[]): number Sets a timer for the system to call a function after the timer goes off. @@ -18,9 +18,9 @@ Sets a timer for the system to call a function after the timer goes off. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| handler | Function | Yes| Function to be called after the timer goes off.| +| handler | Function \| string | Yes| Function to be called after the timer goes off.| | delay | number | No| Number of milliseconds delayed before the execution. If this parameter is left empty, the default value **0** is used, which means that the execution starts immediately or as soon as possible.| -| ...args | Array<any> | No| Additional parameters to pass to the handler after the timer goes off.| +| ...arguments | Array<any> | No| Additional parameters to pass to the handler after the timer goes off.| **Return value** @@ -71,7 +71,7 @@ Cancels the timer created via **setTimeout()**. ## setInterval -setInterval(handler[, delay[, ...args]]): number +setInterval(handler: Function | string, delay: number, ...arguments: any[]): number Sets a repeating timer for the system to repeatedly call a function at a fixed interval. @@ -81,9 +81,9 @@ Sets a repeating timer for the system to repeatedly call a function at a fixed i | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| handler | Function | Yes| Function to be called repeatedly.| -| delay | number | No| Number of milliseconds delayed before the execution.| -| ...args | Array<any> | No| Additional parameters to pass to the handler after the timer goes off.| +| handler | Function \| string | Yes| Function to be called repeatedly.| +| delay | number | Yes| Number of milliseconds delayed before the execution.| +| ...arguments | Array<any> | No| Additional parameters to pass to the handler after the timer goes off.| **Return value** -- GitLab