1 #ifndef __LUNAIX_CLOCK_H
2 #define __LUNAIX_CLOCK_H
4 #include <lunaix/types.h>
6 typedef uint32_t time_t;
10 uint32_t year; // use int32 as we need to store the 4-digit year
23 clock_walltime(datetime_t* datetime);
26 clock_datatime_eq(datetime_t* a, datetime_t* b);
29 * @brief 返回当前系统时间,即自从开机到当前时刻的毫秒时。
40 clock_tounixtime(datetime_t* dt)
42 return (dt->year - 1970) * 31556926u + (dt->month - 1) * 2629743u +
43 (dt->day - 1) * 86400u + (dt->hour - 1) * 3600u +
44 (dt->minute - 1) * 60u + dt->second;
48 time_tounix(u32_t yyyy, u32_t mm, u32_t dd, u32_t hh, u32_t MM, u32_t ss)
50 return (yyyy - 1970) * 31556926u + (mm - 1) * 2629743u + (dd - 1) * 86400u +
51 (hh - 1) * 3600u + (MM - 1) * 60u + ss;
54 #endif /* __LUNAIX_CLOCK_H */