Greetings,

There seems to be a bug in the TDateTime data type. When the time
difference between two TDateTime variables is just one millisecond, the
compareDateTime function returns 0 (equality) rather than the expected
-1 or 1 (different). See the included program code.

A program using this TDateTime data type to sort a set of records by
descending time stamp gives:

03.09.2015;11:26:15,168;1160265;116026.50;51.010534;3.257746; ...
03.09.2015;11:26:15,068;1320686;135505.23;51.026733;3.123868; ...
03.09.2015;11:26:15,069;1160255;116025.50;50.823928;3.968773; ...
03.09.2015;11:26:14,968;1160245;116024.50;50.964353;2.624580; ...

instead of:

03.09.2015;11:26:15,168;1160265;116026.50;51.010534;3.257746; ...
03.09.2015;11:26:15,069;1160255;116025.50;50.823928;3.968773; ...
03.09.2015;11:26:15,068;1320686;135505.23;51.026733;3.123868; ...
03.09.2015;11:26:14,968;1160245;116024.50;50.964353;2.624580; ...

The record separator is ';'. The first column is the date in
(days,months,years). The second column is the time in
(hours,minutes,seconds,milliseconds). The time stamp is composed of the
first two columns.

The test program prints 0 to the console rather than the expected -1;

My freepascal version is: 3.0.0.
The platform is: Slackware 14.2 x86_64.

Kind regards,
Pascal Pype
{tstDateTime.pas -- qsort}

program tstDateTime;

{ A test program used to show a bug in the TDateTime data type. }

  uses

  dateUtils;

  const

  cstMllScnds1: word = 068;
  cstMllScnds2: word = 069;

  var

  dtTm1,dtTm2: TDateTime;

begin {tstDateTime}

 dtTm1 := encodeDateTime(2015,09,03,11,26,15,cstMllScnds1);
 dtTm2 := encodeDateTime(2015,09,03,11,26,15,cstMllScnds2);

 writeLn(compareDateTime(dtTm1,dtTm2));

end. {tstDateTime}
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to