1 /******************************************************************************
2 ###############################################################################
3 # Copyright (c) [2017-2020] [ICT/CAS] #
4 # Licensed under the ORAN Software License v1.0 (License) #
5 ###############################################################################
6 ******************************************************************************/
10 #define __VOS_TIME_H__
16 #include "vos_types.h"
18 #define VOS_TIME_STR_LEN 20
20 typedef struct LOCAL_TIME {
28 USHORT usMilliseconds;
35 * @param[in] vos_time 存储时间的指针
36 * @return 成功返回 VOS_OK,失败则返回其他
38 LONG VOS_local_time( VOS_LOCAL_TIME *vos_time );
43 * @param[out] sys_time 时间
44 * @return 返回值同 sys_time
46 LONG VOS_time( LONG *sys_time );
49 * 时间转换,local time 转成秒数
50 * @param[out] sys_time 时间
51 * @return 返回 sys_time 对应的秒数
53 LONG VOS_mkTime(const VOS_LOCAL_TIME *sys_time );
57 * 时间转换,秒数 转成local time
58 * @param[out] sys_time 时间
59 * @param[in ] time 时间秒数
60 * @return 成功返回 VOS_OK,失败则返回其他
62 LONG VOS_mkLocalTime( VOS_LOCAL_TIME *sys_time ,LONG time);
66 * 获得时间字符串 YYYY-MM-DD hh:mm:ss
67 * 如果sys_time非空则根据sys_time转换,否则根据time转换,time为0时取当前时间转换,
69 * @param[in ] sys_time 时间
70 * @param[in ] time 时间秒数
71 * @param[out] str 时间字符串
74 CHAR *VOS_mkLocalTimeStr( VOS_LOCAL_TIME *sys_time ,LONG time,CHAR str[VOS_TIME_STR_LEN]);
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,失败则返回其他
85 LONG VOS_StrmkLocalTime( CHAR str[VOS_TIME_STR_LEN],VOS_LOCAL_TIME *sys_time ,LONG *time);
90 * @param[in ] sys_time 时间秒数
91 * @param[out] snmpTime 时间
92 * @return 成功返回 VOS_OK,失败则返回其他
94 LONG vos_time2snmp(LONG sys_time,VOS_SNMP_DateAndTime_t *snmpTime);
98 #endif /* end of __cplusplus */
100 #endif /* end of __VOS_TIME_H__ */