feature:add sync api

Signed-off-by: wangtong <wangtong94@huawei.com>
This commit is contained in:
wangtong 2023-08-07 15:52:05 +08:00
parent 2d4694c3ca
commit 64e1a10d14

View File

@ -84,6 +84,16 @@ declare namespace systemDateTime {
*/
function getCurrentTime(isNano?: boolean): Promise<number>;
/**
* Obtains the number of timestamp that have elapsed since the Unix epoch.
*
* @param { boolean } [ isNanoseconds ] - True if the result is in nanoseconds, otherwise in milliseconds
* @returns { number } The timestamp returned of getTime.
* @syscap SystemCapability.MiscServices.Time
* @since 10
*/
function getTime(isNanoseconds?: boolean): number;
/**
* Obtains the number of milliseconds elapsed since the system was booted, not including deep sleep time.
*
@ -148,6 +158,42 @@ declare namespace systemDateTime {
*/
function getRealTime(isNano?: boolean): Promise<number>;
/**
* Indicates time type.
*
* @enum { number } TimeType
* @syscap SystemCapability.MiscServices.Time
* @since 10
*/
enum TimeType {
/**
* Indicates the time elapsed since the system was booted, including deep sleep time.
*
* @syscap SystemCapability.MiscServices.Time
* @since 10
*/
STARTUP,
/**
* Indicates the time elapsed since the system was booted, not including deep sleep time.
*
* @syscap SystemCapability.MiscServices.Time
* @since 10
*/
ACTIVE
}
/**
* Obtains the number of milliseconds since the system has been running.
*
* @param { TimeType } timeType - indicates the type of get uptime.
* @param { boolean } [ isNanoseconds ] - True if the result is in nanoseconds, otherwise in milliseconds
* @returns { number } The timestamp returned of getUpTime.
* @syscap SystemCapability.MiscServices.Time
* @since 10
*/
function getUptime(timeType: TimeType, isNanoseconds?: boolean): number;
/**
* Sets the system time.
*
@ -160,6 +206,8 @@ declare namespace systemDateTime {
* @syscap SystemCapability.MiscServices.Time
* @systemapi Hide this for inner system use
* @since 9
* @deprecated since 10
* @useinstead systemDateTime.setTime
*/
function setDate(date: Date, callback: AsyncCallback<void>): void;
@ -175,6 +223,8 @@ declare namespace systemDateTime {
* @syscap SystemCapability.MiscServices.Time
* @systemapi Hide this for inner system use
* @since 9
* @deprecated since 10
* @useinstead systemDateTime.setTime
*/
function setDate(date: Date): Promise<void>;
@ -185,6 +235,8 @@ declare namespace systemDateTime {
* @throws { BusinessError } 401 - Invalid parameters
* @syscap SystemCapability.MiscServices.Time
* @since 9
* @deprecated since 10
* @useinstead new Date()
*/
function getDate(callback: AsyncCallback<Date>): void;
@ -195,6 +247,8 @@ declare namespace systemDateTime {
* @throws { BusinessError } 401 - Invalid parameters
* @syscap SystemCapability.MiscServices.Time
* @since 9
* @deprecated since 10
* @useinstead new Date()
*/
function getDate(): Promise<Date>;
@ -247,6 +301,15 @@ declare namespace systemDateTime {
* @since 9
*/
function getTimezone(): Promise<string>;
/**
* Obtains the system time zone.
*
* @returns { string } The timezone returned of getTimezoneSync.
* @syscap SystemCapability.MiscServices.Time
* @since 10
*/
function getTimezoneSync(): string;
}
export default systemDateTime;