Commit b9f065be by Jerry Quinn Committed by Jerry Quinn

SimpleTimeZone.java: Reverting my last change until I can fix it properly.

2004-05-27  Jerry Quinn  <jlquinn@optonline.net>

	* java/util/SimpleTimeZone.java: Reverting my last change until I
	can fix it properly.

From-SVN: r82340
parent 13f05fd0
2004-05-27 Jerry Quinn <jlquinn@optonline.net>
* java/util/SimpleTimeZone.java: Reverting my last change until I
can fix it properly.
2004-05-27 Michael Koch <konqueror@gmx.de> 2004-05-27 Michael Koch <konqueror@gmx.de>
* javax/swing/JPopupMenu.java * javax/swing/JPopupMenu.java
......
...@@ -234,7 +234,7 @@ public class SimpleTimeZone extends TimeZone ...@@ -234,7 +234,7 @@ public class SimpleTimeZone extends TimeZone
* @serial * @serial
* @since JDK1.1.4 * @since JDK1.1.4
*/ */
private int serialVersionOnStream = 2; private int serialVersionOnStream = 1;
private static final long serialVersionUID = -403250971215465050L; private static final long serialVersionUID = -403250971215465050L;
...@@ -477,7 +477,9 @@ public class SimpleTimeZone extends TimeZone ...@@ -477,7 +477,9 @@ public class SimpleTimeZone extends TimeZone
{ {
this.startMode = checkRule(month, day, dayOfWeek); this.startMode = checkRule(month, day, dayOfWeek);
this.startMonth = month; this.startMonth = month;
this.startDay = day; // FIXME: XXX: JDK 1.2 allows negative values and has 2 new variations
// of this method.
this.startDay = Math.abs(day);
this.startDayOfWeek = Math.abs(dayOfWeek); this.startDayOfWeek = Math.abs(dayOfWeek);
if (this.startTimeMode == WALL_TIME || this.startTimeMode == STANDARD_TIME) if (this.startTimeMode == WALL_TIME || this.startTimeMode == STANDARD_TIME)
this.startTime = time; this.startTime = time;
...@@ -568,7 +570,9 @@ public class SimpleTimeZone extends TimeZone ...@@ -568,7 +570,9 @@ public class SimpleTimeZone extends TimeZone
{ {
this.endMode = checkRule(month, day, dayOfWeek); this.endMode = checkRule(month, day, dayOfWeek);
this.endMonth = month; this.endMonth = month;
this.endDay = day; // FIXME: XXX: JDK 1.2 allows negative values and has 2 new variations
// of this method.
this.endDay = Math.abs(day);
this.endDayOfWeek = Math.abs(dayOfWeek); this.endDayOfWeek = Math.abs(dayOfWeek);
if (this.endTimeMode == WALL_TIME) if (this.endTimeMode == WALL_TIME)
this.endTime = time; this.endTime = time;
...@@ -656,33 +660,21 @@ public class SimpleTimeZone extends TimeZone ...@@ -656,33 +660,21 @@ public class SimpleTimeZone extends TimeZone
* <code>offset = cal.get(Calendar.ZONE_OFFSET) * <code>offset = cal.get(Calendar.ZONE_OFFSET)
* + cal.get(Calendar.DST_OFFSET);</code> * + cal.get(Calendar.DST_OFFSET);</code>
* *
* This version doesn't suffer this inaccuracy. * You could also use in
* *
* The arguments don't follow the approach for setting start and end rules. * This version doesn't suffer this inaccuracy.
* The day must be a positive number and dayOfWeek must be a positive value
* from Calendar. dayOfWeek is redundant, but must match the other values
* or an inaccurate result may be returned.
* *
* @param era the era of the given date * @param era the era of the given date
* @param year the year of the given date * @param year the year of the given date
* @param month the month of the given date, 0 for January. * @param month the month of the given date, 0 for January.
* @param day the day of month * @param day the day of month
* @param dayOfWeek the day of week; this must match the other fields. * @param dayOfWeek the day of week; this must be matching the
* other fields.
* @param millis the millis in the day (in local standard time) * @param millis the millis in the day (in local standard time)
* @return the time zone offset in milliseconds. * @return the time zone offset in milliseconds. */
* @throws IllegalArgumentException if arguments are incorrect.
*/
public int getOffset(int era, int year, int month, public int getOffset(int era, int year, int month,
int day, int dayOfWeek, int millis) int day, int dayOfWeek, int millis)
{ {
int daysInMonth = getDaysInMonth(month, 1);
if (day < 1 || day > daysInMonth)
throw new IllegalArgumentException("day out of range");
if (dayOfWeek < Calendar.SUNDAY || dayOfWeek > Calendar.SATURDAY)
throw new IllegalArgumentException("dayOfWeek out of range");
if (month < Calendar.JANUARY || month > Calendar.DECEMBER)
throw new IllegalArgumentException("month out of range");
// This method is called by Calendar, so we mustn't use that class. // This method is called by Calendar, so we mustn't use that class.
int daylightSavings = 0; int daylightSavings = 0;
if (useDaylight && era == GregorianCalendar.AD && year >= startYear) if (useDaylight && era == GregorianCalendar.AD && year >= startYear)
...@@ -793,7 +785,7 @@ public class SimpleTimeZone extends TimeZone ...@@ -793,7 +785,7 @@ public class SimpleTimeZone extends TimeZone
/** /**
* Checks if the date given in calXXXX, is before the change between * Checks if the date given in calXXXX, is before the change between
* dst and standard time. * dst and standard time.
* @param calYear the year of the date to check (for leap day checking). * @param calYear the year of the date to check (for leap day cheking).
* @param calMonth the month of the date to check. * @param calMonth the month of the date to check.
* @param calDay the day of month of the date to check. * @param calDay the day of month of the date to check.
* @param calDayOfWeek the day of week of the date to check. * @param calDayOfWeek the day of week of the date to check.
...@@ -878,7 +870,7 @@ public class SimpleTimeZone extends TimeZone ...@@ -878,7 +870,7 @@ public class SimpleTimeZone extends TimeZone
case DOW_LE_DOM_MODE: case DOW_LE_DOM_MODE:
// The greatest sunday before or equal December, 12 // The greatest sunday before or equal December, 12
// is the same as smallest sunday after or equal December, 6. // is the same as smallest sunday after or equal December, 6.
day = Math.abs(day) - 6; day -= 6;
case DOW_GE_DOM_MODE: case DOW_GE_DOM_MODE:
...@@ -939,12 +931,10 @@ public class SimpleTimeZone extends TimeZone ...@@ -939,12 +931,10 @@ public class SimpleTimeZone extends TimeZone
&& startDay == zone.startDay && startDay == zone.startDay
&& startDayOfWeek == zone.startDayOfWeek && startDayOfWeek == zone.startDayOfWeek
&& startTime == zone.startTime && startTime == zone.startTime
&& startTimeMode == zone.startTimeMode
&& endMonth == zone.endMonth && endMonth == zone.endMonth
&& endDay == zone.endDay && endDay == zone.endDay
&& endDayOfWeek == zone.endDayOfWeek && endDayOfWeek == zone.endDayOfWeek
&& endTime == zone.endTime && endTime == zone.endTime);
&& endTimeMode == zone.endTimeMode);
} }
/** /**
...@@ -972,12 +962,9 @@ public class SimpleTimeZone extends TimeZone ...@@ -972,12 +962,9 @@ public class SimpleTimeZone extends TimeZone
&& startDay == zone.startDay && startDay == zone.startDay
&& startDayOfWeek == zone.startDayOfWeek && startDayOfWeek == zone.startDayOfWeek
&& startTime == zone.startTime && startTime == zone.startTime
&& startTimeMode == zone.startTimeMode
&& endMonth == zone.endMonth && endMonth == zone.endMonth
&& endDay == zone.endDay && endDay == zone.endDay
&& endDayOfWeek == zone.endDayOfWeek && endDayOfWeek == zone.endDayOfWeek && endTime == zone.endTime);
&& endTime == zone.endTime
&& endTimeMode == zone.endTimeMode);
} }
/** /**
...@@ -1000,14 +987,11 @@ public class SimpleTimeZone extends TimeZone ...@@ -1000,14 +987,11 @@ public class SimpleTimeZone extends TimeZone
+ ",startDay=" + startDay + ",startDay=" + startDay
+ ",startDayOfWeek=" + startDayOfWeek + ",startDayOfWeek=" + startDayOfWeek
+ ",startTime=" + startTime + ",startTime=" + startTime
+ ",startTimeMode=" + startTimeMode
+ ",endMode=" + endMode + ",endMode=" + endMode
+ ",endMonth=" + endMonth + ",endMonth=" + endMonth
+ ",endDay=" + endDay + ",endDay=" + endDay
+ ",endDayOfWeek=" + endDayOfWeek + ",endDayOfWeek=" + endDayOfWeek
+ ",endTime=" + endTime + ",endTime=" + endTime : "") + "]";
+ ",endTimeMode=" + endTimeMode
: "") + "]";
} }
/** /**
...@@ -1024,9 +1008,7 @@ public class SimpleTimeZone extends TimeZone ...@@ -1024,9 +1008,7 @@ public class SimpleTimeZone extends TimeZone
dstSavings = 60 * 60 * 1000; dstSavings = 60 * 60 * 1000;
endMode = DOW_IN_MONTH_MODE; endMode = DOW_IN_MONTH_MODE;
startMode = DOW_IN_MONTH_MODE; startMode = DOW_IN_MONTH_MODE;
startTimeMode = WALL_TIME; serialVersionOnStream = 1;
endTimeMode = WALL_TIME;
serialVersionOnStream = 2;
} }
else else
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment