windows dtime fix

svn path=/trunk/boinc/; revision=992
This commit is contained in:
Eric Heien 2003-02-28 23:30:05 +00:00
parent 2ea9b9c0d1
commit d2fa9df113
1 changed files with 7 additions and 1 deletions

View File

@ -105,10 +105,16 @@ int double_to_ydhms (double x, int smallest_timescale, char *buf) {
// return time of day as a double // return time of day as a double
// Not necessarily in terms of UNIX time (especially on Windows)
// //
double dtime() { double dtime() {
#ifdef _WIN32 #ifdef _WIN32
return (double)time(0); LARGE_INTEGER time;
FILETIME sysTime;
GetSystemTimeAsFileTime(&sysTime);
time.LowPart = sysTime.dwLowDateTime;
time.HighPart = sysTime.dwHighDateTime; // Time is in 100 ns units
return (double)time.QuadPart/10000000; // Convert to 1 s units
#else #else
struct timeval tv; struct timeval tv;
gettimeofday(&tv, 0); gettimeofday(&tv, 0);