commit-classpath
[Top][All Lists]
Advanced

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

Re: [kaffe] Re: GregorianCalendar fixes


From: Ito Kazumitsu
Subject: Re: [kaffe] Re: GregorianCalendar fixes
Date: Sat, 27 Dec 2003 03:18:05 +0900
User-agent: EMH/1.10.0 SEMI/1.13.7 (Awazu) FLIM/1.13.2 (Kasanui) Emacs/21.2 (i386-unknown-freebsd4.7) MULE/5.0 (SAKAKI)

Hi,

>>>>> ":" == Mark Wielaard <address@hidden> writes:

:> There is only one functional change left between kaffe and classpath in
:> computeFields():

:> -    fields[DAY_OF_WEEK_IN_MONTH] = (fields[DAY_OF_MONTH] + 12) / 7;
:> +    fields[DAY_OF_WEEK_IN_MONTH] = (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. 

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] = (fields[DAY_OF_MONTH] + 6) / 7;

seems to be correct.

[1]====================
From: Mark Wielaard <address@hidden>
To: address@hidden, address@hidden
Message-Id: <address@hidden>
Mime-Version: 1.0
X-Mailer: Ximian Evolution 1.4.5 
Date: Fri, 21 Nov 2003 17:14:35 +0100
Cc: address@hidden
Subject: GregorianCalendar fixes
X-BeenThere: address@hidden
X-Mailman-Version: 2.1.2
List-Unsubscribe: <http://mail.gnu.org/mailman/listinfo/classpath>,     
<mailto:address@hidden>
List-Archive: <http://mail.gnu.org/pipermail/classpath>
List-Post: <mailto:address@hidden>
List-Help: <mailto:address@hidden>
List-Subscribe: <http://mail.gnu.org/mailman/listinfo/classpath>,       
<mailto:address@hidden>

[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
===================================================================
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, 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;
 
[1.2 This is a digitally signed message part <application/pgp-signature (7bit)>]

[2  <text/plain; us-ascii (7bit)>]
_______________________________________________
Classpath mailing list
address@hidden
http://mail.gnu.org/mailman/listinfo/classpath

[2]=================================================================
From: Ito Kazumitsu <address@hidden>
To: address@hidden
In-reply-to: Ito Kazumitsu's message of "Mon, 28 Jul 2003 10:46:11 +0900"       
<address@hidden>
Subject: Re: [kaffe] Bug in Kaffe 1.0.7
User-Agent: SEMI/1.14.3 (Ushinoya) FLIM/1.14.3 (Unebigoryƍmae)
 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: address@hidden
X-Mailman-Version: 2.0.11
List-Help: <mailto:address@hidden>
List-Post: <mailto:address@hidden>
List-Subscribe: <http://kaffe.org/cgi-bin/mailman/listinfo/kaffe>,      
<mailto:address@hidden>
List-Unsubscribe: <http://kaffe.org/cgi-bin/mailman/listinfo/kaffe>,    
<mailto:address@hidden>
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 <address@hidden> 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:
> 
>    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 = (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;
 

_______________________________________________
kaffe mailing list
address@hidden
http://kaffe.org/cgi-bin/mailman/listinfo/kaffe




reply via email to

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