1 /******************************************************************************
3 * Copyright (c) 2020 ICT/CAS.
5 * Licensed under the O-RAN Software License, Version 1.0 (the "Software License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * https://www.o-ran.org/software
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 *******************************************************************************/
21 #ifndef __VOS_TIME_H__
22 #define __VOS_TIME_H__
28 #include "vos_types.h"
30 #define VOS_TIME_STR_LEN 20
32 typedef struct LOCAL_TIME {
40 USHORT usMilliseconds;
47 * @param[in] vos_time 存储时间的指针
48 * @return 成功返回 VOS_OK,失败则返回其他
50 LONG VOS_local_time( VOS_LOCAL_TIME *vos_time );
55 * @param[out] sys_time 时间
56 * @return 返回值同 sys_time
58 LONG VOS_time( LONG *sys_time );
61 * 时间转换,local time 转成秒数
62 * @param[out] sys_time 时间
63 * @return 返回 sys_time 对应的秒数
65 LONG VOS_mkTime(const VOS_LOCAL_TIME *sys_time );
69 * 时间转换,秒数 转成local time
70 * @param[out] sys_time 时间
71 * @param[in ] time 时间秒数
72 * @return 成功返回 VOS_OK,失败则返回其他
74 LONG VOS_mkLocalTime( VOS_LOCAL_TIME *sys_time ,LONG time);
78 * 获得时间字符串 YYYY-MM-DD hh:mm:ss
79 * 如果sys_time非空则根据sys_time转换,否则根据time转换,time为0时取当前时间转换,
81 * @param[in ] sys_time 时间
82 * @param[in ] time 时间秒数
83 * @param[out] str 时间字符串
86 CHAR *VOS_mkLocalTimeStr( VOS_LOCAL_TIME *sys_time ,LONG time,CHAR str[VOS_TIME_STR_LEN]);
90 * 将时间字符串 YYYY-MM-DD hh:mm:ss 转换,为VOS_LOCAL_TIME 和 LONG型
91 * sys_time和time不为空则填入转换后的值,某一项不需要可以使用NULL
92 * @param[in ] str 时间字符串
93 * @param[out] sys_time 时间
94 * @param[out] time 时间秒数
95 * @return 成功返回 VOS_OK,失败则返回其他
97 LONG VOS_StrmkLocalTime( CHAR str[VOS_TIME_STR_LEN],VOS_LOCAL_TIME *sys_time ,LONG *time);
102 * @param[in ] sys_time 时间秒数
103 * @param[out] snmpTime 时间
104 * @return 成功返回 VOS_OK,失败则返回其他
106 LONG vos_time2snmp(LONG sys_time,VOS_SNMP_DateAndTime_t *snmpTime);
110 #endif /* end of __cplusplus */
112 #endif /* end of __VOS_TIME_H__ */