2 * timeval.h 1.0 01/12/19
4 * Defines gettimeofday, timeval, etc. for Win32
6 * By Wu Yongwei, modified by Petr Smolik
16 #include <winsock2.h> //there is defined struct timeval
22 #define EPOCHFILETIME (116444736000000000i64)
24 #define EPOCHFILETIME (116444736000000000LL)
28 int tz_minuteswest; /* minutes W of Greenwich */
29 int tz_dsttime; /* type of dst correction */
32 static inline int gettimeofday(struct timeval *tv, struct timezone *tz)
41 GetSystemTimeAsFileTime(&ft);
42 li.LowPart = ft.dwLowDateTime;
43 li.HighPart = ft.dwHighDateTime;
44 t = li.QuadPart; /* In 100-nanosecond intervals */
45 t -= EPOCHFILETIME; /* Offset to the Epoch time */
46 t /= 10; /* In microseconds */
47 tv->tv_sec = (long)(t / 1000000);
48 tv->tv_usec = (long)(t % 1000000);
58 tz->tz_minuteswest = _timezone / 60;
59 tz->tz_dsttime = _daylight;
67 #endif /* _TIMEVAL_H */