[fpc-pascal] DateTimeToUnix bug?

Michael Van Canneyt michael at freepascal.org
Wed Dec 31 12:12:07 CET 2008



On Tue, 30 Dec 2008, John Coppens wrote:

> 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.

Could you test your hypothesis and provide a patch ?

Michael.



More information about the fpc-pascal mailing list