Implement a usable gettimeofday().

For simplicity, my_mktime() of date.c is reused to avoid the convolutions
that gmtime() and localtime() would implicate.
This commit is contained in:
Johannes Sixt
2007-01-29 13:41:10 +01:00
parent 367d1ce33c
commit f002a73f04
2 changed files with 18 additions and 2 deletions

View File

@@ -81,10 +81,26 @@ int mkstemp (char *__template)
return -1;
return open(filename, O_RDWR | O_CREAT);
}
int gettimeofday(struct timeval *tv, void *tz)
{
return -1;
extern time_t my_mktime(struct tm *tm);
SYSTEMTIME st;
struct tm tm;
GetSystemTime(&st);
tm.tm_year = st.wYear-1900;
tm.tm_mon = st.wMonth-1;
tm.tm_mday = st.wDay;
tm.tm_hour = st.wHour;
tm.tm_min = st.wMinute;
tm.tm_sec = st.wSecond;
tv->tv_sec = my_mktime(&tm);
if (tv->tv_sec < 0)
return -1;
tv->tv_usec = st.wMilliseconds*1000;
return 0;
}
int pipe(int filedes[2])
{
int fd;

2
date.c
View File

@@ -6,7 +6,7 @@
#include "cache.h"
static time_t my_mktime(struct tm *tm)
time_t my_mktime(struct tm *tm)
{
static const int mdays[] = {
0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334