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]

Re: [patch] Return of SimpleTimeZone fix


Michael Koch writes:
 > -----BEGIN PGP SIGNED MESSAGE-----
 > Hash: SHA1
 > 
 > Am Montag, 7. Juni 2004 14:57 schrieb Jerry Quinn:
 > > Michael Koch writes:
 > >  > Have you checked out a special version of the file ? Perhaps cvs
 > >  > thinks you don't want to update it to a newer version ...
 > >
 > > Moving my copy aside and cvs update -A still gives me the same
 > > diffs.
 > >
 > >  > > I could post the whole file if you want.
 > >  >
 > >  > Please do so.
 > 
 > I looked into it. You are right it gives one new FAIL for 
 > java.util.GregorianCalendar BUT you missed that around 200 tests for 
 > java.util.GregorianCalendar where not done because of the one FAIL.
 > 
 > I think think its needed to fix both issues at once. Can you look into 
 > GregorianCalendar before this patch gets commited ?

The following patch fixes the failures in
gnu.testlet.java.util.GregorianCalendar.first.  Basically, the
formulae are wrong, and the SimpleTimeZone fixes now reject the bogus
inputs.  I don't have the presence of mind right now to work out
better formulae or code, and this patch is no worse than what was
there.

Jerry

2004-06-08  Jerry Quinn  <jlquinn@optonline.net>

	* java/util/GregorianCalendar.java (computeTime):  Skip buggy
        formulae when we already know the answer.

--- GregorianCalendar.java.~1.19.~	2004-04-18 17:45:00.000000000 -0400
+++ GregorianCalendar.java	2004-06-08 01:52:57.000000000 -0400
@@ -441,8 +441,15 @@
       ? fields[ZONE_OFFSET] : zone.getRawOffset();
 
     int dayOfYear = daysOfYear[0] + daysOfYear[1];
-    int month = (dayOfYear * 5 + 3) / (31 + 30 + 31 + 30 + 31);
-    int day = (6 + (dayOfYear * 5 + 3) % (31 + 30 + 31 + 30 + 31)) / 5;
+    // FIXME: This formula isn't right, so check for month as a quick fix.  It
+    // doesn't compensate for leap years and puts day 30 in month 1
+    // instead of month 0.
+    int month = isSet[MONTH]
+	? fields[MONTH] : (dayOfYear * 5 + 3) / (31 + 30 + 31 + 30 + 31);
+    // FIXME: This formula isn't right, so check for day as a quick fix.  It
+    // doesn't compensate for leap years.
+    int day = isSet[DAY_OF_MONTH] ? fields[DAY_OF_MONTH]
+	: (6 + (dayOfYear * 5 + 3) % (31 + 30 + 31 + 30 + 31)) / 5;
     int weekday = ((int) (time / (24 * 60 * 60 * 1000L)) + THURSDAY) % 7;
     if (weekday <= 0)
       weekday += 7;


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