At 12:39 PM 12/21/00 +0100, Gilbert Peffer wrote:
>I found a slightly more serious bug in Date::year(), unless it was an
>intended behaviour.
>
>I think the function only works correctly (explained below what that means),
>if you calculate the year using
>
> Year y = (theSerialNumber - 1)/365.25
>
>The function, from my point of view, should at least implement the
>year-change correctly. A little example using the 31/12/1999 and 1/1/2000
>shows that the current function doesn't and the proposed one does:
>
> 31/12/1999 resulting in 2000.0657... (current)
> resulting in 1999.9972... (new)
>
> 1/1/2000 resulting in 2000.0712... (current)
> resulting in 2000 (new)
Hi Gilbert,
in this case
Year y = theSerialNumber/365;
only gives a first guess. The two lines below, namely,
while (theSerialNumber < yearOffset[y])
y--;
check the correctness of the guess and set y to the right value.
I agree that
>Year y = (theSerialNumber - 1)/365.25
might be a better guess. However, I'd like to leave the check, just in case
(365.25 isn't the exact value either)
Bye,
Luigi