\r
interface\r
\r
+{$ifdef win32}\r
+uses\r
+ ltimevalstuff;\r
+{$endif} \r
+\r
type\r
float=extended;\r
\r
\r
function oletounixfloat(t:float):float;\r
function oletounix(t:tdatetime):integer;\r
-function unixtoole(i:integer):tdatetime;\r
+function unixtoole(i:float):tdatetime;\r
\r
{$ifdef win32}\r
function mmtimefloat:float;\r
function qpctimefloat:float;\r
{$endif}\r
\r
+{$ifdef win32}\r
+procedure gettimeofday(var tv:ttimeval);\r
+{$endif}\r
+\r
+\r
const\r
mmtime_driftavgsize=32;\r
mmtime_warmupnum=4;\r
result := trunc(oletounixfloat(t));\r
end;\r
\r
-function unixtoole(i:integer):tdatetime;\r
+function unixtoole(i:float):tdatetime;\r
begin\r
result := ((i)/86400)+daysdifference;\r
end;\r
{$else} {delphi 3}\r
{------------------------------ windows/delphi code to read time}\r
\r
+\r
+{simulate gettimeofday on windows so one can always use gettimeofday if preferred}\r
+\r
+procedure gettimeofday(var tv:ttimeval);\r
+var\r
+ e:extended;\r
+begin\r
+ e := unixtimefloat;\r
+ tv.tv_sec := round(int(e));\r
+ tv.tv_usec := trunc(frac(e)*1000000);\r
+ {just in case}\r
+ if (tv.tv_usec < 0) then tv.tv_usec := 0;\r
+ if (tv.tv_usec > 999999) then tv.tv_usec := 999999;\r
+end;\r
+\r
+\r
{\r
time float: gettickcount\r
resolution: 9x: ~55 ms NT: 1/64th of a second\r