1 Clazz.declarePackage ("java.util");
\r
2 Clazz.load (["java.util.TimeZone", "jssun.util.calendar.CalendarSystem", "$.Gregorian"], "java.util.SimpleTimeZone", ["java.lang.IllegalArgumentException", "jssun.util.calendar.CalendarUtils"], function () {
\r
3 c$ = Clazz.decorateAsClass (function () {
\r
6 this.startDayOfWeek = 0;
\r
8 this.startTimeMode = 0;
\r
11 this.endDayOfWeek = 0;
\r
13 this.endTimeMode = 0;
\r
16 this.useDaylight = false;
\r
17 this.monthLength = null;
\r
20 this.dstSavings = 0;
\r
22 this.cacheStart = 0;
\r
24 this.serialVersionOnStream = 2;
\r
25 Clazz.instantialize (this, arguments);
\r
26 }, java.util, "SimpleTimeZone", java.util.TimeZone);
\r
27 Clazz.prepareFields (c$, function () {
\r
28 this.monthLength = java.util.SimpleTimeZone.staticMonthLength;
\r
30 Clazz.makeConstructor (c$,
\r
31 function (rawOffset, ID) {
\r
32 Clazz.superConstructor (this, java.util.SimpleTimeZone, []);
\r
33 this.rawOffset = rawOffset;
\r
35 this.dstSavings = 3600000;
\r
37 Clazz.makeConstructor (c$,
\r
38 function (rawOffset, ID, startMonth, startDay, startDayOfWeek, startTime, endMonth, endDay, endDayOfWeek, endTime) {
\r
39 this.construct (rawOffset, ID, startMonth, startDay, startDayOfWeek, startTime, 0, endMonth, endDay, endDayOfWeek, endTime, 0, 3600000);
\r
40 }, "~N,~S,~N,~N,~N,~N,~N,~N,~N,~N");
\r
41 Clazz.makeConstructor (c$,
\r
42 function (rawOffset, ID, startMonth, startDay, startDayOfWeek, startTime, endMonth, endDay, endDayOfWeek, endTime, dstSavings) {
\r
43 this.construct (rawOffset, ID, startMonth, startDay, startDayOfWeek, startTime, 0, endMonth, endDay, endDayOfWeek, endTime, 0, dstSavings);
\r
44 }, "~N,~S,~N,~N,~N,~N,~N,~N,~N,~N,~N");
\r
45 Clazz.makeConstructor (c$,
\r
46 function (rawOffset, ID, startMonth, startDay, startDayOfWeek, startTime, startTimeMode, endMonth, endDay, endDayOfWeek, endTime, endTimeMode, dstSavings) {
\r
47 Clazz.superConstructor (this, java.util.SimpleTimeZone, []);
\r
49 this.rawOffset = rawOffset;
\r
50 this.startMonth = startMonth;
\r
51 this.startDay = startDay;
\r
52 this.startDayOfWeek = startDayOfWeek;
\r
53 this.startTime = startTime;
\r
54 this.startTimeMode = startTimeMode;
\r
55 this.endMonth = endMonth;
\r
56 this.endDay = endDay;
\r
57 this.endDayOfWeek = endDayOfWeek;
\r
58 this.endTime = endTime;
\r
59 this.endTimeMode = endTimeMode;
\r
60 this.dstSavings = dstSavings;
\r
61 this.decodeRules ();
\r
62 if (dstSavings <= 0) {
\r
63 throw new IllegalArgumentException ("Illegal daylight saving value: " + dstSavings);
\r
64 }}, "~N,~S,~N,~N,~N,~N,~N,~N,~N,~N,~N,~N,~N");
\r
65 Clazz.defineMethod (c$, "setStartYear",
\r
67 this.startYear = year;
\r
68 this.invalidateCache ();
\r
70 Clazz.defineMethod (c$, "setStartRule",
\r
71 function (startMonth, startDay, startDayOfWeek, startTime) {
\r
72 this.startMonth = startMonth;
\r
73 this.startDay = startDay;
\r
74 this.startDayOfWeek = startDayOfWeek;
\r
75 this.startTime = startTime;
\r
76 this.startTimeMode = 0;
\r
77 this.decodeStartRule ();
\r
78 this.invalidateCache ();
\r
80 Clazz.defineMethod (c$, "setStartRule",
\r
81 function (startMonth, startDay, startTime) {
\r
82 this.setStartRule (startMonth, startDay, 0, startTime);
\r
84 Clazz.defineMethod (c$, "setStartRule",
\r
85 function (startMonth, startDay, startDayOfWeek, startTime, after) {
\r
87 this.setStartRule (startMonth, startDay, -startDayOfWeek, startTime);
\r
89 this.setStartRule (startMonth, -startDay, -startDayOfWeek, startTime);
\r
90 }}, "~N,~N,~N,~N,~B");
\r
91 Clazz.defineMethod (c$, "setEndRule",
\r
92 function (endMonth, endDay, endDayOfWeek, endTime) {
\r
93 this.endMonth = endMonth;
\r
94 this.endDay = endDay;
\r
95 this.endDayOfWeek = endDayOfWeek;
\r
96 this.endTime = endTime;
\r
97 this.endTimeMode = 0;
\r
98 this.decodeEndRule ();
\r
99 this.invalidateCache ();
\r
101 Clazz.defineMethod (c$, "setEndRule",
\r
102 function (endMonth, endDay, endTime) {
\r
103 this.setEndRule (endMonth, endDay, 0, endTime);
\r
105 Clazz.defineMethod (c$, "setEndRule",
\r
106 function (endMonth, endDay, endDayOfWeek, endTime, after) {
\r
108 this.setEndRule (endMonth, endDay, -endDayOfWeek, endTime);
\r
110 this.setEndRule (endMonth, -endDay, -endDayOfWeek, endTime);
\r
111 }}, "~N,~N,~N,~N,~B");
\r
112 Clazz.defineMethod (c$, "getOffset",
\r
114 return this.getOffsets (date, null);
\r
116 Clazz.overrideMethod (c$, "getOffsets",
\r
117 function (date, offsets) {
\r
118 var offset = this.rawOffset;
\r
119 computeOffset : if (this.useDaylight) {
\r
121 if (this.cacheStart != 0) {
\r
122 if (date >= this.cacheStart && date < this.cacheEnd) {
\r
123 offset += this.dstSavings;
\r
124 break computeOffset;
\r
125 }}}var cal = date >= -12219292800000 ? java.util.SimpleTimeZone.gcal : jssun.util.calendar.CalendarSystem.forName ("julian");
\r
126 var cdate = cal.newCalendarDate (java.util.TimeZone.NO_TIMEZONE);
\r
127 cal.getCalendarDate (date + this.rawOffset, cdate);
\r
128 var year = cdate.getNormalizedYear ();
\r
129 if (year >= this.startYear) {
\r
130 cdate.setTimeOfDay (0, 0, 0, 0);
\r
131 offset = this.getOffset (cal, cdate, year, date);
\r
132 }}if (offsets != null) {
\r
133 offsets[0] = this.rawOffset;
\r
134 offsets[1] = offset - this.rawOffset;
\r
137 Clazz.defineMethod (c$, "getOffset",
\r
138 function (era, year, month, day, dayOfWeek, millis) {
\r
139 if (era != 1 && era != 0) {
\r
140 throw new IllegalArgumentException ("Illegal era " + era);
\r
144 }if (y >= 292278994) {
\r
145 y = 2800 + y % 2800;
\r
146 } else if (y <= -292269054) {
\r
147 y = jssun.util.calendar.CalendarUtils.mod (y, 28);
\r
148 }var m = month + 1;
\r
149 var cal = java.util.SimpleTimeZone.gcal;
\r
150 var cdate = cal.newCalendarDate (java.util.TimeZone.NO_TIMEZONE);
\r
151 cdate.setDate (y, m, day);
\r
152 var time = cal.getTime (cdate);
\r
153 time += millis - this.rawOffset;
\r
154 if (time < -12219292800000) {
\r
155 cal = jssun.util.calendar.CalendarSystem.forName ("julian");
\r
156 cdate = cal.newCalendarDate (java.util.TimeZone.NO_TIMEZONE);
\r
157 cdate.setNormalizedDate (y, m, day);
\r
158 time = cal.getTime (cdate) + millis - this.rawOffset;
\r
159 }if ((cdate.getNormalizedYear () != y) || (cdate.getMonth () != m) || (cdate.getDayOfMonth () != day) || (dayOfWeek < 1 || dayOfWeek > 7) || (millis < 0 || millis >= (86400000))) {
\r
160 throw new IllegalArgumentException ();
\r
161 }if (!this.useDaylight || year < this.startYear || era != 1) {
\r
162 return this.rawOffset;
\r
163 }return this.getOffset (cal, cdate, y, time);
\r
164 }, "~N,~N,~N,~N,~N,~N");
\r
165 Clazz.defineMethod (c$, "getOffset",
\r
166 function (cal, cdate, year, time) {
\r
168 if (this.cacheStart != 0) {
\r
169 if (time >= this.cacheStart && time < this.cacheEnd) {
\r
170 return this.rawOffset + this.dstSavings;
\r
171 }if (year == this.cacheYear) {
\r
172 return this.rawOffset;
\r
173 }}}var start = this.getStart (cal, cdate, year);
\r
174 var end = this.getEnd (cal, cdate, year);
\r
175 var offset = this.rawOffset;
\r
176 if (start <= end) {
\r
177 if (time >= start && time < end) {
\r
178 offset += this.dstSavings;
\r
180 this.cacheYear = year;
\r
181 this.cacheStart = start;
\r
182 this.cacheEnd = end;
\r
185 start = this.getStart (cal, cdate, year - 1);
\r
186 if (time >= start) {
\r
187 offset += this.dstSavings;
\r
188 }} else if (time >= start) {
\r
189 end = this.getEnd (cal, cdate, year + 1);
\r
191 offset += this.dstSavings;
\r
192 }}if (start <= end) {
\r
194 this.cacheYear = this.startYear - 1;
\r
195 this.cacheStart = start;
\r
196 this.cacheEnd = end;
\r
198 }, "jssun.util.calendar.BaseCalendar,jssun.util.calendar.BaseCalendar.Date,~N,~N");
\r
199 Clazz.defineMethod (c$, "getStart",
\r
200 function (cal, cdate, year) {
\r
201 var time = this.startTime;
\r
202 if (this.startTimeMode != 2) {
\r
203 time -= this.rawOffset;
\r
204 }return this.getTransition (cal, cdate, this.startMode, year, this.startMonth, this.startDay, this.startDayOfWeek, time);
\r
205 }, "jssun.util.calendar.BaseCalendar,jssun.util.calendar.BaseCalendar.Date,~N");
\r
206 Clazz.defineMethod (c$, "getEnd",
\r
207 function (cal, cdate, year) {
\r
208 var time = this.endTime;
\r
209 if (this.endTimeMode != 2) {
\r
210 time -= this.rawOffset;
\r
211 }if (this.endTimeMode == 0) {
\r
212 time -= this.dstSavings;
\r
213 }return this.getTransition (cal, cdate, this.endMode, year, this.endMonth, this.endDay, this.endDayOfWeek, time);
\r
214 }, "jssun.util.calendar.BaseCalendar,jssun.util.calendar.BaseCalendar.Date,~N");
\r
215 Clazz.defineMethod (c$, "getTransition",
\r
216 function (cal, cdate, mode, year, month, dayOfMonth, dayOfWeek, timeOfDay) {
\r
217 cdate.setNormalizedYear (year);
\r
218 cdate.setMonth (month + 1);
\r
221 cdate.setDayOfMonth (dayOfMonth);
\r
224 cdate.setDayOfMonth (1);
\r
225 if (dayOfMonth < 0) {
\r
226 cdate.setDayOfMonth (cal.getMonthLength (cdate));
\r
227 }cdate = cal.getNthDayOfWeek (dayOfMonth, dayOfWeek, cdate);
\r
230 cdate.setDayOfMonth (dayOfMonth);
\r
231 cdate = cal.getNthDayOfWeek (1, dayOfWeek, cdate);
\r
234 cdate.setDayOfMonth (dayOfMonth);
\r
235 cdate = cal.getNthDayOfWeek (-1, dayOfWeek, cdate);
\r
238 return cal.getTime (cdate) + timeOfDay;
\r
239 }, "jssun.util.calendar.BaseCalendar,jssun.util.calendar.BaseCalendar.Date,~N,~N,~N,~N,~N,~N");
\r
240 Clazz.overrideMethod (c$, "getRawOffset",
\r
242 return this.rawOffset;
\r
244 Clazz.overrideMethod (c$, "setRawOffset",
\r
245 function (offsetMillis) {
\r
246 this.rawOffset = offsetMillis;
\r
248 Clazz.defineMethod (c$, "setDSTSavings",
\r
249 function (millisSavedDuringDST) {
\r
250 if (millisSavedDuringDST <= 0) {
\r
251 throw new IllegalArgumentException ("Illegal daylight saving value: " + millisSavedDuringDST);
\r
252 }this.dstSavings = millisSavedDuringDST;
\r
254 Clazz.overrideMethod (c$, "getDSTSavings",
\r
256 if (this.useDaylight) {
\r
257 return this.dstSavings;
\r
260 Clazz.overrideMethod (c$, "useDaylightTime",
\r
262 return this.useDaylight;
\r
264 Clazz.overrideMethod (c$, "inDaylightTime",
\r
266 return (this.getOffset (date.getTime ()) != this.rawOffset);
\r
267 }, "java.util.Date");
\r
268 Clazz.overrideMethod (c$, "hashCode",
\r
270 return this.startMonth ^ this.startDay ^ this.startDayOfWeek ^ this.startTime ^ this.endMonth ^ this.endDay ^ this.endDayOfWeek ^ this.endTime ^ this.rawOffset;
\r
272 Clazz.overrideMethod (c$, "equals",
\r
274 if (this === obj) {
\r
276 }if (!(Clazz.instanceOf (obj, java.util.SimpleTimeZone))) {
\r
279 return this.getID ().equals (that.getID ()) && this.hasSameRules (that);
\r
281 Clazz.overrideMethod (c$, "hasSameRules",
\r
283 if (this === other) {
\r
285 }if (!(Clazz.instanceOf (other, java.util.SimpleTimeZone))) {
\r
288 return this.rawOffset == that.rawOffset && this.useDaylight == that.useDaylight && (!this.useDaylight || (this.dstSavings == that.dstSavings && this.startMode == that.startMode && this.startMonth == that.startMonth && this.startDay == that.startDay && this.startDayOfWeek == that.startDayOfWeek && this.startTime == that.startTime && this.startTimeMode == that.startTimeMode && this.endMode == that.endMode && this.endMonth == that.endMonth && this.endDay == that.endDay && this.endDayOfWeek == that.endDayOfWeek && this.endTime == that.endTime && this.endTimeMode == that.endTimeMode && this.startYear == that.startYear));
\r
289 }, "java.util.TimeZone");
\r
290 Clazz.overrideMethod (c$, "toString",
\r
292 return this.getClass ().getName () + "[id=" + this.getID () + ",offset=" + this.rawOffset + ",dstSavings=" + this.dstSavings + ",useDaylight=" + this.useDaylight + ",startYear=" + this.startYear + ",startMode=" + this.startMode + ",startMonth=" + this.startMonth + ",startDay=" + this.startDay + ",startDayOfWeek=" + this.startDayOfWeek + ",startTime=" + this.startTime + ",startTimeMode=" + this.startTimeMode + ",endMode=" + this.endMode + ",endMonth=" + this.endMonth + ",endDay=" + this.endDay + ",endDayOfWeek=" + this.endDayOfWeek + ",endTime=" + this.endTime + ",endTimeMode=" + this.endTimeMode + ']';
\r
294 Clazz.defineMethod (c$, "invalidateCache",
\r
296 this.cacheYear = this.startYear - 1;
\r
297 this.cacheStart = this.cacheEnd = 0;
\r
299 Clazz.defineMethod (c$, "decodeRules",
\r
301 this.decodeStartRule ();
\r
302 this.decodeEndRule ();
\r
304 Clazz.defineMethod (c$, "decodeStartRule",
\r
306 this.useDaylight = (this.startDay != 0) && (this.endDay != 0);
\r
307 if (this.startDay != 0) {
\r
308 if (this.startMonth < 0 || this.startMonth > 11) {
\r
309 throw new IllegalArgumentException ("Illegal start month " + this.startMonth);
\r
310 }if (this.startTime < 0 || this.startTime > 86400000) {
\r
311 throw new IllegalArgumentException ("Illegal start time " + this.startTime);
\r
312 }if (this.startDayOfWeek == 0) {
\r
313 this.startMode = 1;
\r
315 if (this.startDayOfWeek > 0) {
\r
316 this.startMode = 2;
\r
318 this.startDayOfWeek = -this.startDayOfWeek;
\r
319 if (this.startDay > 0) {
\r
320 this.startMode = 3;
\r
322 this.startDay = -this.startDay;
\r
323 this.startMode = 4;
\r
324 }}if (this.startDayOfWeek > 7) {
\r
325 throw new IllegalArgumentException ("Illegal start day of week " + this.startDayOfWeek);
\r
326 }}if (this.startMode == 2) {
\r
327 if (this.startDay < -5 || this.startDay > 5) {
\r
328 throw new IllegalArgumentException ("Illegal start day of week in month " + this.startDay);
\r
329 }} else if (this.startDay < 1 || this.startDay > java.util.SimpleTimeZone.staticMonthLength[this.startMonth]) {
\r
330 throw new IllegalArgumentException ("Illegal start day " + this.startDay);
\r
332 Clazz.defineMethod (c$, "decodeEndRule",
\r
334 this.useDaylight = (this.startDay != 0) && (this.endDay != 0);
\r
335 if (this.endDay != 0) {
\r
336 if (this.endMonth < 0 || this.endMonth > 11) {
\r
337 throw new IllegalArgumentException ("Illegal end month " + this.endMonth);
\r
338 }if (this.endTime < 0 || this.endTime > 86400000) {
\r
339 throw new IllegalArgumentException ("Illegal end time " + this.endTime);
\r
340 }if (this.endDayOfWeek == 0) {
\r
343 if (this.endDayOfWeek > 0) {
\r
346 this.endDayOfWeek = -this.endDayOfWeek;
\r
347 if (this.endDay > 0) {
\r
350 this.endDay = -this.endDay;
\r
352 }}if (this.endDayOfWeek > 7) {
\r
353 throw new IllegalArgumentException ("Illegal end day of week " + this.endDayOfWeek);
\r
354 }}if (this.endMode == 2) {
\r
355 if (this.endDay < -5 || this.endDay > 5) {
\r
356 throw new IllegalArgumentException ("Illegal end day of week in month " + this.endDay);
\r
357 }} else if (this.endDay < 1 || this.endDay > java.util.SimpleTimeZone.staticMonthLength[this.endMonth]) {
\r
358 throw new IllegalArgumentException ("Illegal end day " + this.endDay);
\r
360 Clazz.defineStatics (c$,
\r
361 "millisPerHour", 3600000,
\r
362 "millisPerDay", 86400000,
\r
363 "staticMonthLength", Clazz.newByteArray (-1, [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]),
\r
364 "staticLeapMonthLength", Clazz.newByteArray (-1, [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]));
\r
365 c$.gcal = c$.prototype.gcal = jssun.util.calendar.CalendarSystem.getGregorianCalendar ();
\r
366 Clazz.defineStatics (c$,
\r
368 "DOW_IN_MONTH_MODE", 2,
\r
369 "DOW_GE_DOM_MODE", 3,
\r
370 "DOW_LE_DOM_MODE", 4,
\r
372 "STANDARD_TIME", 1,
\r
374 "currentSerialVersion", 2);
\r