In message "Re: Bug report: java.util.GregorianCalendar" on 03/08/28, Ito Kazumitsu <[EMAIL PROTECTED]> writes:
> And I have found another bug shown by the attached program. > This bug seems to have something to do with leap yeas. > If this bug is fixed, my patch about the WEEK_OF_MONTH will > work. 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; time += gregOffset * (24 * 60 * 60 * 1000L); } @@ -609,7 +611,7 @@ // which day of the week are we (0..6), relative to getFirstDayOfWeek int relativeWeekday = (7 + fields[DAY_OF_WEEK] - getFirstDayOfWeek()) % 7; - fields[WEEK_OF_MONTH] = (fields[DAY_OF_MONTH] - relativeWeekday + 6) / 7; + fields[WEEK_OF_MONTH] = (fields[DAY_OF_MONTH] - relativeWeekday + 12) / 7; int weekOfYear = (fields[DAY_OF_YEAR] - relativeWeekday + 6) / 7; _______________________________________________ Classpath mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/classpath