[fpc-pascal] DateTimeToUnix bug?
John Coppens
john at jcoppens.com
Wed Dec 31 00:44:05 CET 2008
On Tue, 30 Dec 2008 09:25:29 -0700
"Seth Grover" <sethdgrover at gmail.com> wrote:
> Is this broken or am I missing something?
I suspect the problem is in this function:
Function SecondsBetween(const ANow, AThen: TDateTime): Int64;
begin
Result:=Trunc(Abs(ANow-AThen)*SecsPerDay);
end;
from the dateutil.inc rtl library. The trunc function is no garantee for
a correct result, and can err downwards. I think it should be rounding
function, or add 0.0005 seconds (1/2 milisecond). Of course this also
depends on the sign of the result.
John
More information about the fpc-pascal
mailing list