From: Artur Bergman Date: Tue, 25 Sep 2001 13:37:12 +0000 (+0000) Subject: Second attempt at fixing Time::HiRes::time on win32. Apperently if ENV{TZ} is wrong... X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=920aa6e3b70bf37dd398a673ab4c0e7575ffbd42;p=p5sagit%2Fp5-mst-13.2.git Second attempt at fixing Time::HiRes::time on win32. Apperently if ENV{TZ} is wrong we fail. New attempt uses _ftime to try and be more robust. p4raw-id: //depot/perl@12196 --- diff --git a/ext/Time/HiRes/HiRes.xs b/ext/Time/HiRes/HiRes.xs index a4bf2df..a0349fa 100644 --- a/ext/Time/HiRes/HiRes.xs +++ b/ext/Time/HiRes/HiRes.xs @@ -62,26 +62,15 @@ struct timeval { long tv_usec; } */ +#include int gettimeofday (struct timeval *tp, int nothing) { - SYSTEMTIME st; - time_t tt; - struct tm tmtm; - /* mktime converts local to UTC */ - GetLocalTime (&st); - tmtm.tm_sec = st.wSecond; - tmtm.tm_min = st.wMinute; - tmtm.tm_hour = st.wHour; - tmtm.tm_mday = st.wDay; - tmtm.tm_mon = st.wMonth - 1; - tmtm.tm_year = st.wYear - 1900; - tmtm.tm_wday = st.wDayOfWeek; - tmtm.tm_isdst = -1; - tt = mktime (&tmtm); - tp->tv_sec = tt; - tp->tv_usec = st.wMilliseconds * 1000; + struct _timeb timebuffer; + _ftime( &timebuffer ); + tp->tv_sec = timebuffer.time; + tp->tv_usec = timebuffer.millitm * 1000; return 0; } #endif