fix: windows gettimeofday

This commit is contained in:
Alex Duan 2023-09-20 11:24:27 +08:00
parent 09d91cc116
commit 5251675b44
1 changed files with 17 additions and 2 deletions

View File

@ -162,8 +162,23 @@ void SZ_Finalize()
#ifdef WINDOWS
#include <windows.h>
int gettimeofday(struct timeval *tv, struct timezone *tz);
int gettimeofday(struct timeval *tp, void *tzp) {
time_t clock;
struct tm tm;
SYSTEMTIME wtm;
GetLocalTime(&wtm);
tm.tm_year = wtm.wYear - 1900;
tm.tm_mon = wtm.wMonth - 1;
tm.tm_mday = wtm.wDay;
tm.tm_hour = wtm.wHour;
tm.tm_min = wtm.wMinute;
tm.tm_sec = wtm.wSecond;
tm. tm_isdst = -1;
clock = mktime(&tm);
tp->tv_sec = clock;
tp->tv_usec = wtm.wMilliseconds * 1000;
return 0;
}
#else
#include <sys/time.h>
#endif