• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# time_service.h
2
3## Overview
4
5Declares the APIs for obtaining the time and time zone.
6
7**Library**: libtime_service_ndk.so
8
9**System capability**: SystemCapability.MiscServices.Time
10
11**Since**: 12
12
13**Related module**: [TimeService](capi-timeservice.md)
14
15## Summary
16
17### Enums
18
19| Name| typedef Keyword| Description|
20| -- | -- | -- |
21| [TimeService_ErrCode](#timeservice_errcode) | TimeService_ErrCode | Enumerates the error codes.|
22
23### Functions
24
25| Name| Description|
26| -- | -- |
27| [TimeService_ErrCode OH_TimeService_GetTimeZone(char *timeZone, uint32_t len)](#oh_timeservice_gettimezone) | Obtains the current system time zone.|
28
29## Enum Description
30
31### TimeService_ErrCode
32
33```
34enum TimeService_ErrCode
35```
36
37**Description**
38
39Enumerates the error codes.
40
41**Since**: 12
42
43| Enum Item| Description|
44| -- | -- |
45| TIMESERVICE_ERR_OK = 0 | Operation successful.|
46| TIMESERVICE_ERR_INTERNAL_ERROR = 13000001 | Failed to obtain system parameters. |
47| TIMESERVICE_ERR_INVALID_PARAMETER = 13000002 | Invalid parameter.|
48
49
50## Function Description
51
52### OH_TimeService_GetTimeZone()
53
54```
55TimeService_ErrCode OH_TimeService_GetTimeZone(char *timeZone, uint32_t len)
56```
57
58**Description**
59
60Obtains the current system time zone.
61
62**System capability**: SystemCapability.MiscServices.Time
63
64**Since**: 12
65
66
67**Parameters**
68
69| Name| Description|
70| -- | -- |
71| char *timeZone | Pointer 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**.|
72| uint32_t len | Length of a string array of time zone IDs without maximum limit. You are advised to apply for sufficient memory for at less 31 bytes.|
73
74**Returns**
75
76| Type| Description|
77| -- | -- |
78| [TimeService_ErrCode](#timeservice_errcode) | Returns [TIMESERVICE_ERR_OK](capi-time-service-h.md#timeservice_errcode) if the operation is successful;<br>returns [TIMESERVICE_ERR_INTERNAL_ERROR](capi-time-service-h.md#timeservice_errcode) if the system parameters fail to be obtained;<br>returns [TIMESERVICE_ERR_INVALID_PARAMETER](capi-time-service-h.md#timeservice_errcode) 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**. |
79