git://scm.lunaixsky.com
/
lunaix-os.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
chore: fix almost *ALL* warnings.
[lunaix-os.git]
/
lunaix-os
/
includes
/
lunaix
/
clock.h
diff --git
a/lunaix-os/includes/lunaix/clock.h
b/lunaix-os/includes/lunaix/clock.h
index 44dfa04b7da5c8e0bcdd3f5b844877d10ca0dfa3..f3c67d978470b43bb105c3910a3947c7577b4347 100644
(file)
--- a/
lunaix-os/includes/lunaix/clock.h
+++ b/
lunaix-os/includes/lunaix/clock.h
@@
-1,19
+1,19
@@
#ifndef __LUNAIX_CLOCK_H
#define __LUNAIX_CLOCK_H
#ifndef __LUNAIX_CLOCK_H
#define __LUNAIX_CLOCK_H
-#include <
stdint
.h>
+#include <
lunaix/types
.h>
-typedef u
int
32_t time_t;
+typedef u32_t time_t;
typedef struct
{
typedef struct
{
- u
int
32_t year; // use int32 as we need to store the 4-digit year
- u
int
8_t month;
- u
int
8_t day;
- u
int
8_t weekday;
- u
int
8_t hour;
- u
int
8_t minute;
- u
int
8_t second;
+ u32_t year; // use int32 as we need to store the 4-digit year
+ u8_t month;
+ u8_t day;
+ u8_t weekday;
+ u8_t hour;
+ u8_t minute;
+ u8_t second;
} datetime_t;
void
} datetime_t;
void
@@
-44,4
+44,11
@@
clock_tounixtime(datetime_t* dt)
(dt->minute - 1) * 60u + dt->second;
}
(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 */
#endif /* __LUNAIX_CLOCK_H */