GregorianCalendar.java (computeTime): Skip buggy formulae when we already know the answer.
2004-06-11 Jerry Quinn <jlquinn@optonline.net> * java/util/GregorianCalendar.java (computeTime): Skip buggy formulae when we already know the answer. * java/util/SimpleTimeZone.java (serialVersionOnStream): Bump to 2. (setStartRule,setEndRule): Don't take abs of day number. (getOffset): Clarify docs. Add argument checks. (isBefore): Take abs of day number in DOW_LE_DOM_MODE. (equals,hasSameRules,toString,readObject): Use startTimeMode and endTimeMode. From-SVN: r82962
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
/* java.util.GregorianCalendar
|
||||
Copyright (C) 1998, 1999, 2001, 2002, 2003 Free Software Foundation, Inc.
|
||||
Copyright (C) 1998, 1999, 2001, 2002, 2003, 2004
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@@ -441,8 +442,15 @@ public class GregorianCalendar extends Calendar
|
||||
? fields[ZONE_OFFSET] : zone.getRawOffset();
|
||||
|
||||
int dayOfYear = daysOfYear[0] + daysOfYear[1];
|
||||
int month = (dayOfYear * 5 + 3) / (31 + 30 + 31 + 30 + 31);
|
||||
int day = (6 + (dayOfYear * 5 + 3) % (31 + 30 + 31 + 30 + 31)) / 5;
|
||||
// This formula isn't right, so check for month as a quick fix.
|
||||
// It doesn't compensate for leap years and puts day 30 in month 1
|
||||
// instead of month 0.
|
||||
int month = isSet[MONTH]
|
||||
? fields[MONTH] : (dayOfYear * 5 + 3) / (31 + 30 + 31 + 30 + 31);
|
||||
// This formula isn't right, so check for day as a quick fix. It
|
||||
// doesn't compensate for leap years, either.
|
||||
int day = isSet[DAY_OF_MONTH] ? fields[DAY_OF_MONTH]
|
||||
: (6 + (dayOfYear * 5 + 3) % (31 + 30 + 31 + 30 + 31)) / 5;
|
||||
int weekday = ((int) (time / (24 * 60 * 60 * 1000L)) + THURSDAY) % 7;
|
||||
if (weekday <= 0)
|
||||
weekday += 7;
|
||||
|
||||
Reference in New Issue
Block a user