diff --git a/compat/mingw.c b/compat/mingw.c index f5b64fc564..7f5067676c 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -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; diff --git a/date.c b/date.c index 542c004c2e..11aa176a7f 100644 --- a/date.c +++ b/date.c @@ -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