O-CU-UP
[scp/ocu/5gnr.git] / Include / vos_time.h
1 /******************************************************************************
2 ###############################################################################
3 #   Copyright (c) [2017-2020] [ICT/CAS]                                        #
4 #   Licensed under the ORAN Software License v1.0 (License)             #
5 ###############################################################################
6 ******************************************************************************/
7
8
9 #ifndef __VOS_TIME_H__
10 #define __VOS_TIME_H__
11
12 #ifdef  __cplusplus
13 extern "C"{
14 #endif
15
16 #include "vos_types.h"
17
18 #define VOS_TIME_STR_LEN 20
19
20 typedef struct LOCAL_TIME {
21     USHORT usYear;
22     USHORT usMonth;
23     USHORT usDayOfWeek;
24     USHORT usDay;
25     USHORT usHour;
26     USHORT usMinute;
27     USHORT usSecond;
28     USHORT usMilliseconds;
29 }VOS_LOCAL_TIME;
30
31
32
33 /** 
34  * 获取当前时间
35  * @param[in]   vos_time     存储时间的指针
36  * @return      成功返回 VOS_OK,失败则返回其他
37  */ 
38 LONG VOS_local_time( VOS_LOCAL_TIME *vos_time );
39
40
41 /** 
42  * 获取当前时间
43  * @param[out]   sys_time     时间
44  * @return      返回值同 sys_time
45  */ 
46 LONG VOS_time( LONG *sys_time );
47
48 /** 
49  * 时间转换,local time 转成秒数
50  * @param[out]   sys_time     时间
51  * @return      返回 sys_time 对应的秒数
52  */ 
53 LONG VOS_mkTime(const VOS_LOCAL_TIME *sys_time );
54
55
56 /** 
57  * 时间转换,秒数 转成local time
58  * @param[out]   sys_time     时间
59  * @param[in ]   time         时间秒数
60  * @return      成功返回 VOS_OK,失败则返回其他
61  */ 
62 LONG VOS_mkLocalTime( VOS_LOCAL_TIME *sys_time ,LONG time);
63
64
65 /** 
66  * 获得时间字符串 YYYY-MM-DD hh:mm:ss
67  *  如果sys_time非空则根据sys_time转换,否则根据time转换,time为0时取当前时间转换,
68  *  转换完成后存入str中
69  * @param[in ]   sys_time     时间
70  * @param[in ]   time         时间秒数
71  * @param[out]   str          时间字符串
72  * @return      指向str的指针
73  */
74 CHAR *VOS_mkLocalTimeStr( VOS_LOCAL_TIME *sys_time ,LONG time,CHAR str[VOS_TIME_STR_LEN]);
75
76
77 /** 
78  * 将时间字符串 YYYY-MM-DD hh:mm:ss 转换,为VOS_LOCAL_TIME 和 LONG型
79  *  sys_time和time不为空则填入转换后的值,某一项不需要可以使用NULL
80  * @param[in ]   str          时间字符串
81  * @param[out]   sys_time     时间
82  * @param[out]   time         时间秒数
83  * @return      成功返回 VOS_OK,失败则返回其他
84  */
85 LONG VOS_StrmkLocalTime( CHAR str[VOS_TIME_STR_LEN],VOS_LOCAL_TIME *sys_time ,LONG *time);
86
87
88 /** 
89  * 将时间秒数转换成 snmp 时间
90  * @param[in ]   sys_time     时间秒数
91  * @param[out]   snmpTime     时间
92  * @return      成功返回 VOS_OK,失败则返回其他
93  */
94 LONG vos_time2snmp(LONG sys_time,VOS_SNMP_DateAndTime_t *snmpTime);
95
96 #ifdef  __cplusplus
97 }
98 #endif  /* end of __cplusplus */
99
100 #endif  /* end of __VOS_TIME_H__ */
101