[fpc-pascal] Possible bug in return value of MonthsBetween function in unit dateutils

Funky Beast funkybeast at pacific.net.sg
Thu Dec 10 12:18:23 CET 2009


When trying to get the number of months between the following dates:
01-06-2009 and 01-08-2008

MonthsBetween returns: 9 months.

That is clearly wrong (fundamentally counting with my fingers yields 10
Looking at the function in dateutils.inc, I copied the function
implementation to do a test.
Now, if I strip away Trunc() from the function, the result is: 9.98767967.
Trunc() simply strips away the decimals behind, which returns: 9.

I'm wondering if Round() should be used instead of Trunc().

Funky Beast.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20091210/0cd4eb6a/attachment.html>

More information about the fpc-pascal mailing list