161847f8eSopenharmony_ci/*
261847f8eSopenharmony_ci * Copyright (C) 2021 Huawei Device Co., Ltd.
361847f8eSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
461847f8eSopenharmony_ci * you may not use this file except in compliance with the License.
561847f8eSopenharmony_ci * You may obtain a copy of the License at
661847f8eSopenharmony_ci *
761847f8eSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
861847f8eSopenharmony_ci *
961847f8eSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1061847f8eSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1161847f8eSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1261847f8eSopenharmony_ci * See the License for the specific language governing permissions and
1361847f8eSopenharmony_ci * limitations under the License.
1461847f8eSopenharmony_ci */
1561847f8eSopenharmony_ci
1661847f8eSopenharmony_ci/**
1761847f8eSopenharmony_ci * @file
1861847f8eSopenharmony_ci * @kit BasicServicesKit
1961847f8eSopenharmony_ci */
2061847f8eSopenharmony_ci
2161847f8eSopenharmony_ciimport { AsyncCallback } from './@ohos.base';
2261847f8eSopenharmony_ci
2361847f8eSopenharmony_ci/**
2461847f8eSopenharmony_ci * System time and timezone.
2561847f8eSopenharmony_ci *
2661847f8eSopenharmony_ci * @namespace systemTime
2761847f8eSopenharmony_ci * @syscap SystemCapability.MiscServices.Time
2861847f8eSopenharmony_ci * @since 7
2961847f8eSopenharmony_ci * @deprecated since 9
3061847f8eSopenharmony_ci * @useinstead ohos.systemDateTime
3161847f8eSopenharmony_ci */
3261847f8eSopenharmony_cideclare namespace systemTime {
3361847f8eSopenharmony_ci  /**
3461847f8eSopenharmony_ci   * Sets the system time.
3561847f8eSopenharmony_ci   *
3661847f8eSopenharmony_ci   * @permission ohos.permission.SET_TIME
3761847f8eSopenharmony_ci   * @param { number } time - Target time stamp (ms)
3861847f8eSopenharmony_ci   * @param { AsyncCallback<void> } callback
3961847f8eSopenharmony_ci   * @throws { BusinessError } -1 - Parameter check failed, permission denied, or system error.
4061847f8eSopenharmony_ci   * @syscap SystemCapability.MiscServices.Time
4161847f8eSopenharmony_ci   * @since 7
4261847f8eSopenharmony_ci   * @deprecated since 9
4361847f8eSopenharmony_ci   */
4461847f8eSopenharmony_ci  function setTime(time: number, callback: AsyncCallback<void>): void;
4561847f8eSopenharmony_ci
4661847f8eSopenharmony_ci  /**
4761847f8eSopenharmony_ci   * Sets the system time.
4861847f8eSopenharmony_ci   *
4961847f8eSopenharmony_ci   * @permission ohos.permission.SET_TIME
5061847f8eSopenharmony_ci   * @param { number } time - Target time stamp (ms)
5161847f8eSopenharmony_ci   * @returns { Promise<void> }
5261847f8eSopenharmony_ci   * @throws { BusinessError } -1 - Parameter check failed, permission denied, or system error.
5361847f8eSopenharmony_ci   * @syscap SystemCapability.MiscServices.Time
5461847f8eSopenharmony_ci   * @since 7
5561847f8eSopenharmony_ci   * @deprecated since 9
5661847f8eSopenharmony_ci   */
5761847f8eSopenharmony_ci  function setTime(time: number): Promise<void>;
5861847f8eSopenharmony_ci
5961847f8eSopenharmony_ci  /**
6061847f8eSopenharmony_ci   * Obtains the number of milliseconds that have elapsed since the Unix epoch.
6161847f8eSopenharmony_ci   *
6261847f8eSopenharmony_ci   * @param { boolean } isNano
6361847f8eSopenharmony_ci   * @param { AsyncCallback<number> } callback
6461847f8eSopenharmony_ci   * @throws { BusinessError } -1 - Parameter check failed, permission denied, or system error.
6561847f8eSopenharmony_ci   * @syscap SystemCapability.MiscServices.Time
6661847f8eSopenharmony_ci   * @since 8
6761847f8eSopenharmony_ci   * @deprecated since 9
6861847f8eSopenharmony_ci   * @useinstead ohos.systemDateTime/systemDateTime.getCurrentTime
6961847f8eSopenharmony_ci   */
7061847f8eSopenharmony_ci  function getCurrentTime(isNano: boolean, callback: AsyncCallback<number>): void;
7161847f8eSopenharmony_ci
7261847f8eSopenharmony_ci  /**
7361847f8eSopenharmony_ci   * Obtains the number of milliseconds that have elapsed since the Unix epoch.
7461847f8eSopenharmony_ci   *
7561847f8eSopenharmony_ci   * @param { AsyncCallback<number> } callback
7661847f8eSopenharmony_ci   * @throws { BusinessError } -1 - Parameter check failed, permission denied, or system error.
7761847f8eSopenharmony_ci   * @syscap SystemCapability.MiscServices.Time
7861847f8eSopenharmony_ci   * @since 8
7961847f8eSopenharmony_ci   * @deprecated since 9
8061847f8eSopenharmony_ci   * @useinstead ohos.systemDateTime/systemDateTime.getCurrentTime
8161847f8eSopenharmony_ci   */
8261847f8eSopenharmony_ci  function getCurrentTime(callback: AsyncCallback<number>): void;
8361847f8eSopenharmony_ci
8461847f8eSopenharmony_ci  /**
8561847f8eSopenharmony_ci   * Obtains the number of milliseconds that have elapsed since the Unix epoch.
8661847f8eSopenharmony_ci   *
8761847f8eSopenharmony_ci   * @param { boolean } isNano
8861847f8eSopenharmony_ci   * @returns { Promise<number> }
8961847f8eSopenharmony_ci   * @throws { BusinessError } -1 - Parameter check failed, permission denied, or system error.
9061847f8eSopenharmony_ci   * @syscap SystemCapability.MiscServices.Time
9161847f8eSopenharmony_ci   * @since 8
9261847f8eSopenharmony_ci   * @deprecated since 9
9361847f8eSopenharmony_ci   * @useinstead ohos.systemDateTime/systemDateTime.getCurrentTime
9461847f8eSopenharmony_ci   */
9561847f8eSopenharmony_ci  function getCurrentTime(isNano?: boolean): Promise<number>;
9661847f8eSopenharmony_ci
9761847f8eSopenharmony_ci  /**
9861847f8eSopenharmony_ci   * Obtains the number of milliseconds elapsed since the system was booted, not including deep sleep time.
9961847f8eSopenharmony_ci   *
10061847f8eSopenharmony_ci   * @param { boolean } isNano
10161847f8eSopenharmony_ci   * @param { AsyncCallback<number> } callback
10261847f8eSopenharmony_ci   * @throws { BusinessError } -1 - Parameter check failed, permission denied, or system error.
10361847f8eSopenharmony_ci   * @syscap SystemCapability.MiscServices.Time
10461847f8eSopenharmony_ci   * @since 8
10561847f8eSopenharmony_ci   * @deprecated since 9
10661847f8eSopenharmony_ci   * @useinstead ohos.systemDateTime/systemDateTime.getRealActiveTime
10761847f8eSopenharmony_ci   */
10861847f8eSopenharmony_ci  function getRealActiveTime(isNano: boolean, callback: AsyncCallback<number>): void;
10961847f8eSopenharmony_ci
11061847f8eSopenharmony_ci  /**
11161847f8eSopenharmony_ci   * Obtains the number of milliseconds elapsed since the system was booted, not including deep sleep time.
11261847f8eSopenharmony_ci   *
11361847f8eSopenharmony_ci   * @param { AsyncCallback<number> } callback
11461847f8eSopenharmony_ci   * @throws { BusinessError } -1 - Parameter check failed, permission denied, or system error.
11561847f8eSopenharmony_ci   * @syscap SystemCapability.MiscServices.Time
11661847f8eSopenharmony_ci   * @since 8
11761847f8eSopenharmony_ci   * @deprecated since 9
11861847f8eSopenharmony_ci   * @useinstead ohos.systemDateTime/systemDateTime.getRealActiveTime
11961847f8eSopenharmony_ci   */
12061847f8eSopenharmony_ci  function getRealActiveTime(callback: AsyncCallback<number>): void;
12161847f8eSopenharmony_ci
12261847f8eSopenharmony_ci  /**
12361847f8eSopenharmony_ci   * Obtains the number of milliseconds elapsed since the system was booted, not including deep sleep time.
12461847f8eSopenharmony_ci   *
12561847f8eSopenharmony_ci   * @param { boolean } isNano
12661847f8eSopenharmony_ci   * @returns { Promise<number> }
12761847f8eSopenharmony_ci   * @throws { BusinessError } -1 - Parameter check failed, permission denied, or system error.
12861847f8eSopenharmony_ci   * @syscap SystemCapability.MiscServices.Time
12961847f8eSopenharmony_ci   * @since 8
13061847f8eSopenharmony_ci   * @deprecated since 9
13161847f8eSopenharmony_ci   * @useinstead ohos.systemDateTime/systemDateTime.getRealActiveTime
13261847f8eSopenharmony_ci   */
13361847f8eSopenharmony_ci  function getRealActiveTime(isNano?: boolean): Promise<number>;
13461847f8eSopenharmony_ci
13561847f8eSopenharmony_ci  /**
13661847f8eSopenharmony_ci   * Obtains the number of milliseconds elapsed since the system was booted, including deep sleep time.
13761847f8eSopenharmony_ci   *
13861847f8eSopenharmony_ci   * @param { boolean } isNano
13961847f8eSopenharmony_ci   * @param { AsyncCallback<number> } callback
14061847f8eSopenharmony_ci   * @throws { BusinessError } -1 - Parameter check failed, permission denied, or system error.
14161847f8eSopenharmony_ci   * @syscap SystemCapability.MiscServices.Time
14261847f8eSopenharmony_ci   * @since 8
14361847f8eSopenharmony_ci   * @deprecated since 9
14461847f8eSopenharmony_ci   * @useinstead ohos.systemDateTime/systemDateTime.getRealTime
14561847f8eSopenharmony_ci   */
14661847f8eSopenharmony_ci  function getRealTime(isNano: boolean, callback: AsyncCallback<number>): void;
14761847f8eSopenharmony_ci
14861847f8eSopenharmony_ci  /**
14961847f8eSopenharmony_ci   * Obtains the number of milliseconds elapsed since the system was booted, including deep sleep time.
15061847f8eSopenharmony_ci   *
15161847f8eSopenharmony_ci   * @param { AsyncCallback<number> } callback
15261847f8eSopenharmony_ci   * @throws { BusinessError } -1 - Parameter check failed, permission denied, or system error.
15361847f8eSopenharmony_ci   * @syscap SystemCapability.MiscServices.Time
15461847f8eSopenharmony_ci   * @since 8
15561847f8eSopenharmony_ci   * @deprecated since 9
15661847f8eSopenharmony_ci   * @useinstead ohos.systemDateTime/systemDateTime.getRealTime
15761847f8eSopenharmony_ci   */
15861847f8eSopenharmony_ci  function getRealTime(callback: AsyncCallback<number>): void;
15961847f8eSopenharmony_ci
16061847f8eSopenharmony_ci  /**
16161847f8eSopenharmony_ci   * Obtains the number of milliseconds elapsed since the system was booted, including deep sleep time.
16261847f8eSopenharmony_ci   *
16361847f8eSopenharmony_ci   * @param { boolean } isNano
16461847f8eSopenharmony_ci   * @returns { Promise<number> }
16561847f8eSopenharmony_ci   * @throws { BusinessError } -1 - Parameter check failed, permission denied, or system error.
16661847f8eSopenharmony_ci   * @syscap SystemCapability.MiscServices.Time
16761847f8eSopenharmony_ci   * @since 8
16861847f8eSopenharmony_ci   * @deprecated since 9
16961847f8eSopenharmony_ci   * @useinstead ohos.systemDateTime/systemDateTime.getRealTime
17061847f8eSopenharmony_ci   */
17161847f8eSopenharmony_ci  function getRealTime(isNano?: boolean): Promise<number>;
17261847f8eSopenharmony_ci
17361847f8eSopenharmony_ci  /**
17461847f8eSopenharmony_ci   * Sets the system time.
17561847f8eSopenharmony_ci   *
17661847f8eSopenharmony_ci   * @permission ohos.permission.SET_TIME
17761847f8eSopenharmony_ci   * @param { Date } date - The target date
17861847f8eSopenharmony_ci   * @param { AsyncCallback<void> } callback
17961847f8eSopenharmony_ci   * @throws { BusinessError } -1 - Parameter check failed, permission denied, or system error.
18061847f8eSopenharmony_ci   * @syscap SystemCapability.MiscServices.Time
18161847f8eSopenharmony_ci   * @since 7
18261847f8eSopenharmony_ci   * @deprecated since 9
18361847f8eSopenharmony_ci   */
18461847f8eSopenharmony_ci  function setDate(date: Date, callback: AsyncCallback<void>): void;
18561847f8eSopenharmony_ci
18661847f8eSopenharmony_ci  /**
18761847f8eSopenharmony_ci   * Sets the system time.
18861847f8eSopenharmony_ci   *
18961847f8eSopenharmony_ci   * @permission ohos.permission.SET_TIME
19061847f8eSopenharmony_ci   * @param { Date } date - The target date
19161847f8eSopenharmony_ci   * @returns { Promise<void> }
19261847f8eSopenharmony_ci   * @throws { BusinessError } -1 - Parameter check failed, permission denied, or system error.
19361847f8eSopenharmony_ci   * @syscap SystemCapability.MiscServices.Time
19461847f8eSopenharmony_ci   * @since 7
19561847f8eSopenharmony_ci   * @deprecated since 9
19661847f8eSopenharmony_ci   */
19761847f8eSopenharmony_ci  function setDate(date: Date): Promise<void>;
19861847f8eSopenharmony_ci
19961847f8eSopenharmony_ci  /**
20061847f8eSopenharmony_ci   * Obtains the system date.
20161847f8eSopenharmony_ci   *
20261847f8eSopenharmony_ci   * @param { AsyncCallback<Date> } callback
20361847f8eSopenharmony_ci   * @throws { BusinessError } -1 - Parameter check failed, permission denied, or system error.
20461847f8eSopenharmony_ci   * @syscap SystemCapability.MiscServices.Time
20561847f8eSopenharmony_ci   * @since 8
20661847f8eSopenharmony_ci   * @deprecated since 9
20761847f8eSopenharmony_ci   * @useinstead ohos.systemDateTime/systemDateTime.getDate
20861847f8eSopenharmony_ci   */
20961847f8eSopenharmony_ci  function getDate(callback: AsyncCallback<Date>): void;
21061847f8eSopenharmony_ci
21161847f8eSopenharmony_ci  /**
21261847f8eSopenharmony_ci   * Obtains the system date.
21361847f8eSopenharmony_ci   *
21461847f8eSopenharmony_ci   * @returns { Promise<Date> }
21561847f8eSopenharmony_ci   * @throws { BusinessError } -1 - Parameter check failed, permission denied, or system error.
21661847f8eSopenharmony_ci   * @syscap SystemCapability.MiscServices.Time
21761847f8eSopenharmony_ci   * @since 8
21861847f8eSopenharmony_ci   * @deprecated since 9
21961847f8eSopenharmony_ci   * @useinstead ohos.systemDateTime/systemDateTime.getDate
22061847f8eSopenharmony_ci   */
22161847f8eSopenharmony_ci  function getDate(): Promise<Date>;
22261847f8eSopenharmony_ci
22361847f8eSopenharmony_ci  /**
22461847f8eSopenharmony_ci   * Sets the system timezone.
22561847f8eSopenharmony_ci   *
22661847f8eSopenharmony_ci   * @permission ohos.permission.SET_TIME_ZONE
22761847f8eSopenharmony_ci   * @param { string } timezone - The system timezone
22861847f8eSopenharmony_ci   * @param { AsyncCallback<void> } callback
22961847f8eSopenharmony_ci   * @throws { BusinessError } -1 - Parameter check failed, permission denied, or system error.
23061847f8eSopenharmony_ci   * @syscap SystemCapability.MiscServices.Time
23161847f8eSopenharmony_ci   * @since 7
23261847f8eSopenharmony_ci   * @deprecated since 9
23361847f8eSopenharmony_ci   */
23461847f8eSopenharmony_ci  function setTimezone(timezone: string, callback: AsyncCallback<void>): void;
23561847f8eSopenharmony_ci
23661847f8eSopenharmony_ci  /**
23761847f8eSopenharmony_ci   * Sets the system timezone.
23861847f8eSopenharmony_ci   *
23961847f8eSopenharmony_ci   * @permission ohos.permission.SET_TIME_ZONE
24061847f8eSopenharmony_ci   * @param { string } timezone - The system timezone
24161847f8eSopenharmony_ci   * @returns { Promise<void> }
24261847f8eSopenharmony_ci   * @throws { BusinessError } -1 - Parameter check failed, permission denied, or system error.
24361847f8eSopenharmony_ci   * @syscap SystemCapability.MiscServices.Time
24461847f8eSopenharmony_ci   * @since 7
24561847f8eSopenharmony_ci   * @deprecated since 9
24661847f8eSopenharmony_ci   */
24761847f8eSopenharmony_ci  function setTimezone(timezone: string): Promise<void>;
24861847f8eSopenharmony_ci
24961847f8eSopenharmony_ci  /**
25061847f8eSopenharmony_ci   * Obtains the system timezone.
25161847f8eSopenharmony_ci   *
25261847f8eSopenharmony_ci   * @param { AsyncCallback<string> } callback
25361847f8eSopenharmony_ci   * @throws { BusinessError } -1 - Parameter check failed, permission denied, or system error.
25461847f8eSopenharmony_ci   * @syscap SystemCapability.MiscServices.Time
25561847f8eSopenharmony_ci   * @since 8
25661847f8eSopenharmony_ci   * @deprecated since 9
25761847f8eSopenharmony_ci   * @useinstead ohos.systemDateTime/systemDateTime.getTimezone
25861847f8eSopenharmony_ci   */
25961847f8eSopenharmony_ci  function getTimezone(callback: AsyncCallback<string>): void;
26061847f8eSopenharmony_ci
26161847f8eSopenharmony_ci  /**
26261847f8eSopenharmony_ci   * Obtains the system timezone.
26361847f8eSopenharmony_ci   *
26461847f8eSopenharmony_ci   * @returns { Promise<string> }
26561847f8eSopenharmony_ci   * @throws { BusinessError } -1 - Parameter check failed, permission denied, or system error.
26661847f8eSopenharmony_ci   * @syscap SystemCapability.MiscServices.Time
26761847f8eSopenharmony_ci   * @since 8
26861847f8eSopenharmony_ci   * @deprecated since 9
26961847f8eSopenharmony_ci   * @useinstead ohos.systemDateTime/systemDateTime.getTimezone
27061847f8eSopenharmony_ci   */
27161847f8eSopenharmony_ci  function getTimezone(): Promise<string>;
27261847f8eSopenharmony_ci}
27361847f8eSopenharmony_ci
27461847f8eSopenharmony_ciexport default systemTime;