1 #ifndef __LUNAIX_TIME_H
2 #define __LUNAIX_TIME_H
4 #include <lunaix/types.h>
8 #define TIME_MIN (TIME_SEC * 60)
9 #define TIME_HOUR (TIME_MIN * 60)
11 typedef unsigned int ticks_t;
16 u32_t year; // use int32 as we need to store the 4-digit year
26 datetime_tounix(datetime_t* dt)
28 return (dt->year - 1970) * 31556926u + (dt->month - 1) * 2629743u +
29 (dt->day - 1) * 86400u + (dt->hour - 1) * 3600u +
30 (dt->minute - 1) * 60u + dt->second;
34 time_tounix(u32_t yyyy, u32_t mm, u32_t dd, u32_t hh, u32_t MM, u32_t ss)
36 return (yyyy - 1970) * 31556926u + (mm - 1) * 2629743u + (dd - 1) * 86400u +
37 (hh - 1) * 3600u + (MM - 1) * 60u + ss;
41 datatime_eq(datetime_t* a, datetime_t* b)
43 return a->year == b->year && a->month == b->month && a->day == b->day &&
44 a->weekday == b->weekday && a->minute == b->minute &&
45 a->second == b->second;
48 #endif /* __LUNAIX_TIME_H */