classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cp-patches] GregorianCalendar mess


From: Bryce McKinlay
Subject: Re: [cp-patches] GregorianCalendar mess
Date: Wed, 13 Oct 2004 15:50:51 -0400
User-agent: Mozilla Thunderbird 0.8 (X11/20040913)

Jeroen Frijters wrote:

Hi,

Working on this almost made my head explode and I'm sure it's still
broken, but I think it's little bit less broken than before.

Two of my Mauve java.util.Date tests turned out to be broken. I had used
Sun JDK 1.4.1 to calculate the reference dates, but it was buggy (fixed
in JDK 1.5).
+    int day = (int) (time / (24 * 60 * 60 * 1000L));
+    millisInDay = (int) (time % (24 * 60 * 60 * 1000L));
+    if (millisInDay < 0)
+      {
+    millisInDay += (24 * 60 * 60 * 1000);
+    day--;
+      }
+
+    int[] f = new int[FIELD_COUNT];
+    calculateDay(f, day, time - rawOffset >= gregorianCutover);
+    year = f[YEAR];
+    int month = f[MONTH];
+    day = f[DAY_OF_MONTH];
+    int weekday = f[DAY_OF_WEEK];
     int dstOffset = isSet[DST_OFFSET]
       ? fields[DST_OFFSET] : (zone.getOffset((year < 0) ? BC : AD,
                          (year < 0) ? 1 - year : year,


We need to find a way to avoid the "new int[]" in calculateTime(), as this is a pretty substantial performance regression. Perhaps a separate pass to normalize the fields is needed, which can be called by both calculateDay() and computeTime()? I think this could also simplify much of the other code, since it can assume the fields are already properly rolled over after each set() call, etc? Thanks for working on this!

Regards

Bryce





reply via email to

[Prev in Thread] Current Thread [Next in Thread]