Commit 33ebe68e by Ito Kazumitsu Committed by Michael Koch

GregorianCalendar.java (getLinearTime): Avoid counting the leap day of the leap year twice.

2003-11-27  Ito Kazumitsu  <kaz@maczuka.gcd.org>

	* java/util/GregorianCalendar.java (getLinearTime): Avoid counting
	the leap day of the leap year twice.
	(computeFields): First week of month is 1 not 0.

From-SVN: r73984
parent 0e8c0c22
2003-11-27 Ito Kazumitsu <kaz@maczuka.gcd.org>
* java/util/GregorianCalendar.java (getLinearTime): Avoid counting
the leap day of the leap year twice.
(computeFields): First week of month is 1 not 0.
2003-11-27 Mark Wielaard <mark@klomp.org> 2003-11-27 Mark Wielaard <mark@klomp.org>
* javax/swing/plaf/basic/BasicDefaults.java (BasicDefaults): Put * javax/swing/plaf/basic/BasicDefaults.java (BasicDefaults): Put
......
/* java.util.GregorianCalendar /* java.util.GregorianCalendar
Copyright (C) 1998, 1999, 2001, 2002 Free Software Foundation, Inc. Copyright (C) 1998, 1999, 2001, 2002, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath. This file is part of GNU Classpath.
...@@ -264,8 +264,10 @@ public class GregorianCalendar extends Calendar ...@@ -264,8 +264,10 @@ public class GregorianCalendar extends Calendar
// //
// The additional leap year factor accounts for the fact that // The additional leap year factor accounts for the fact that
// a leap day is not seen on Jan 1 of the leap year. // 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; int gregOffset = (year / 400) - (year / 100) + 2;
if (isLeapYear (year, true) && dayOfYear < 31 + 29) if (isLeapYear (year, true))
--gregOffset; --gregOffset;
time += gregOffset * (24 * 60 * 60 * 1000L); time += gregOffset * (24 * 60 * 60 * 1000L);
} }
...@@ -604,12 +606,12 @@ public class GregorianCalendar extends Calendar ...@@ -604,12 +606,12 @@ public class GregorianCalendar extends Calendar
calculateDay(++day, gregorian); calculateDay(++day, gregorian);
} }
fields[DAY_OF_WEEK_IN_MONTH] = (fields[DAY_OF_MONTH] + 6) / 7; fields[DAY_OF_WEEK_IN_MONTH] = (fields[DAY_OF_MONTH] + 12) / 7;
// which day of the week are we (0..6), relative to getFirstDayOfWeek // which day of the week are we (0..6), relative to getFirstDayOfWeek
int relativeWeekday = (7 + fields[DAY_OF_WEEK] - getFirstDayOfWeek()) % 7; 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; int weekOfYear = (fields[DAY_OF_YEAR] - relativeWeekday + 6) / 7;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment