• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# time_service.h
2
3## 概述
4
5声明获取时间时区信息的API。
6
7**库:** libtime_service_ndk.so
8
9**系统能力:** SystemCapability.MiscServices.Time
10
11**起始版本:** 12
12
13**相关模块:** [TimeService](capi-timeservice.md)
14
15## 汇总
16
17### 枚举
18
19| 名称 | typedef关键字 | 描述 |
20| -- | -- | -- |
21| [TimeService_ErrCode](#timeservice_errcode) | TimeService_ErrCode | 枚举错误码。 |
22
23### 函数
24
25| 名称 | 描述 |
26| -- | -- |
27| [TimeService_ErrCode OH_TimeService_GetTimeZone(char *timeZone, uint32_t len)](#oh_timeservice_gettimezone) | 获取当前系统时区。 |
28
29## 枚举类型说明
30
31### TimeService_ErrCode
32
33```
34enum TimeService_ErrCode
35```
36
37**描述**
38
39枚举错误码。
40
41**起始版本:** 12
42
43| 枚举项 | 描述 |
44| -- | -- |
45| TIMESERVICE_ERR_OK = 0 | 成功。 |
46| TIMESERVICE_ERR_INTERNAL_ERROR = 13000001 | 获取系统参数失败。 |
47| TIMESERVICE_ERR_INVALID_PARAMETER = 13000002 | 无效的参数。 |
48
49
50## 函数说明
51
52### OH_TimeService_GetTimeZone()
53
54```
55TimeService_ErrCode OH_TimeService_GetTimeZone(char *timeZone, uint32_t len)
56```
57
58**描述**
59
60获取当前系统时区。
61
62**系统能力:** SystemCapability.MiscServices.Time
63
64**起始版本:** 12
65
66
67**参数:**
68
69| 参数项 | 描述 |
70| -- | -- |
71| char *timeZone | 时区ID字符数组,成功时写入当前系统时区ID字符串,失败时写入空字符串,字符串以'\0'结尾。 |
72| uint32_t len | 时区ID字符数组分配的内存大小,当前时区字符串没有最大长度规格,建议申请足够多的内存,至少不能低于31字节。 |
73
74**返回:**
75
76| 类型 | 说明 |
77| -- | -- |
78| [TimeService_ErrCode](#timeservice_errcode) | 返回[TIMESERVICE_ERR_OK](capi-time-service-h.md#timeservice_errcode)表示成功。<br>         返回[TIMESERVICE_ERR_INTERNAL_ERROR](capi-time-service-h.md#timeservice_errcode)表示获取系统参数失败。<br>         返回[TIMESERVICE_ERR_INVALID_PARAMETER](capi-time-service-h.md#timeservice_errcode)表示timeZone为NULL指针或时区名称(不包括结束字符('\0'))的大小大于或等于len。 |
79
80
81