[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
GregorianCalendar fixes
From: |
Mark Wielaard |
Subject: |
GregorianCalendar fixes |
Date: |
Fri, 21 Nov 2003 17:14:35 +0100 |
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
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;
signature.asc
Description: This is a digitally signed message part
- GregorianCalendar fixes,
Mark Wielaard <=
- Re: GregorianCalendar fixes, Andreas Tobler, 2003/11/24
- Re: GregorianCalendar fixes, Ito Kazumitsu, 2003/11/24
- Re: GregorianCalendar fixes, Mark Wielaard, 2003/11/25
- Re: GregorianCalendar fixes, Ito Kazumitsu, 2003/11/27
- Re: GregorianCalendar fixes, Stephen Crawley, 2003/11/27
- Re: GregorianCalendar fixes, Mark Wielaard, 2003/11/27
- Re: GregorianCalendar fixes, Stephen Crawley, 2003/11/27
- Re: GregorianCalendar fixes, Mark Wielaard, 2003/11/28
- Re: GregorianCalendar fixes, Dalibor Topic, 2003/11/28
- Re: GregorianCalendar fixes, Chris Gray, 2003/11/28