diff --git a/en/application-dev/reference/apis/js-apis-system-date-time.md b/en/application-dev/reference/apis/js-apis-system-date-time.md index d78f005217ddae233bedcb3c37a3284655cec0e5..7ffeee39f6a234df3d0183ed815565fb4710f68a 100644 --- a/en/application-dev/reference/apis/js-apis-system-date-time.md +++ b/en/application-dev/reference/apis/js-apis-system-date-time.md @@ -12,6 +12,17 @@ The **systemDateTime** module provides system time and time zone features. You c import systemDateTime from '@ohos.systemDateTime'; ``` +## TimeType10+ + +Enumerates the types of time to obtain. + +**System capability**: SystemCapability.MiscServices.Time + +| Name | Value | Description | +| ------- | ---- | ------------------------------------------------ | +| STARTUP | 0 | Number of milliseconds elapsed since system startup, including the deep sleep time. | +| ACTIVE | 1 | Number of milliseconds elapsed since system startup, excluding the deep sleep time.| + ## systemDateTime.setTime setTime(time : number, callback : AsyncCallback<void>) : void @@ -374,12 +385,77 @@ try { } ``` -## systemDateTime.setDate +## systemDateTime.getTime10+ + +getTime(isNanoseconds?: boolean): number + + Obtains the time elapsed since the Unix epoch. This API returns the result synchronously. + +**System capability**: SystemCapability.MiscServices.Time + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------------- | ------- | ---- | ------------------------------------------------------------ | +| isNanoseconds | boolean | No | Whether the time to return is in nanoseconds.
- **true**: The time to return is in nanoseconds.
- **false**: The time to return is in milliseconds.
Default value: **false**| + +**Return value** + +| Type | Description | +| ------ | -------------------------- | +| number | Time elapsed since the Unix epoch.| + +**Example** + +```js +try { + let time = systemDateTime.getTime(true) +} catch(e) { + console.info(`Failed to get time. message: ${e.message}, code: ${e.code}`); +} +``` + +## systemDateTime.getUptime10+ + +getUptime(timeType: TimeType, isNanoseconds?: boolean): number + + Obtains the time elapsed since system startup. This API returns the result synchronously. + +**System capability**: SystemCapability.MiscServices.Time + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------------- | ----------------------- | ---- | ------------------------------------------------------------ | +| timeType | [TimeType](#timetype10) | Yes | Type of the time to obtain. | +| isNanoseconds | boolean | No | Whether the time to return is in nanoseconds.
- **true**: The time to return is in nanoseconds.
- **false**: The time to return is in milliseconds.
Default value: **false**| + +**Return value** + +| Type | Description | +| ------ | -------------------------- | +| number | Time elapsed since system startup.| + +**Example** + +```js +try { + let time = systemDateTime.getUpime(systemDate.TimeType.ACTIVE, false); +} catch(e) { + console.info(`Failed to get uptime. message: ${e.message}, code: ${e.code}`); +} +``` + +## systemDateTime.setDate(deprecated) setDate(date: Date, callback: AsyncCallback<void>): void Sets the system date. This API uses an asynchronous callback to return the result. +> **NOTE** +> +> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [systemDateTime.setTime](#systemdatetimesettime) instead. + **System API**: This is a system API. **System capability**: SystemCapability.MiscServices.Time @@ -410,12 +486,16 @@ try { } ``` -## systemDateTime.setDate +## systemDateTime.setDate(deprecated) setDate(date: Date): Promise<void> Sets the system date. This API uses a promise to return the result. +> **NOTE** +> +> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [systemDateTime.setTime](#systemdatetimesettime) instead. + **System API**: This is a system API. **System capability**: SystemCapability.MiscServices.Time @@ -449,12 +529,16 @@ try { } ``` -## systemDateTime.getDate +## systemDateTime.getDate(deprecated) getDate(callback: AsyncCallback<Date>): void Obtains the current system date. This API uses an asynchronous callback to return the result. +> **NOTE** +> +> This API is supported since API version 9 and deprecated since API version 10. You are advised to use **new Date()** instead, which returns a **Date** object. + **System capability**: SystemCapability.MiscServices.Time **Parameters** @@ -479,12 +563,16 @@ try { } ``` -## systemDateTime.getDate +## systemDateTime.getDate(deprecated) getDate(): Promise<Date> Obtains the current system date. This API uses a promise to return the result. +> **NOTE** +> +> This API is supported since API version 9 and deprecated since API version 10. You are advised to use **new Date()** instead, which returns a **Date** object. + **System capability**: SystemCapability.MiscServices.Time **Return value** @@ -638,6 +726,30 @@ try { } ``` +## systemDateTime.getTimezoneSync10+ + +getTimezoneSync(): string + +Obtain the system time zone. This API returns the result synchronously. + +**System capability**: SystemCapability.MiscServices.Time + +**Return value** + +| Type | Description | +| ------ | ---------------------------------------------------------- | +| string | System time zone. For details, see [Supported System Time Zones](#supported-system-time-zones).| + +**Example** + +```js +try { + let timezone = systemDateTime.getTimezoneSync(); +} catch(e) { + console.info(`Failed to get timezone. message: ${e.message}, code: ${e.code}`); +} +``` + ## 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. diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_custom.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_custom.gif index 7ce7ddd59482b67c26553ad04fd8df26a0af5ddb..0b59ac57d889b57ea36faa1fab0224f60c670c0e 100644 Binary files a/en/application-dev/reference/arkui-ts/figures/en-us_image_custom.gif and b/en/application-dev/reference/arkui-ts/figures/en-us_image_custom.gif differ diff --git a/en/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md b/en/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md index 859579fbab98bf9515bef2102d4528c67d167723..b473d51245b3e41b1d61fd856ade4ef4bbae008d 100644 --- a/en/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md +++ b/en/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md @@ -17,7 +17,7 @@ CustomDialogController(value:{builder: CustomDialog, cancel?: () => void, aut | Name | Type | Mandatory | Description | | ----------------------------- | ---------------------------------------- | ---- | ---------------------------------------- | -| builder | CustomDialog | Yes | Constructor of the custom dialog box content. | +| builder | CustomDialog | Yes | Builder of the custom dialog box content. | | cancel | () => void | No | Callback invoked when the dialog box is closed after the overlay exits. | | autoCancel | boolean | No | Whether to allow users to click the overlay to exit.
Default value: **true** | | alignment | [DialogAlignment](ts-methods-alert-dialog-box.md#dialogalignment) | No | Alignment mode of the dialog box in the vertical direction.
Default value: **DialogAlignment.Default**| @@ -29,7 +29,7 @@ CustomDialogController(value:{builder: CustomDialog, cancel?: () => void, aut | openAnimation10+ | [AnimateParam](ts-explicit-animation.md#animateparam) | No | Parameters for defining the open animation of the dialog box.
**NOTE**
**iterations**: The default value is **1**, indicating that the animation is played once; any other value evaluates to the default value.
**playMode**: The default value is **PlayMode.Normal**; any other value evaluates to the default value.| | closeAniamtion10+ | [AnimateParam](ts-explicit-animation.md#animateparam) | No | Parameters for defining the close animation of the dialog box.
**NOTE**
**iterations**: The default value is **1**, indicating that the animation is played once; any other value evaluates to the default value.
**playMode**: The default value is **PlayMode.Normal**; any other value evaluates to the default value. | | showInSubWindow10+ | boolean | No | Whether to show the dialog box in a sub-window when the dialog box needs to be displayed outside the main window.
Default value: **false**, indicating that the dialog box is not displayed in the subwindow
**NOTE**
A dialog box whose **showInSubWindow** attribute is **true** cannot trigger the display of another dialog box whose **showInSubWindow** attribute is also **true**.| -| backgroundColor10+ | [ResourceColor](ts-types.md#resourcecolor) | No | Background color of the dialog box. | +| backgroundColor10+ | [ResourceColor](ts-types.md#resourcecolor) | No | Background color of the dialog box.
**NOTE**
If the content builder also has the background color set, the background color set here will be overridden by the background color of the content builder.| | cornerRadius10+ | [BorderRadiuses](ts-types.md#borderradiuses9) \| [Dimension](ts-types.md#dimension10) | No | Radius of the rounded corners of the background.
You can set separate radiuses for the four rounded corners.
Default value: **{ topLeft: '24vp', topRight: '24vp', bottomLeft: '24vp', bottomRight: '24vp' }**
**NOTE**
This attribute must be used together with the [borderRadius](ts-universal-attributes-border.md) attribute.| ## CustomDialogController @@ -110,7 +110,7 @@ struct CustomDialogUser { }), cancel: this.existApp, autoCancel: true, - alignment: DialogAlignment.Default, + alignment: DialogAlignment.Bottom, offset: { dx: 0, dy: -20 }, gridCount: 4, customStyle: false, diff --git a/en/release-notes/changelogs/OpenHarmony_4.0.10.2/changelogs-time.md b/en/release-notes/changelogs/OpenHarmony_4.0.10.2/changelogs-time.md new file mode 100644 index 0000000000000000000000000000000000000000..99f93ceb5079c5f5c33c95da4293f98f55b5c31a --- /dev/null +++ b/en/release-notes/changelogs/OpenHarmony_4.0.10.2/changelogs-time.md @@ -0,0 +1,29 @@ +# Time Subsystem Changelog + +## cl.time.1 Permission Verification Adding for setTime, setDate, and setTimezone + +Added permission verification for the **setTime**, **setDate**, and **setTimezone** APIs for compliance with the OpenHarmony API specifications. + +Specifically: + + - To call the **setTime** API, the **ohos.permission.SET_TIME** permission is required. + - To call the **setDate** API, the **ohos.permission.SET_TIME** permission is required. + - To call the **setTimezone** API, the **ohos.permission.SET_TIME_ZONE** permission is required. + +**Key API/Component Changes** + +Involved APIs: + + - systemDateTime.setTime; + - systemDateTime.setDate; + - systemDateTime.setTimezone; + +Before change: + - No permission is required for calling the APIs in question. + +After change: + - The APIs can be called only after the specific permission is obtained. If the permission request is invalid or the specific permission is not obtained, **201** is returned, indicating that permission verification fails. + +**Adaptation Guide** + +To call the **setTime**, **setDate**, and **setTimezone** APIs, an application must apply for the corresponding permission.