diff --git a/cocos2dx/platform/CCStdC.cpp b/cocos2dx/platform/CCStdC.cpp index 7fe335a14b..a641e88a1e 100644 --- a/cocos2dx/platform/CCStdC.cpp +++ b/cocos2dx/platform/CCStdC.cpp @@ -30,20 +30,11 @@ int CC_DLL gettimeofday(struct timeval * val, struct timezone *) { if (val) { - SYSTEMTIME wtm; - GetLocalTime(&wtm); - - struct tm tTm; - tTm.tm_year = wtm.wYear - 1900; - tTm.tm_mon = wtm.wMonth - 1; - tTm.tm_mday = wtm.wDay; - tTm.tm_hour = wtm.wHour; - tTm.tm_min = wtm.wMinute; - tTm.tm_sec = wtm.wSecond; - tTm.tm_isdst = -1; - - val->tv_sec = (long)mktime(&tTm); // time_t is 64-bit on win32 - val->tv_usec = wtm.wMilliseconds * 1000; + LARGE_INTEGER liTime, liFreq; + QueryPerformanceFrequency( &liFreq ); + QueryPerformanceCounter( &liTime ); + val->tv_sec = (long)( liTime.QuadPart / liFreq.QuadPart ); + val->tv_usec = (long)( liTime.QuadPart * 1000000.0 / liFreq.QuadPart - val->tv_sec * 1000000.0 ); } return 0; }