This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

FYI: Patch: java.util.GregorianCalendar


Hi list,


I commited the attached patch to merge fixes in java.util.GregorianCalendar 
from classpath.


Michael
Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/libjava/ChangeLog,v
retrieving revision 1.2375
diff -u -b -B -r1.2375 ChangeLog
--- ChangeLog	27 Nov 2003 09:09:12 -0000	1.2375
+++ ChangeLog	27 Nov 2003 09:13:28 -0000
@@ -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: java/util/GregorianCalendar.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/util/GregorianCalendar.java,v
retrieving revision 1.17
diff -u -b -B -r1.17 GregorianCalendar.java
--- java/util/GregorianCalendar.java	18 Sep 2003 06:34:00 -0000	1.17
+++ java/util/GregorianCalendar.java	27 Nov 2003 09:13:28 -0000
@@ -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 @@
 	//
 	// 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 @@
 	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;
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]