1cf69771bSopenharmony_ci/*
2cf69771bSopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd.
3cf69771bSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4cf69771bSopenharmony_ci * you may not use this file except in compliance with the License.
5cf69771bSopenharmony_ci * You may obtain a copy of the License at
6cf69771bSopenharmony_ci *
7cf69771bSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8cf69771bSopenharmony_ci *
9cf69771bSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10cf69771bSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11cf69771bSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12cf69771bSopenharmony_ci * See the License for the specific language governing permissions and
13cf69771bSopenharmony_ci * limitations under the License.
14cf69771bSopenharmony_ci */
15cf69771bSopenharmony_ci
16cf69771bSopenharmony_ci#ifndef TIME_SERVICE_H
17cf69771bSopenharmony_ci#define TIME_SERVICE_H
18cf69771bSopenharmony_ci
19cf69771bSopenharmony_ci/**
20cf69771bSopenharmony_ci * @addtogroup TimeService
21cf69771bSopenharmony_ci * @{
22cf69771bSopenharmony_ci *
23cf69771bSopenharmony_ci * @brief Declares the time zone capabilities provided by TimeService to an application.
24cf69771bSopenharmony_ci * @since 12
25cf69771bSopenharmony_ci */
26cf69771bSopenharmony_ci/**
27cf69771bSopenharmony_ci * @file time_service.h
28cf69771bSopenharmony_ci *
29cf69771bSopenharmony_ci * @brief Declares the APIs for obtaining the time zone information.
30cf69771bSopenharmony_ci * @library libtime_service_ndk.so
31cf69771bSopenharmony_ci * @syscap SystemCapability.MiscServices.Time
32cf69771bSopenharmony_ci * @since 12
33cf69771bSopenharmony_ci */
34cf69771bSopenharmony_ci
35cf69771bSopenharmony_ci#include <stdint.h>
36cf69771bSopenharmony_ci
37cf69771bSopenharmony_ci#ifdef __cplusplus
38cf69771bSopenharmony_ciextern "C" {
39cf69771bSopenharmony_ci#endif
40cf69771bSopenharmony_ci
41cf69771bSopenharmony_ci/**
42cf69771bSopenharmony_ci * @brief Enumerates the error codes.
43cf69771bSopenharmony_ci *
44cf69771bSopenharmony_ci * @since 12
45cf69771bSopenharmony_ci */
46cf69771bSopenharmony_citypedef enum TimeService_ErrCode {
47cf69771bSopenharmony_ci    /** @error Success.*/
48cf69771bSopenharmony_ci    TIMESERVICE_ERR_OK = 0,
49cf69771bSopenharmony_ci
50cf69771bSopenharmony_ci    /** @error Failed to obtain system parameters.*/
51cf69771bSopenharmony_ci    TIMESERVICE_ERR_INTERNAL_ERROR = 13000001,
52cf69771bSopenharmony_ci
53cf69771bSopenharmony_ci    /** @error Invalid parameter.*/
54cf69771bSopenharmony_ci    TIMESERVICE_ERR_INVALID_PARAMETER = 13000002,
55cf69771bSopenharmony_ci} TimeService_ErrCode;
56cf69771bSopenharmony_ci
57cf69771bSopenharmony_ci/**
58cf69771bSopenharmony_ci * @brief Obtains the current system time zone.
59cf69771bSopenharmony_ci *
60cf69771bSopenharmony_ci * @param timeZone Pointer to an array of characters indicating the time zone ID. On success, the string indicates the
61cf69771bSopenharmony_ci *        current system time zone ID. On failure, the string is empty. The string is terminated using '\0'.
62cf69771bSopenharmony_ci * @param len Size of the memory allocated for the time zone ID character array. There is no upper limit for the length
63cf69771bSopenharmony_ci *        of the time zone ID. It is recommended to allocate sufficient memory, at least not less than 31 bytes.
64cf69771bSopenharmony_ci * @return Returns {@link TIMESERVICE_ERR_OK} if the operation is successful.
65cf69771bSopenharmony_ci *         Returns {@link TIMESERVICE_ERR_INTERNAL_ERROR} if obtaining the system parameters fails.
66cf69771bSopenharmony_ci *         Returns {@link TIMESERVICE_ERR_INVALID_PARAMETER} if <b>timeZone</b> is a null pointer or the length of the
67cf69771bSopenharmony_ci *         time zone ID (excluding the terminating character ('\0')) is greater than or equal to <b>len</b>.
68cf69771bSopenharmony_ci * @syscap SystemCapability.MiscServices.Time
69cf69771bSopenharmony_ci * @since 12
70cf69771bSopenharmony_ci */
71cf69771bSopenharmony_ciTimeService_ErrCode OH_TimeService_GetTimeZone(char *timeZone, uint32_t len);
72cf69771bSopenharmony_ci
73cf69771bSopenharmony_ci#ifdef __cplusplus
74cf69771bSopenharmony_ci}
75cf69771bSopenharmony_ci#endif
76cf69771bSopenharmony_ci
77cf69771bSopenharmony_ci/** @} */
78cf69771bSopenharmony_ci
79cf69771bSopenharmony_ci#endif /* TIME_SERVICE_H */