1 Clazz.declarePackage ("jssun.util.calendar");
2 Clazz.load (["jssun.util.calendar.CalendarSystem"], "jssun.util.calendar.AbstractCalendar", ["java.lang.IllegalArgumentException", "jssun.util.calendar.CalendarUtils", "$.ZoneInfo"], function () {
3 c$ = Clazz.decorateAsClass (function () {
5 Clazz.instantialize (this, arguments);
6 }, jssun.util.calendar, "AbstractCalendar", jssun.util.calendar.CalendarSystem);
7 Clazz.makeConstructor (c$,
9 Clazz.superConstructor (this, jssun.util.calendar.AbstractCalendar, []);
11 Clazz.overrideMethod (c$, "getEra",
13 if (this.eras != null) {
14 for (var i = 0; i < this.eras.length; i++) {
15 if (this.eras[i].equals (eraName)) {
20 Clazz.overrideMethod (c$, "getEras",
23 if (this.eras != null) {
24 e = new Array (this.eras.length);
25 System.arraycopy (this.eras, 0, e, 0, this.eras.length);
28 Clazz.overrideMethod (c$, "setEra",
29 function (date, eraName) {
30 if (this.eras == null) {
32 }for (var i = 0; i < this.eras.length; i++) {
34 if (e != null && e.getName ().equals (eraName)) {
38 throw new IllegalArgumentException ("unknown era name: " + eraName);
39 }, "jssun.util.calendar.CalendarDate,~S");
40 Clazz.defineMethod (c$, "setEras",
44 Clazz.defineMethod (c$, "getCalendarDate",
46 return this.getCalendarDate (System.currentTimeMillis (), this.newCalendarDate ());
48 Clazz.defineMethod (c$, "getCalendarDate",
50 return this.getCalendarDate (millis, this.newCalendarDate ());
52 Clazz.defineMethod (c$, "getCalendarDate",
53 function (millis, zone) {
54 var date = this.newCalendarDate (zone);
55 return this.getCalendarDate (millis, date);
56 }, "~N,java.util.TimeZone");
57 Clazz.defineMethod (c$, "getCalendarDate",
58 function (millis, date) {
63 var zi = date.getZone ();
65 var offsets = Clazz.newIntArray (2, 0);
66 if (Clazz.instanceOf (zi, jssun.util.calendar.ZoneInfo)) {
67 zoneOffset = (zi).getOffsets (millis, offsets);
69 zoneOffset = zi.getOffset (millis);
70 offsets[0] = zi.getRawOffset ();
71 offsets[1] = zoneOffset - offsets[0];
72 }days = Clazz.doubleToInt (zoneOffset / 86400000);
73 ms = zoneOffset % 86400000;
75 }date.setZoneOffset (zoneOffset);
76 date.setDaylightSaving (saving);
77 days += Clazz.doubleToInt (millis / 86400000);
78 ms += (millis % 86400000);
88 this.getCalendarDateFromFixedDate (date, days);
89 this.setTimeOfDay (date, ms);
90 date.setLeapYear (this.isLeapYear (date));
91 date.setNormalized (true);
93 }, "~N,jssun.util.calendar.CalendarDate");
94 Clazz.overrideMethod (c$, "getTime",
96 var gd = this.getFixedDate (date);
97 var ms = (gd - 719163) * 86400000 + this.getTimeOfDay (date);
99 var zi = date.getZone ();
101 if (date.isNormalized ()) {
102 return ms - date.getZoneOffset ();
103 }var offsets = Clazz.newIntArray (2, 0);
104 if (date.isStandardTime ()) {
105 if (Clazz.instanceOf (zi, jssun.util.calendar.ZoneInfo)) {
106 (zi).getOffsetsByStandard (ms, offsets);
107 zoneOffset = offsets[0];
109 zoneOffset = zi.getOffset (ms - zi.getRawOffset ());
111 if (Clazz.instanceOf (zi, jssun.util.calendar.ZoneInfo)) {
112 zoneOffset = (zi).getOffsetsByWall (ms, offsets);
114 zoneOffset = zi.getOffset (ms - zi.getRawOffset ());
116 this.getCalendarDate (ms, date);
118 }, "jssun.util.calendar.CalendarDate");
119 Clazz.defineMethod (c$, "getTimeOfDay",
121 var fraction = date.getTimeOfDay ();
122 if (fraction != -9223372036854775808) {
124 }fraction = this.getTimeOfDayValue (date);
125 date.setTimeOfDay (fraction);
127 }, "jssun.util.calendar.CalendarDate");
128 Clazz.defineMethod (c$, "getTimeOfDayValue",
130 var fraction = date.getHours ();
132 fraction += date.getMinutes ();
134 fraction += date.getSeconds ();
136 fraction += date.getMillis ();
138 }, "jssun.util.calendar.CalendarDate");
139 Clazz.overrideMethod (c$, "setTimeOfDay",
140 function (cdate, fraction) {
142 throw new IllegalArgumentException ();
143 }var normalizedState = cdate.isNormalized ();
145 var hours = Clazz.doubleToInt (time / 3600000);
147 var minutes = Clazz.doubleToInt (time / 60000);
149 var seconds = Clazz.doubleToInt (time / 1000);
151 cdate.setHours (hours);
152 cdate.setMinutes (minutes);
153 cdate.setSeconds (seconds);
154 cdate.setMillis (time);
155 cdate.setTimeOfDay (fraction);
156 if (hours < 24 && normalizedState) {
157 cdate.setNormalized (normalizedState);
159 }, "jssun.util.calendar.CalendarDate,~N");
160 Clazz.overrideMethod (c$, "getWeekLength",
164 Clazz.overrideMethod (c$, "getNthDayOfWeek",
165 function (nth, dayOfWeek, date) {
166 var ndate = date.clone ();
167 this.normalize (ndate);
168 var fd = this.getFixedDate (ndate);
171 nfd = 7 * nth + jssun.util.calendar.AbstractCalendar.getDayOfWeekDateBefore (fd, dayOfWeek);
173 nfd = 7 * nth + jssun.util.calendar.AbstractCalendar.getDayOfWeekDateAfter (fd, dayOfWeek);
174 }this.getCalendarDateFromFixedDate (ndate, nfd);
176 }, "~N,~N,jssun.util.calendar.CalendarDate");
177 c$.getDayOfWeekDateBefore = Clazz.defineMethod (c$, "getDayOfWeekDateBefore",
178 function (fixedDate, dayOfWeek) {
179 return jssun.util.calendar.AbstractCalendar.getDayOfWeekDateOnOrBefore (fixedDate - 1, dayOfWeek);
181 c$.getDayOfWeekDateAfter = Clazz.defineMethod (c$, "getDayOfWeekDateAfter",
182 function (fixedDate, dayOfWeek) {
183 return jssun.util.calendar.AbstractCalendar.getDayOfWeekDateOnOrBefore (fixedDate + 7, dayOfWeek);
185 c$.getDayOfWeekDateOnOrBefore = Clazz.defineMethod (c$, "getDayOfWeekDateOnOrBefore",
186 function (fixedDate, dayOfWeek) {
187 var fd = fixedDate - (dayOfWeek - 1);
189 return fixedDate - (fd % 7);
190 }return fixedDate - jssun.util.calendar.CalendarUtils.mod (fd, 7);
192 Clazz.defineMethod (c$, "validateTime",
194 var t = date.getHours ();
195 if (t < 0 || t >= 24) {
197 }t = date.getMinutes ();
198 if (t < 0 || t >= 60) {
200 }t = date.getSeconds ();
201 if (t < 0 || t >= 60) {
203 }t = date.getMillis ();
204 if (t < 0 || t >= 1000) {
207 }, "jssun.util.calendar.CalendarDate");
208 Clazz.defineMethod (c$, "normalizeTime",
210 var fraction = this.getTimeOfDay (date);
212 if (fraction >= 86400000) {
213 days = Clazz.doubleToInt (fraction / 86400000);
214 fraction %= 86400000;
215 } else if (fraction < 0) {
216 days = jssun.util.calendar.CalendarUtils.floorDivide (fraction, 86400000);
218 fraction -= 86400000 * days;
220 date.setTimeOfDay (fraction);
221 }date.setMillis ((fraction % 1000));
222 fraction = Clazz.doubleToInt (fraction / 1000);
223 date.setSeconds ((fraction % 60));
224 fraction = Clazz.doubleToInt (fraction / 60);
225 date.setMinutes ((fraction % 60));
226 date.setHours ((Clazz.doubleToInt (fraction / 60)));
228 }, "jssun.util.calendar.CalendarDate");
229 Clazz.defineStatics (c$,
230 "SECOND_IN_MILLIS", 1000,
231 "MINUTE_IN_MILLIS", 60000,
232 "HOUR_IN_MILLIS", 3600000,
233 "DAY_IN_MILLIS", 86400000,
234 "EPOCH_OFFSET", 719163);