OSDN Git Service

2003-11-27 Ito Kazumitsu <kaz@maczuka.gcd.org>
authormkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 27 Nov 2003 09:16:13 +0000 (09:16 +0000)
committermkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 27 Nov 2003 09:16:13 +0000 (09:16 +0000)
* java/util/GregorianCalendar.java (getLinearTime): Avoid counting
the leap day of the leap year twice.
(computeFields): First week of month is 1 not 0.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@73984 138bc75d-0d04-0410-961f-82ee72b054a4

libjava/ChangeLog
libjava/java/util/GregorianCalendar.java

index 3fc4273..33a8692 100644 (file)
@@ -1,3 +1,9 @@
+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>
 
        * javax/swing/plaf/basic/BasicDefaults.java (BasicDefaults): Put
index 91f5890..624924c 100644 (file)
@@ -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;