Add some time stuff to libc
This commit is contained in:
parent
9f7ea8db1d
commit
4ace4427d4
@ -17,3 +17,5 @@ struct tm {
|
||||
|
||||
extern struct tm *localtime(const time_t *timep);
|
||||
extern size_t strftime(char *s, size_t max, const char *format, const struct tm *tm);
|
||||
extern time_t time(time_t * out);
|
||||
extern double difftime(time_t a, time_t b);
|
||||
|
15
libc/time.c
Normal file
15
libc/time.c
Normal file
@ -0,0 +1,15 @@
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
time_t time(time_t * out) {
|
||||
struct timeval p;
|
||||
gettimeofday(&p, NULL);
|
||||
if (out) {
|
||||
*out = p.tv_sec;
|
||||
}
|
||||
return p.tv_sec;
|
||||
}
|
||||
|
||||
double difftime(time_t a, time_t b) {
|
||||
return (double)(a - b);
|
||||
}
|
Loading…
Reference in New Issue
Block a user