mirror of
https://gitee.com/openharmony/interface_sdk_c
synced 2024-11-23 06:39:54 +00:00
新增时间时区获取时区接口
Signed-off-by: li_junsong <lijunsong4@huawei.com>
This commit is contained in:
parent
a1fe6b2164
commit
6385b1dba4
@ -57,3 +57,17 @@ ohos_ndk_library("libohscan_ndk") {
|
||||
system_capability = "SystemCapability.Print.PrintFramework"
|
||||
system_capability_headers = [ "BasicServicesKit/ohscan.h" ]
|
||||
}
|
||||
|
||||
ohos_ndk_headers("time_service_ndk_header") {
|
||||
dest_dir = "$ndk_headers_out_dir/BasicServicesKit/"
|
||||
sources = [ "./time_service.h" ]
|
||||
}
|
||||
|
||||
ohos_ndk_library("libtime_service_ndk") {
|
||||
output_name = "time_service_ndk"
|
||||
output_extension = "so"
|
||||
ndk_description_file = "./libtime_service.ndk.json"
|
||||
min_compact_version = "12"
|
||||
system_capability = "SystemCapability.MiscServices.Time"
|
||||
system_capability_headers = [ "BasicServicesKit/time_service.h" ]
|
||||
}
|
||||
|
5
BasicServicesKit/libtime_service.ndk.json
Normal file
5
BasicServicesKit/libtime_service.ndk.json
Normal file
@ -0,0 +1,5 @@
|
||||
[
|
||||
{ "first_introduced": "12",
|
||||
"name":"OH_TimeService_GetTimeZone"
|
||||
}
|
||||
]
|
79
BasicServicesKit/time_service.h
Normal file
79
BasicServicesKit/time_service.h
Normal file
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef TIME_SERVICE_H
|
||||
#define TIME_SERVICE_H
|
||||
|
||||
/**
|
||||
* @addtogroup TimeService
|
||||
* @{
|
||||
*
|
||||
* @brief Declares the time zone capabilities provided by TimeService to an application.
|
||||
* @since 12
|
||||
*/
|
||||
/**
|
||||
* @file time_service.h
|
||||
*
|
||||
* @brief Declares the APIs for obtaining the time zone information.
|
||||
* @library libtime_service_ndk.so
|
||||
* @syscap SystemCapability.MiscServices.Time
|
||||
* @since 12
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enumerates the error codes.
|
||||
*
|
||||
* @since 12
|
||||
*/
|
||||
typedef enum TimeService_ErrCode {
|
||||
/** @error Success.*/
|
||||
TIMESERVICE_ERR_OK = 0,
|
||||
|
||||
/** @error Failed to obtain system parameters.*/
|
||||
TIMESERVICE_ERR_INTERNAL_ERROR = 13000001,
|
||||
|
||||
/** @error Invalid parameter.*/
|
||||
TIMESERVICE_ERR_INVALID_PARAMETER = 13000002,
|
||||
} TimeService_ErrCode;
|
||||
|
||||
/**
|
||||
* @brief Obtains the current system time zone.
|
||||
*
|
||||
* @param timeZone Pointer to an array of characters indicating the time zone ID. On success, the string indicates the
|
||||
* current system time zone ID. On failure, the string is empty. The string is terminated using '\0'.
|
||||
* @param len Size of the memory allocated for the time zone ID character array. There is no upper limit for the length
|
||||
* of the time zone ID. It is recommended to allocate sufficient memory, at least not less than 31 bytes.
|
||||
* @return Returns {@link TIMESERVICE_ERR_OK} if the operation is successful.
|
||||
* Returns {@link TIMESERVICE_ERR_INTERNAL_ERROR} if obtaining the system parameters fails.
|
||||
* Returns {@link TIMESERVICE_ERR_INVALID_PARAMETER} if <b>timeZone</b> is a null pointer or the length of the
|
||||
* time zone ID (excluding the terminating character ('\0')) is greater than or equal to <b>len</b>.
|
||||
* @syscap SystemCapability.MiscServices.Time
|
||||
* @since 12
|
||||
*/
|
||||
TimeService_ErrCode OH_TimeService_GetTimeZone(char *timeZone, uint32_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif /* TIME_SERVICE_H */
|
Loading…
Reference in New Issue
Block a user