[fpc-devel] TDateTime issue.

Pascal Pype pascal.pype at skynet.be
Sun Mar 31 11:55:04 CEST 2024


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tstDateTime.pas
Type: text/x-pascal
Size: 441 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20240331/b2ce0096/attachment.pas>


More information about the fpc-devel mailing list