openharmony 鸿蒙 capi-time-service-h

2026-08-25 浏览 (1)

time_service.h

概述

声明获取时间时区信息的API。

库: libtime_service_ndk.so

引用文件: <BasicServicesKit/time_service.h>

系统能力: SystemCapability.MiscServices.Time

起始版本: 12

相关模块: TimeService

汇总

枚举

名称typedef关键字描述
TimeService_ErrCodeTimeService_ErrCode枚举错误码。

函数

名称描述
TimeService_ErrCode OH_TimeService_GetTimeZone(char *timeZone, uint32_t len)获取当前系统时区。

枚举类型说明

TimeService_ErrCode

enum TimeService_ErrCode

描述

枚举错误码。

起始版本: 12

枚举项描述
TIMESERVICE_ERR_OK = 0成功。
TIMESERVICE_ERR_INTERNAL_ERROR = 13000001获取系统参数失败。
TIMESERVICE_ERR_INVALID_PARAMETER = 13000002无效的参数。

函数说明

OH_TimeService_GetTimeZone()

TimeService_ErrCode OH_TimeService_GetTimeZone(char *timeZone, uint32_t len)

描述

获取当前系统时区。

系统能力: SystemCapability.MiscServices.Time

起始版本: 12

参数:

参数项描述
char *timeZone时区ID字符数组,成功时写入当前系统时区ID字符串,失败时写入空字符串,字符串以'\0'结尾。
uint32_t len时区ID字符数组分配的内存大小,当前时区字符串没有最大长度规格,建议申请足够多的内存,至少不能低于31字节。

返回:

类型说明
TimeService_ErrCode返回TIMESERVICE_ERR_OK表示成功。
返回TIMESERVICE_ERR_INTERNAL_ERROR表示获取系统参数失败。
返回TIMESERVICE_ERR_INVALID_PARAMETER表示timeZone为NULL指针或时区名称(不包括结束字符('\0'))的大小大于或等于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/KM3KrKi9