1 /* 2 * Copyright (c) 2024 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 16 #ifndef TIME_SERVICE_H 17 #define TIME_SERVICE_H 18 19 /** 20 * @addtogroup TimeService 21 * @{ 22 * 23 * @brief Declares the time zone capabilities provided by TimeService to an application. 24 * @since 12 25 */ 26 /** 27 * @file time_service.h 28 * 29 * @brief Declares the APIs for obtaining the time zone information. 30 * @library libtime_service_ndk.so 31 * @syscap SystemCapability.MiscServices.Time 32 * @since 12 33 */ 34 35 #include <stdint.h> 36 37 #ifdef __cplusplus 38 extern "C" { 39 #endif 40 41 /** 42 * @brief Enumerates the error codes. 43 * 44 * @since 12 45 */ 46 typedef enum TimeService_ErrCode { 47 /** @error Success.*/ 48 TIMESERVICE_ERR_OK = 0, 49 50 /** @error Failed to obtain system parameters.*/ 51 TIMESERVICE_ERR_INTERNAL_ERROR = 13000001, 52 53 /** @error Invalid parameter.*/ 54 TIMESERVICE_ERR_INVALID_PARAMETER = 13000002, 55 } TimeService_ErrCode; 56 57 /** 58 * @brief Obtains the current system time zone. 59 * 60 * @param timeZone Pointer to an array of characters indicating the time zone ID. On success, the string indicates the 61 * current system time zone ID. On failure, the string is empty. The string is terminated using '\0'. 62 * @param len Size of the memory allocated for the time zone ID character array. There is no upper limit for the length 63 * of the time zone ID. It is recommended to allocate sufficient memory, at least not less than 31 bytes. 64 * @return Returns {@link TIMESERVICE_ERR_OK} if the operation is successful. 65 * Returns {@link TIMESERVICE_ERR_INTERNAL_ERROR} if obtaining the system parameters fails. 66 * Returns {@link TIMESERVICE_ERR_INVALID_PARAMETER} if <b>timeZone</b> is a null pointer or the length of the 67 * time zone ID (excluding the terminating character ('\0')) is greater than or equal to <b>len</b>. 68 * @syscap SystemCapability.MiscServices.Time 69 * @since 12 70 */ 71 TimeService_ErrCode OH_TimeService_GetTimeZone(char *timeZone, uint32_t len); 72 73 #ifdef __cplusplus 74 } 75 #endif 76 77 /** @} */ 78 79 #endif /* TIME_SERVICE_H */