[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bug report: java.util.GregorianCalendar
From: |
Jochen Hoenicke |
Subject: |
Re: Bug report: java.util.GregorianCalendar |
Date: |
Fri, 29 Aug 2003 10:56:59 +0200 |
User-agent: |
KMail/1.5.3 |
On Friday 29 August 2003 08:58, Ito Kazumitsu wrote:
>
> This is my patch for this bug.
>
> --- java/util/GregorianCalendar.java.orig Thu Aug 14 13:32:06 2003
> +++ java/util/GregorianCalendar.java Fri Aug 29 15:56:51 2003
> @@ -264,8 +264,10 @@
> //
> // The additional leap year factor accounts for the fact that
> // a leap day is not seen on Jan 1 of the leap year.
> + // And on and after the leap day, the leap day has already been
> + // included in dayOfYear.
> int gregOffset = (year / 400) - (year / 100) + 2;
> - if (isLeapYear (year, true) && dayOfYear < 31 + 29)
> + if (isLeapYear (year, true))
> --gregOffset;
Although I authored this code, I haven't followed the patches for
GregorianCalendar lately. I think you are right that the dayOfYear
doesn't matter here, but this should also apply for the julian case
i.e. outside of the if(gregorian).
Also there is almost the same code in getLinearDay that needs
fixing too. This function is used when transforming a linear day
in day/month/year and it is known whether it is gregorian or julian.
A trickier change would subtract year by one at the beginning of
the function, replace 1970 by 1969 and get rid of the isLeapYear
case. This saves the extra case distinction and isLeapYear call
(and makes the code even less understandable).
Jochen
--
Jochen Hoenicke, University of Oldenburg, 26111 Oldenburg, Germany
Email: address@hidden Tel: +49 441 798 3124
pgppQ8aSbTu6O.pgp
Description: signature