openharmony 鸿蒙 capi-time-service-h

2026-08-25 浏览 (1)

time_service.h

Overview

Declares the APIs for obtaining the time and time zone.

Library: libtime_service_ndk.so

File to include: <BasicServicesKit/time_service.h>

System capability: SystemCapability.MiscServices.Time

Since: 12

Related module: TimeService

Summary

Enums

Nametypedef KeywordDescription
TimeService_ErrCodeTimeService_ErrCodeEnumerates the error codes.

Functions

NameDescription
TimeService_ErrCode OH_TimeService_GetTimeZone(char *timeZone, uint32_t len)Obtains the current system time zone.

Enum Description

TimeService_ErrCode

enum TimeService_ErrCode

Description

Enumerates the error codes.

Since: 12

Enum ItemDescription
TIMESERVICE_ERR_OK = 0Operation successful.
TIMESERVICE_ERR_INTERNAL_ERROR = 13000001Failed to obtain system parameters.
TIMESERVICE_ERR_INVALID_PARAMETER = 13000002Invalid parameter.

Function Description

OH_TimeService_GetTimeZone()

TimeService_ErrCode OH_TimeService_GetTimeZone(char *timeZone, uint32_t len)

Description

Obtains the current system time zone.

System capability: SystemCapability.MiscServices.Time

Since: 12

Parameters

NameDescription
char *timeZonePointer to the string array of time zone IDs. If the timezone is obtained, its ID is written. Otherwise, an empty string is written. The string ends with \0.
uint32_t lenLength of a string array of time zone IDs without maximum limit. You are advised to apply for sufficient memory for at least 31 bytes.

Returns

TypeDescription
TimeService_ErrCodeReturns TIMESERVICE_ERR_OK if the operation is successful;
returns TIMESERVICE_ERR_INTERNAL_ERROR if the system parameters fail to be obtained;
returns TIMESERVICE_ERR_INVALID_PARAMETER if timeZone is a null pointer or the length of the time zone name (excluding the end character \0) is greater than or equal to the value of len.

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 errorcode-zlib

openharmony 鸿蒙 capi-oh-scan-scan-picturescanprogress

openharmony 鸿蒙 js-apis-screen-lock

openharmony 鸿蒙 capi-os-account-common-h

openharmony 鸿蒙 js-apis-screen-lock-sys

openharmony 鸿蒙 capi-oh-print-print-propertylist

openharmony 鸿蒙 capi-oh-scan

openharmony 鸿蒙 js-apis-system-device

openharmony 鸿蒙 errorcode-intelligentVoice

openharmony 鸿蒙 js-apis-request-sys

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/vxqLs19C