1 Clazz.declarePackage ("jssun.util.calendar");
2 Clazz.load (["java.util.TimeZone", "jssun.util.calendar.CalendarSystem"], "jssun.util.calendar.ZoneInfo", ["java.lang.IllegalArgumentException", "$.NullPointerException", "java.util.Date", "java.util.SimpleTimeZone"], function () {
3 c$ = Clazz.decorateAsClass (function () {
5 this.rawOffsetDiff = 0;
8 this.transitions = null;
10 this.simpleTimeZoneParams = null;
11 this.willGMTOffsetChange = false;
14 Clazz.instantialize (this, arguments);
15 }, jssun.util.calendar, "ZoneInfo", java.util.TimeZone);
16 Clazz.defineMethod (c$, "setRawOffsetReally",
18 this.rawOffset = offset;
20 Clazz.makeConstructor (c$,
22 Clazz.superConstructor (this, jssun.util.calendar.ZoneInfo, []);
24 Clazz.makeConstructor (c$,
25 function (ID, rawOffset) {
26 this.construct (ID, rawOffset, 0, 0, null, null, null, false);
28 Clazz.makeConstructor (c$,
29 function (ID, rawOffset, dstSavings, checksum, transitions, offsets, simpleTimeZoneParams, willGMTOffsetChange) {
30 Clazz.superConstructor (this, jssun.util.calendar.ZoneInfo, []);
32 this.rawOffset = rawOffset;
33 this.dstSavings = dstSavings;
34 this.checksum = checksum;
35 this.transitions = transitions;
36 this.offsets = offsets;
37 this.simpleTimeZoneParams = simpleTimeZoneParams;
38 this.willGMTOffsetChange = willGMTOffsetChange;
39 }, "~S,~N,~N,~N,~A,~A,~A,~B");
40 Clazz.defineMethod (c$, "getOffset",
42 return this.getOffsets (date, null, 0);
44 Clazz.defineMethod (c$, "getOffsets",
45 function (utc, offsets) {
46 return this.getOffsets (utc, offsets, 0);
48 Clazz.defineMethod (c$, "getOffsetsByStandard",
49 function (standard, offsets) {
50 return this.getOffsets (standard, offsets, 1);
52 Clazz.defineMethod (c$, "getOffsetsByWall",
53 function (wall, offsets) {
54 return this.getOffsets (wall, offsets, 2);
56 Clazz.defineMethod (c$, "getOffsets",
57 function (date, offsets, type) {
58 if (this.transitions == null) {
59 var offset = this.getLastRawOffset ();
60 if (offsets != null) {
64 }date -= this.rawOffsetDiff;
65 var index = this.getTransitionIndex (date, type);
67 var offset = this.getLastRawOffset ();
68 if (offsets != null) {
72 }if (index < this.transitions.length) {
73 var val = this.transitions[index];
74 var offset = this.offsets[(val & 15)] + this.rawOffsetDiff;
75 if (offsets != null) {
76 var dst = ((val >>> 4) & 0xf);
77 var save = (dst == 0) ? 0 : this.offsets[dst];
78 offsets[0] = offset - save;
81 }var tz = this.getLastRule ();
83 var rawoffset = tz.getRawOffset ();
86 msec -= this.rawOffset;
87 }var dstoffset = tz.inDaylightTime ( new java.util.Date (msec)) ? tz.getDSTSavings () : 0;
88 if (offsets != null) {
89 offsets[0] = rawoffset;
90 offsets[1] = dstoffset;
91 }return rawoffset + dstoffset;
92 }var offset = this.getLastRawOffset ();
93 if (offsets != null) {
98 Clazz.defineMethod (c$, "getTransitionIndex",
99 function (date, type) {
101 var high = this.transitions.length - 1;
102 while (low <= high) {
103 var mid = Clazz.doubleToInt ((low + high) / 2);
104 var val = this.transitions[mid];
105 var midVal = val >> 12;
107 midVal += this.offsets[(val & 15)];
109 var dstIndex = ((val >>> 4) & 0xf);
111 midVal -= this.offsets[dstIndex];
112 }}if (midVal < date) {
114 } else if (midVal > date) {
119 if (low >= this.transitions.length) {
123 Clazz.defineMethod (c$, "getOffset",
124 function (era, year, month, day, dayOfWeek, milliseconds) {
125 if (milliseconds < 0 || milliseconds >= 86400000) {
126 throw new IllegalArgumentException ();
129 } else if (era != 1) {
130 throw new IllegalArgumentException ();
131 }var date = jssun.util.calendar.ZoneInfo.gcal.newCalendarDate (null);
132 date.setDate (year, month + 1, day);
133 if (jssun.util.calendar.ZoneInfo.gcal.validate (date) == false) {
134 throw new IllegalArgumentException ();
135 }if (dayOfWeek < 1 || dayOfWeek > 7) {
136 throw new IllegalArgumentException ();
137 }if (this.transitions == null) {
138 return this.getLastRawOffset ();
139 }var dateInMillis = jssun.util.calendar.ZoneInfo.gcal.getTime (date) + milliseconds;
140 dateInMillis -= this.rawOffset;
141 return this.getOffsets (dateInMillis, null, 0);
142 }, "~N,~N,~N,~N,~N,~N");
143 Clazz.overrideMethod (c$, "setRawOffset",
144 function (offsetMillis) {
145 if (offsetMillis == this.rawOffset + this.rawOffsetDiff) {
147 }this.rawOffsetDiff = offsetMillis - this.rawOffset;
148 if (this.lastRule != null) {
149 this.lastRule.setRawOffset (offsetMillis);
152 Clazz.defineMethod (c$, "getRawOffset",
154 if (!this.willGMTOffsetChange) {
155 return this.rawOffset + this.rawOffsetDiff;
156 }var offsets = Clazz.newIntArray (2, 0);
157 this.getOffsets (System.currentTimeMillis (), offsets, 0);
160 Clazz.defineMethod (c$, "isDirty",
164 Clazz.defineMethod (c$, "getLastRawOffset",
166 return this.rawOffset + this.rawOffsetDiff;
168 Clazz.defineMethod (c$, "useDaylightTime",
170 return (this.simpleTimeZoneParams != null);
172 Clazz.overrideMethod (c$, "inDaylightTime",
175 throw new NullPointerException ();
176 }if (this.transitions == null) {
178 }var utc = date.getTime () - this.rawOffsetDiff;
179 var index = this.getTransitionIndex (utc, 0);
182 }if (index < this.transitions.length) {
183 return (this.transitions[index] & 240) != 0;
184 }var tz = this.getLastRule ();
186 return tz.inDaylightTime (date);
188 }, "java.util.Date");
189 Clazz.overrideMethod (c$, "getDSTSavings",
191 return this.dstSavings;
193 Clazz.overrideMethod (c$, "toString",
195 return this.getClass ().getName () + "[id=\"" + this.getID () + "\"" + ",offset=" + this.getLastRawOffset () + ",dstSavings=" + this.dstSavings + ",useDaylight=" + this.useDaylightTime () + ",transitions=" + ((this.transitions != null) ? this.transitions.length : 0) + ",lastRule=" + (this.lastRule == null ? this.getLastRuleInstance () : this.lastRule) + "]";
197 Clazz.defineMethod (c$, "getLastRule",
199 if (this.lastRule == null) {
200 this.lastRule = this.getLastRuleInstance ();
201 }return this.lastRule;
203 Clazz.defineMethod (c$, "getLastRuleInstance",
205 if (this.simpleTimeZoneParams == null) {
207 }if (this.simpleTimeZoneParams.length == 10) {
208 return new java.util.SimpleTimeZone (this.getLastRawOffset (), this.getID (), this.simpleTimeZoneParams[0], this.simpleTimeZoneParams[1], this.simpleTimeZoneParams[2], this.simpleTimeZoneParams[3], this.simpleTimeZoneParams[4], this.simpleTimeZoneParams[5], this.simpleTimeZoneParams[6], this.simpleTimeZoneParams[7], this.simpleTimeZoneParams[8], this.simpleTimeZoneParams[9], this.dstSavings);
209 }return new java.util.SimpleTimeZone (this.getLastRawOffset (), this.getID (), this.simpleTimeZoneParams[0], this.simpleTimeZoneParams[1], this.simpleTimeZoneParams[2], this.simpleTimeZoneParams[3], this.simpleTimeZoneParams[4], this.simpleTimeZoneParams[5], this.simpleTimeZoneParams[6], this.simpleTimeZoneParams[7], this.dstSavings);
211 Clazz.defineMethod (c$, "clone",
213 var zi = Clazz.superCall (this, jssun.util.calendar.ZoneInfo, "clone", []);
217 Clazz.overrideMethod (c$, "hashCode",
219 return this.getLastRawOffset () ^ this.checksum;
221 Clazz.overrideMethod (c$, "equals",
225 }if (!(Clazz.instanceOf (obj, jssun.util.calendar.ZoneInfo))) {
228 return (this.getID ().equals (that.getID ()) && (this.getLastRawOffset () == that.getLastRawOffset ()) && (this.checksum == that.checksum));
230 Clazz.overrideMethod (c$, "hasSameRules",
232 if (this === other) {
234 }if (other == null) {
236 }if (!(Clazz.instanceOf (other, jssun.util.calendar.ZoneInfo))) {
237 if (this.getRawOffset () != other.getRawOffset ()) {
239 }if ((this.transitions == null) && (this.useDaylightTime () == false) && (other.useDaylightTime () == false)) {
242 }if (this.getLastRawOffset () != (other).getLastRawOffset ()) {
244 }return (this.checksum == (other).checksum);
245 }, "java.util.TimeZone");
246 c$.getAliasTable = Clazz.defineMethod (c$, "getAliasTable",
249 var cache = jssun.util.calendar.ZoneInfo.aliasTable;
252 if (aliases != null) {
256 Clazz.defineStatics (c$,
263 "TRANSITION_NSHIFT", 12);
264 c$.gcal = c$.prototype.gcal = jssun.util.calendar.CalendarSystem.getGregorianCalendar ();
265 Clazz.defineStatics (c$,