1/* 2 * Copyright (C) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16import { AsyncCallback } from './basic'; 17 18/** 19 * System time and timezone. 20 * @since 7 21 * @syscap SystemCapability.MiscServices.Time 22 * @deprecated since 9 23 * @useinstead ohos.systemDateTime 24 */ 25declare namespace systemTime { 26 /** 27 * Sets the system time. 28 * @permission ohos.permission.SET_TIME 29 * @param time Target time stamp (ms) 30 * @throws { BusinessError } -1 - the parameter check failed or permission denied or system error. 31 * @since 7 32 * @deprecated since 9 33 */ 34 function setTime(time : number, callback : AsyncCallback<void>) : void; 35 function setTime(time : number) : Promise<void>; 36 37 /** 38 * Obtains the number of milliseconds that have elapsed since the Unix epoch. 39 * @throws { BusinessError } -1 - the parameter check failed or system error. 40 * @since 8 41 * @deprecated since 9 42 * @useinstead ohos.systemDateTime/systemDateTime.getCurrentTime 43 */ 44 function getCurrentTime(isNano: boolean, callback: AsyncCallback<number>): void; 45 function getCurrentTime(callback: AsyncCallback<number>): void; 46 function getCurrentTime(isNano?: boolean): Promise<number>; 47 48 /** 49 * Obtains the number of milliseconds elapsed since the system was booted, not including deep sleep time. 50 * @throws { BusinessError } -1 - the parameter check failed or system error. 51 * @since 8 52 * @deprecated since 9 53 * @useinstead ohos.systemDateTime/systemDateTime.getRealActiveTime 54 */ 55 function getRealActiveTime(isNano: boolean, callback: AsyncCallback<number>): void; 56 function getRealActiveTime(callback: AsyncCallback<number>): void; 57 function getRealActiveTime(isNano?: boolean): Promise<number>; 58 59 /** 60 * Obtains the number of milliseconds elapsed since the system was booted, including deep sleep time. 61 * @throws { BusinessError } -1 - the parameter check failed or system error. 62 * @since 8 63 * @deprecated since 9 64 * @useinstead ohos.systemDateTime/systemDateTime.getRealTime 65 */ 66 function getRealTime(isNano: boolean, callback: AsyncCallback<number>): void; 67 function getRealTime(callback: AsyncCallback<number>): void; 68 function getRealTime(isNano?: boolean): Promise<number>; 69 70 /** 71 * Sets the system time. 72 * @permission ohos.permission.SET_TIME 73 * @param date The target date 74 * @throws { BusinessError } -1 - the parameter check failed or permission denied or system error. 75 * @since 7 76 * @deprecated since 9 77 */ 78 function setDate(date: Date, callback: AsyncCallback<void>): void; 79 function setDate(date: Date): Promise<void>; 80 81 /** 82 * Obtains the system date. 83 * @throws { BusinessError } -1 - the parameter check failed or system error. 84 * @since 8 85 * @deprecated since 9 86 * @useinstead ohos.systemDateTime/systemDateTime.getDate 87 */ 88 function getDate(callback: AsyncCallback<Date>): void; 89 function getDate(): Promise<Date>; 90 91 /** 92 * Sets the system time zone. 93 * @permission ohos.permission.SET_TIME_ZONE 94 * @param timezone The system time zone 95 * @throws { BusinessError } -1 - the parameter check failed or permission denied or system error. 96 * @since 7 97 * @deprecated since 9 98 */ 99 function setTimezone(timezone: string, callback: AsyncCallback<void>): void; 100 function setTimezone(timezone: string): Promise<void>; 101 102 /** 103 * Obtains the system time zone. 104 * @throws { BusinessError } -1 - the parameter check failed or system error. 105 * @since 8 106 * @deprecated since 9 107 * @useinstead ohos.systemDateTime/systemDateTime.getTimezone 108 */ 109 function getTimezone(callback: AsyncCallback<string>): void; 110 function getTimezone(): Promise<string>; 111} 112 113export default systemTime; 114