Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2008-03

Looking for a increment time function

6 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Graeme Geldenhuys

Hi,

Does FPC contain a increment time function? Something like IncMonth().

I know I can use DocodeDate/EncodeDate, but that seems such an inefficient way of doing it.

Basically I want to increment the time by 15 or 30 minutes to populate rows in a grid.

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email

ik
to Graeme Geldenhuys

Yes, :)

Ido

Graeme Geldenhuys wrote 22 lines
Hi, Does FPC contain a increment time function? Something like IncMonth(). I know I can use DocodeDate/EncodeDate, but that seems such an inefficient way of doing it. Basically I want to increment the time by 15 or 30 minutes to populate rows in a grid. Regards, - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/ _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

ik
to ik

sorry dateutils.pp

ik wrote 36 lines
Yes, :) Ido On Mon, Mar 17, 2008 at 11:43 AM, Graeme Geldenhuys wrote: > Hi, > > Does FPC contain a increment time function? Something like IncMonth(). > > I know I can use DocodeDate/EncodeDate, but that seems such an > inefficient way of doing it. > > Basically I want to increment the time by 15 or 30 minutes to populate > rows in a grid. > > > Regards, > - Graeme - > > > _______________________________________________ > fpGUI - a cross-platform Free Pascal GUI toolkit > http://opensoft.homeip.net/fpgui/ > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > -- http://ik.homelinux.org/

Reply by email

Graeme Geldenhuys
to ik
ik 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/

Reply by email

Rainer Stratmann
to Graeme Geldenhuys

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,@global_timezone);
 global_gertvold:=global_gertv;
end;
function ger_timeoutget_usec:longint;
begin
 fpgettimeofday(@global_gertv,@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;
Graeme Geldenhuys wrote 19 lines
On 17/03/2008, ik 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 - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

Rainer Stratmann
to Graeme Geldenhuys: Idiot me, I also never thought that TDateTime's time portion is milliseconds from…
+
var
 global_timezone:timezone;
Graeme Geldenhuys wrote 19 lines
On 17/03/2008, ik 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 - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email