[fpc-pascal] DateTimeToUnix bug ?

Koenraad Lelong fpascal at brouwerij.homelinux.net
Wed Jul 15 11:06:39 CEST 2009


Hi,
I have a linux application where I use DatetimeToUnix. I think it 
contains a bug.
Every minute I put a sample in an rrddb (rrdtool). When I dump the 
rrddb, the time of the samples is 2 hours in the future. Those 2 hours 
happen to be the time-zone difference, between UTC and CEST.
Anyone can verify this ?

This is what I used to test this :
program DateTest;
{$ifdef FPC}{$mode objfpc}{$h+}{$INTERFACES CORBA}{$endif}
{$ifdef mswindows}{$apptype console}{$endif}
uses
  {$ifdef FPC}{$ifdef linux}cthreads,{$endif}{$endif}
  sysutils, dateutils;

var
  Nu : TDateTime;

begin

Nu:=Now;
writeln(nu:1:8,' ',DateTimeToStr(nu),' ',DatetimeToUnix(Nu));
end.

When I run "./DateTest && date +%s && date" I get :
40009.44713685 15-7-09 10:43:52 1247654632
1247647432
wo jul 15 10:43:52 CEST 2009

Between the fpc-version and the linux-version of the unix-time there is 
7200 seconds difference, fpc running ahead.

Is it a bug, or am I missing someting ? This happens with FPC 2.4.

Regards,
Koenraad Lelong.



More information about the fpc-pascal mailing list