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