[fpc-pascal] Looking for a increment time function
Rainer Stratmann
RainerStratmann at t-online.de
Mon Mar 17 11:35:35 CET 2008
Hello Graeme,
may be this is interisting for you...
ger_timeoutreset -> resets the timer
ger_timeoutget_usec -> gets µsec's after resetting
regards
Rainer
var
global_gertv:timeval;
global_gertvold:timeval;
const
secusec:=1000000;
procedure ger_timeoutreset;
begin
fpgettimeofday(@global_gertv, at global_timezone);
global_gertvold:=global_gertv;
end;
function ger_timeoutget_usec:longint;
begin
fpgettimeofday(@global_gertv, at global_timezone);
if global_gertvold.tv_sec=global_gertv.tv_sec then begin
ger_toutcount_usec:=ger_toutcount_usec+(global_gertv.tv_usec -
global_gertvold.tv_usec)
end
else begin
ger_toutcount_usec:=ger_toutcount_usec
+(secusec - global_gertvold.tv_usec + global_gertv.tv_usec)
+(global_gertv.tv_sec - global_gertvold.tv_sec - 1) * secusec;
end;
if ger_toutcount_usec<0 then ger_toutcount_usec:=0;
global_gertvold:=global_gertv;
result:=ger_toutcount_usec;
end;
Am Montag, 17. März 2008 10:54 schrieb Graeme Geldenhuys:
> On 17/03/2008, ik <idokan at gmail.com> wrote:
> > sorry dateutils.pp
>
> Idiot me, I also never thought that TDateTime's time portion is
> milliseconds from midnight. I could have calculated 30 minutes in
> milliseconds and keep adding that to the time portion of TDateTime.
>
> But IncMinute() is so much easier! ;-) Thanks again!
>
> Regards,
> - Graeme -
>
>
> _______________________________________________
> fpGUI - a cross-platform Free Pascal GUI toolkit
> http://opensoft.homeip.net/fpgui/
> _______________________________________________
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
More information about the fpc-pascal
mailing list