X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/a5338b60e111972364a8bc6f07011c6defd213d2..a362b4b2c4abbf2da6ec14cb44a8685a81107f6a:/lunaix-os/includes/lunaix/clock.h diff --git a/lunaix-os/includes/lunaix/clock.h b/lunaix-os/includes/lunaix/clock.h index 44dfa04..889490e 100644 --- a/lunaix-os/includes/lunaix/clock.h +++ b/lunaix-os/includes/lunaix/clock.h @@ -1,13 +1,13 @@ #ifndef __LUNAIX_CLOCK_H #define __LUNAIX_CLOCK_H -#include +#include -typedef uint32_t time_t; +typedef u32_t time_t; typedef struct { - uint32_t year; // use int32 as we need to store the 4-digit year + u32_t year; // use int32 as we need to store the 4-digit year uint8_t month; uint8_t day; uint8_t weekday; @@ -44,4 +44,11 @@ clock_tounixtime(datetime_t* dt) (dt->minute - 1) * 60u + dt->second; } +static inline time_t +time_tounix(u32_t yyyy, u32_t mm, u32_t dd, u32_t hh, u32_t MM, u32_t ss) +{ + return (yyyy - 1970) * 31556926u + (mm - 1) * 2629743u + (dd - 1) * 86400u + + (hh - 1) * 3600u + (MM - 1) * 60u + ss; +} + #endif /* __LUNAIX_CLOCK_H */