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
This commit is contained in:
parent
0e8c0c22a5
commit
33ebe68e64
2 changed files with 12 additions and 4 deletions
|
@ -1,5 +1,5 @@
|
|||
/* 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.
|
||||
|
||||
|
@ -264,8 +264,10 @@ public class GregorianCalendar extends Calendar
|
|||
//
|
||||
// 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);
|
||||
}
|
||||
|
@ -604,12 +606,12 @@ public class GregorianCalendar extends Calendar
|
|||
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
|
||||
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;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue