1 #include <time.h> 2 #include <windows.h> 3 4 #include "gettimeofday.h" 5 6 #ifndef LWS_MINGW_SUPPORT gettimeofday(struct timeval * tv,struct timezone * tz)7int gettimeofday(struct timeval *tv, struct timezone *tz) 8 { 9 FILETIME ft; 10 unsigned __int64 tmpres = 0; 11 static int tzflag; 12 13 if (NULL != tv) { 14 GetSystemTimeAsFileTime(&ft); 15 16 tmpres |= ft.dwHighDateTime; 17 tmpres <<= 32; 18 tmpres |= ft.dwLowDateTime; 19 20 /*converting file time to unix epoch*/ 21 tmpres /= 10; /*convert into microseconds*/ 22 tmpres -= DELTA_EPOCH_IN_MICROSECS; 23 tv->tv_sec = (long)(tmpres / 1000000UL); 24 tv->tv_usec = (long)(tmpres % 1000000UL); 25 } 26 27 if (NULL != tz) { 28 if (!tzflag) { 29 _tzset(); 30 tzflag++; 31 } 32 tz->tz_minuteswest = _timezone / 60; 33 tz->tz_dsttime = _daylight; 34 } 35 36 return 0; 37 } 38 #endif 39