[kaffe] Re: GregorianCalendar fixes
Ito Kazumitsu
kaz@maczuka.gcd.org
Fri Dec 26 10:20:05 2003
Hi,
>>>>> ":" =3D=3D Mark Wielaard <mark@klomp.org> writes:
:> There is only one functional change left between kaffe and classpath in
:> computeFields():
:> - fields[DAY_OF_WEEK_IN_MONTH] =3D (fields[DAY_OF_MONTH] + 12) / 7;
:> + fields[DAY_OF_WEEK_IN_MONTH] =3D (fields[DAY_OF_MONTH] + 6) / 7;
:> Haven't looked at who is right here, so won't merge.
This change about DAY_OF_WEEK_IN_MONTH was in Mark's patch [1] (see below)
but was not in my original patch [2] (see below) posted to the kaffe mailing
list. This patch seemes to have been introduced by analogy with the
patch about WEEK_OF_MONTH.=20
But Sun's API document says:
Unlike WEEK_OF_MONTH and WEEK_OF_YEAR, this field's value does not
depend on getFirstDayOfWeek() or getMinimalDaysInFirstWeek().
DAY_OF_MONTH 1 through 7 always correspond to DAY_OF_WEEK_IN_MONTH 1;
8 through 14 correspond to DAY_OF_WEEK_IN_MONTH 2, and so on.
In this respect,
fields[DAY_OF_WEEK_IN_MONTH] =3D (fields[DAY_OF_MONTH] + 6) / 7;
seems to be correct.
[1]=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
From: Mark Wielaard <mark@klomp.org>
To: classpath@gnu.org, kaffe@kaffe.org
Message-Id: <1069431275.2861.580.camel@elsschot.wildebeest.org>
Mime-Version: 1.0
X-Mailer: Ximian Evolution 1.4.5=20
Date: Fri, 21 Nov 2003 17:14:35 +0100
Cc: java-patches@gcc.gnu.org
Subject: GregorianCalendar fixes
X-BeenThere: classpath@gnu.org
X-Mailman-Version: 2.1.2
List-Unsubscribe: <http://mail.gnu.org/mailman/listinfo/classpath>, <mailto=
:classpath-request@gnu.org?subject=3Dunsubscribe>
List-Archive: <http://mail.gnu.org/pipermail/classpath>
List-Post: <mailto:classpath@gnu.org>
List-Help: <mailto:classpath-request@gnu.org?subject=3Dhelp>
List-Subscribe: <http://mail.gnu.org/mailman/listinfo/classpath>, <mailto:c=
lasspath-request@gnu.org?subject=3Dsubscribe>
[1 <multipart/signed (7bit)>]
[1.1 <multipart/mixed (7bit)>]
[1.1.1 <text/plain (quoted-printable)>]
Hi,
Since I am not a GregorianCalendar expert I was hoping that someone
could review the following patch which I have in my tree from Ito
Kazumitsu. He and I wrote a couple of mauve test cases which are fixed
by this and I see no new failures. But people didn't seem to be
completely comfortable with it back in Augustus/September. It would be
nice if we could create even more test cases to make sure that nothing
else breaks and to have a ChangeLog entry for this patch (Ito?). Don't
really have have time to learn about Calendars so I am just re-posting
this patch in the hope that someone can review it.
Thanks,
Mark
[1.1.2 GregorianCalendar.patch <text/x-patch; ISO-8859-1 (base64)>]
Index: java/util/GregorianCalendar.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvsroot/classpath/classpath/java/util/GregorianCalendar.java,v
retrieving revision 1.20
diff -u -r1.20 GregorianCalendar.java
--- java/util/GregorianCalendar.java 12 Aug 2003 13:41:27 -0000 1.20
+++ java/util/GregorianCalendar.java 21 Nov 2003 16:11:56 -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, In=
c.
=20
This file is part of GNU Classpath.
=20
@@ -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.=20
int gregOffset =3D (year / 400) - (year / 100) + 2;
- if (isLeapYear (year, true) && dayOfYear < 31 + 29)
+ if (isLeapYear (year, true))
--gregOffset;
time +=3D gregOffset * (24 * 60 * 60 * 1000L);
}
@@ -604,12 +606,12 @@
calculateDay(++day, gregorian);
}
=20
- fields[DAY_OF_WEEK_IN_MONTH] =3D (fields[DAY_OF_MONTH] + 6) / 7;
+ fields[DAY_OF_WEEK_IN_MONTH] =3D (fields[DAY_OF_MONTH] + 12) / 7;
=20
// which day of the week are we (0..6), relative to getFirstDayOfWeek
int relativeWeekday =3D (7 + fields[DAY_OF_WEEK] - getFirstDayOfWeek()=
) % 7;
=20
- fields[WEEK_OF_MONTH] =3D (fields[DAY_OF_MONTH] - relativeWeekday + 6)=
/ 7;
+ fields[WEEK_OF_MONTH] =3D (fields[DAY_OF_MONTH] - relativeWeekday + 12=
) / 7;
=20
int weekOfYear =3D (fields[DAY_OF_YEAR] - relativeWeekday + 6) / 7;
=20
[1.2 This is a digitally signed message part <application/pgp-signature (7b=
it)>]
[2 <text/plain; us-ascii (7bit)>]
_______________________________________________
Classpath mailing list
Classpath@gnu.org
http://mail.gnu.org/mailman/listinfo/classpath
[2]=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
From: Ito Kazumitsu <ito.kazumitsu@hitachi-cable.co.jp>
To: kaffe@kaffe.org
In-reply-to: Ito Kazumitsu's message of "Mon, 28 Jul 2003 10:46:11 +0900" <=
200307280146.h6S1kBq16305@sm1.hitachi-cable.co.jp>
Subject: Re: [kaffe] Bug in Kaffe 1.0.7
User-Agent: SEMI/1.14.3 (Ushinoya) FLIM/1.14.3 (Unebigory=F2mae)
APEL/10.3 Emacs/20.7 (i386-*-windows98.2222) MULE/4.1 (AOI) Meadow/1.14
(AWSAKA:62)
MIME-Version: 1.0 (generated by SEMI 1.14.3 - "Ushinoya")
X-BeenThere: kaffe@kaffe.org
X-Mailman-Version: 2.0.11
List-Help: <mailto:kaffe-request@kaffe.org?subject=3Dhelp>
List-Post: <mailto:kaffe@kaffe.org>
List-Subscribe: <http://kaffe.org/cgi-bin/mailman/listinfo/kaffe>, <mailto:=
kaffe-request@kaffe.org?subject=3Dsubscribe>
List-Unsubscribe: <http://kaffe.org/cgi-bin/mailman/listinfo/kaffe>, <mailt=
o:kaffe-request@kaffe.org?subject=3Dunsubscribe>
List-Archive: <http://kaffe.org/pipermail/kaffe/>
X-Original-Date: Mon, 28 Jul 2003 13:31:38 +0900
Date: Mon, 28 Jul 2003 13:31:38 +0900
In message "Re: [kaffe] Bug in Kaffe 1.0.7"
on 03/07/28, Ito Kazumitsu <ito.kazumitsu@hitachi-cable.co.jp> writes:
> The attached program prints week-related values for the dates
> from Jan 1 2000 to Dec 31 2003. Both GNU Classpath and Sun's
> JDK give identical results for the following months:
>=20
> Oct 2000, Apr 2001, Jul 2001, Sep 2002, Dec 2002, Jun 2003
These months are special in that the first day of the month is Sunday.
The attached patch makes GNU classpath's java.util.Calendar behave
almost similarly to Sun's JDK except that the former returns 53 or
54 as the last week of the year but the latter returns 1. I think
that returning 1 as the last week of the year may be a bug of Sun's
JDK.
I will submit this patch to the GNU Classpath mailing list.
--- java/util/GregorianCalendar.java.orig Sun Mar 24 01:10:15 2002
+++ java/util/GregorianCalendar.java Mon Jul 28 11:53:16 2003
@@ -599,7 +599,7 @@
// which day of the week are we (0..6), relative to getFirstDayOfWeek
int relativeWeekday =3D (7 + fields[DAY_OF_WEEK] - getFirstDayOfWeek()=
) % 7;
=20
- fields[WEEK_OF_MONTH] =3D (fields[DAY_OF_MONTH] - relativeWeekday + 6)=
/ 7;
+ fields[WEEK_OF_MONTH] =3D (fields[DAY_OF_MONTH] - relativeWeekday + 12=
) / 7;
=20
int weekOfYear =3D (fields[DAY_OF_YEAR] - relativeWeekday + 6) / 7;
=20
_______________________________________________
kaffe mailing list
kaffe@kaffe.org
http://kaffe.org/cgi-bin/mailman/listinfo/kaffe