[fpc-pascal]Question about DATE handling...

Matt Emson memsom at interalpha.co.uk
Thu Mar 22 16:34:36 CET 2001


>Next, the result of StrToDate() is tDateTime. I can basically live with this,

>but: How can I add a specific number of days to this date? (I must calculate
a
>end date from start-date plus num of days!)

TDateTime (if it works like the Delphi type of the same name) works in the following
way..

TDateTime = Double;

The part before the Decimal point is the date, the part after is the 'time'.


Date:

var
  T: TDateTime;
begin
  T := 0; // 30/12/1899 (Delphi 2+)
  T := 1; // 31/12/1899
end;

  you can therefore summise that each whole digit = 1 day.
  therefore, 'today' = number of days since 30/12/1899 

 Time:
    0.000012 = 1 second  (00:00:01)
    0.000024 = 2 seconds (00:00:02)

>Normally, I use EpochTime as internal date format for all of that, so I 
>can simply add/subtract seconds -- and this is perfect. 
>--> But how can I get an epoch time out from tDateTime?

Take a look at:

http://www.merlyn.demon.co.uk/pas-time.htm

Hope that helps,

Matt




More information about the fpc-pascal mailing list