未验证 提交 2d0155a7 编写于 作者: O openharmony_ci 提交者: Gitee

!23978 翻译完成 23522+23243+22005:自定义弹窗文档整改+【time】增加权限校验

Merge pull request !23978 from ester.zhou/TR-23522
......@@ -12,6 +12,17 @@ The **systemDateTime** module provides system time and time zone features. You c
import systemDateTime from '@ohos.systemDateTime';
```
## TimeType<sup>10+</sup>
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&lt;void&gt;) : void
......@@ -374,12 +385,77 @@ try {
}
```
## systemDateTime.setDate
## systemDateTime.getTime<sup>10+</sup>
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.<br>- **true**: The time to return is in nanoseconds.<br>- **false**: The time to return is in milliseconds.<br>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.getUptime<sup>10+</sup>
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.<br>- **true**: The time to return is in nanoseconds.<br>- **false**: The time to return is in milliseconds.<br>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<sup>(deprecated)</sup>
setDate(date: Date, callback: AsyncCallback&lt;void&gt;): 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<sup>(deprecated)</sup>
setDate(date: Date): Promise&lt;void&gt;
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<sup>(deprecated)</sup>
getDate(callback: AsyncCallback&lt;Date&gt;): 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<sup>(deprecated)</sup>
getDate(): Promise&lt;Date&gt;
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.getTimezoneSync<sup>10+</sup>
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.
......
......@@ -17,7 +17,7 @@ CustomDialogController(value:{builder: CustomDialog, cancel?: () =&gt; 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 | () =&gt; 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.<br>Default value: **true** |
| alignment | [DialogAlignment](ts-methods-alert-dialog-box.md#dialogalignment) | No | Alignment mode of the dialog box in the vertical direction.<br>Default value: **DialogAlignment.Default**|
......@@ -29,7 +29,7 @@ CustomDialogController(value:{builder: CustomDialog, cancel?: () =&gt; void, aut
| openAnimation<sup>10+</sup> | [AnimateParam](ts-explicit-animation.md#animateparam) | No | Parameters for defining the open animation of the dialog box.<br>**NOTE**<br>**iterations**: The default value is **1**, indicating that the animation is played once; any other value evaluates to the default value.<br>**playMode**: The default value is **PlayMode.Normal**; any other value evaluates to the default value.|
| closeAniamtion<sup>10+</sup> | [AnimateParam](ts-explicit-animation.md#animateparam) | No | Parameters for defining the close animation of the dialog box.<br>**NOTE**<br>**iterations**: The default value is **1**, indicating that the animation is played once; any other value evaluates to the default value.<br>**playMode**: The default value is **PlayMode.Normal**; any other value evaluates to the default value. |
| showInSubWindow<sup>10+</sup> | boolean | No | Whether to show the dialog box in a sub-window when the dialog box needs to be displayed outside the main window.<br>Default value: **false**, indicating that the dialog box is not displayed in the subwindow<br>**NOTE**<br>A dialog box whose **showInSubWindow** attribute is **true** cannot trigger the display of another dialog box whose **showInSubWindow** attribute is also **true**.|
| backgroundColor<sup>10+</sup> | [ResourceColor](ts-types.md#resourcecolor) | No | Background color of the dialog box. |
| backgroundColor<sup>10+</sup> | [ResourceColor](ts-types.md#resourcecolor) | No | Background color of the dialog box.<br>**NOTE**<br>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.|
| cornerRadius<sup>10+</sup> | [BorderRadiuses](ts-types.md#borderradiuses9) \| [Dimension](ts-types.md#dimension10) | No | Radius of the rounded corners of the background.<br>You can set separate radiuses for the four rounded corners.<br>Default value: **{ topLeft: '24vp', topRight: '24vp', bottomLeft: '24vp', bottomRight: '24vp' }**<br>**NOTE**<br>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,
......
# 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.
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册