Even more fixes, oh yes. But now I don't know of any more bugs. So this is it for now.
2005-02-13 Sven de Marothy <[EMAIL PROTECTED]> * java/util/Calendar.java (clear): Dates should clear to local time. * java/util/GregorianCalendar.java (computeTime): Fix priority problem with DAY_OF_WEEK, Handle non-sunday-startig weeks and minimumDaysInFirstWeek.
Index: java/util/Calendar.java =================================================================== RCS file: /cvsroot/classpath/classpath/java/util/Calendar.java,v retrieving revision 1.36 diff -u -r1.36 Calendar.java --- java/util/Calendar.java 6 Feb 2005 00:20:57 -0000 1.36 +++ java/util/Calendar.java 13 Feb 2005 18:15:37 -0000 @@ -828,16 +828,10 @@ isTimeSet = false; areFieldsSet = false; int zoneOffs = zone.getRawOffset(); - - int hour = zoneOffs / (60 * 60 * 1000); - int minute = (zoneOffs - 60 * 60 * 1000 * hour) / (60 * 1000); - int seconds = (zoneOffs - 60 * 60 * 1000 * hour - 60 * 1000 * minute) / 1000; - int millis = zoneOffs - 60 * 60 * 1000 * hour - 60 * 1000 * minute - - seconds * 1000; int[] tempFields = { - 1, 1970, JANUARY, 1, 1, 1, 1, THURSDAY, 1, AM, hour, - hour, minute, seconds, millis, zoneOffs, 0 + 1, 1970, JANUARY, 1, 1, 1, 1, THURSDAY, 1, AM, 0, 0, 0, + 0, 0, zoneOffs, 0 }; fields = tempFields; for (int i = 0; i < FIELD_COUNT; i++) Index: java/util/GregorianCalendar.java =================================================================== RCS file: /cvsroot/classpath/classpath/java/util/GregorianCalendar.java,v retrieving revision 1.37 diff -u -r1.37 GregorianCalendar.java --- java/util/GregorianCalendar.java 6 Feb 2005 00:20:57 -0000 1.37 +++ java/util/GregorianCalendar.java 13 Feb 2005 18:15:37 -0000 @@ -369,8 +369,25 @@ private int getFirstDayOfMonth(int year, int month) { int[] dayCount = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 }; - int dayOfYear = dayCount[month] + 1; + if (month > 11) + { + year += (month / 12); + month = month % 12; + } + + if (month < 0) + { + year += (int) month / 12; + month = month % 12; + if (month < 0) + { + month += 12; + year--; + } + } + + int dayOfYear = dayCount[month] + 1; if (month > 1) if (isLeapYear(year)) dayOfYear++; @@ -508,22 +525,28 @@ if (! isLenient()) nonLeniencyCheck(); - if (! isSet[MONTH]) + if (! isSet[MONTH] && (! isSet[DAY_OF_WEEK] || isSet[WEEK_OF_YEAR])) { // 5: YEAR + DAY_OF_WEEK + WEEK_OF_YEAR - if (isSet[DAY_OF_WEEK] || isSet[WEEK_OF_YEAR]) + if (isSet[WEEK_OF_YEAR]) { int first = getFirstDayOfMonth(year, 0); - int offs; - if ((8 - first) >= getMinimalDaysInFirstWeek()) - // start counting on first week - offs = 1; - else - offs = 1 + (8 - first); + int offs = 1; + int daysInFirstWeek = getFirstDayOfWeek() - first; + if (daysInFirstWeek <= 0) + daysInFirstWeek += 7; + if (daysInFirstWeek < getMinimalDaysInFirstWeek()) + offs += daysInFirstWeek; + else + offs -= 7 - daysInFirstWeek; month = 0; day = offs + 7 * (fields[WEEK_OF_YEAR] - 1); - day += fields[DAY_OF_WEEK] - first; + offs = fields[DAY_OF_WEEK] - getFirstDayOfWeek(); + + if (offs < 0) + offs += 7; + day += offs; } else { @@ -549,8 +572,21 @@ } else { // 2: YEAR + MONTH + WEEK_OF_MONTH + DAY_OF_WEEK - day = 1 + 7 * (fields[WEEK_OF_MONTH] - 1); - day += fields[DAY_OF_WEEK] - first; + int offs = 1; + int daysInFirstWeek = getFirstDayOfWeek() - first; + if (daysInFirstWeek <= 0) + daysInFirstWeek += 7; + + if (daysInFirstWeek < getMinimalDaysInFirstWeek()) + offs += daysInFirstWeek; + else + offs -= 7 - daysInFirstWeek; + + day = offs + 7 * (fields[WEEK_OF_MONTH] - 1); + offs = fields[DAY_OF_WEEK] - getFirstDayOfWeek(); + if (offs < 0) + offs += 7; + day += offs; } }
_______________________________________________ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches