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