a7dfe8f7a3aa43d1bb91ae684b9beb80a230d0d5
[jalviewjs.git] / site / j2s / java / util / GregorianCalendar.js
1 Clazz.declarePackage ("java.util");
2 Clazz.load (["java.util.Calendar", "jssun.util.calendar.CalendarSystem", "$.Gregorian"], "java.util.GregorianCalendar", ["java.lang.ArrayIndexOutOfBoundsException", "$.IllegalArgumentException", "java.util.Date", "java.util.Locale", "$.TimeZone", "jssun.util.calendar.AbstractCalendar", "$.CalendarUtils", "$.ZoneInfo"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.gregorianCutover = -12219292800000;
5 this.gregorianCutoverDate = 577736;
6 this.gregorianCutoverYear = 1582;
7 this.gregorianCutoverYearJulian = 1582;
8 this.gdate = null;
9 this.cdate = null;
10 this.calsys = null;
11 this.zoneOffsets = null;
12 this.originalFields = null;
13 this.cachedFixedDate = -9223372036854775808;
14 Clazz.instantialize (this, arguments);
15 }, java.util, "GregorianCalendar", java.util.Calendar);
16 Clazz.makeConstructor (c$, 
17 function () {
18 this.construct (java.util.TimeZone.getDefaultRef (), java.util.Locale.getDefault ());
19 this.setZoneShared (true);
20 });
21 Clazz.makeConstructor (c$, 
22 function (zone) {
23 this.construct (zone, java.util.Locale.getDefault ());
24 }, "java.util.TimeZone");
25 Clazz.makeConstructor (c$, 
26 function (aLocale) {
27 this.construct (java.util.TimeZone.getDefaultRef (), aLocale);
28 this.setZoneShared (true);
29 }, "java.util.Locale");
30 Clazz.makeConstructor (c$, 
31 function (zone, aLocale) {
32 Clazz.superConstructor (this, java.util.GregorianCalendar, [zone, aLocale]);
33 this.gdate = java.util.GregorianCalendar.gcal.newCalendarDate (zone);
34 this.setTimeInMillis (System.currentTimeMillis ());
35 }, "java.util.TimeZone,java.util.Locale");
36 Clazz.makeConstructor (c$, 
37 function (year, month, dayOfMonth) {
38 this.construct (year, month, dayOfMonth, 0, 0, 0, 0);
39 }, "~N,~N,~N");
40 Clazz.makeConstructor (c$, 
41 function (year, month, dayOfMonth, hourOfDay, minute) {
42 this.construct (year, month, dayOfMonth, hourOfDay, minute, 0, 0);
43 }, "~N,~N,~N,~N,~N");
44 Clazz.makeConstructor (c$, 
45 function (year, month, dayOfMonth, hourOfDay, minute, second) {
46 this.construct (year, month, dayOfMonth, hourOfDay, minute, second, 0);
47 }, "~N,~N,~N,~N,~N,~N");
48 Clazz.makeConstructor (c$, 
49 function (year, month, dayOfMonth, hourOfDay, minute, second, millis) {
50 Clazz.superConstructor (this, java.util.GregorianCalendar);
51 this.gdate = java.util.GregorianCalendar.gcal.newCalendarDate (this.getZone ());
52 this.set (1, year);
53 this.set (2, month);
54 this.set (5, dayOfMonth);
55 if (hourOfDay >= 12 && hourOfDay <= 23) {
56 this.internalSet (9, 1);
57 this.internalSet (10, hourOfDay - 12);
58 } else {
59 this.internalSet (10, hourOfDay);
60 }this.setFieldsComputed (1536);
61 this.set (11, hourOfDay);
62 this.set (12, minute);
63 this.set (13, second);
64 this.internalSet (14, millis);
65 }, "~N,~N,~N,~N,~N,~N,~N");
66 Clazz.defineMethod (c$, "getGregorianChange", 
67 function () {
68 return  new java.util.Date (this.gregorianCutover);
69 });
70 Clazz.defineMethod (c$, "isLeapYear", 
71 function (year) {
72 if ((year & 3) != 0) {
73 return false;
74 }if (year > this.gregorianCutoverYear) {
75 return (year % 100 != 0) || (year % 400 == 0);
76 }if (year < this.gregorianCutoverYearJulian) {
77 return true;
78 }var gregorian;
79 if (this.gregorianCutoverYear == this.gregorianCutoverYearJulian) {
80 var d = this.getCalendarDate (this.gregorianCutoverDate);
81 gregorian = d.getMonth () < 3;
82 } else {
83 gregorian = year == this.gregorianCutoverYear;
84 }return gregorian ? (year % 100 != 0) || (year % 400 == 0) : true;
85 }, "~N");
86 Clazz.defineMethod (c$, "equals", 
87 function (obj) {
88 return Clazz.instanceOf (obj, java.util.GregorianCalendar) && Clazz.superCall (this, java.util.GregorianCalendar, "equals", [obj]) && this.gregorianCutover == (obj).gregorianCutover;
89 }, "~O");
90 Clazz.defineMethod (c$, "hashCode", 
91 function () {
92 return Clazz.superCall (this, java.util.GregorianCalendar, "hashCode", []) ^ this.gregorianCutoverDate;
93 });
94 Clazz.overrideMethod (c$, "add", 
95 function (field, amount) {
96 if (amount == 0) {
97 return;
98 }if (field < 0 || field >= 15) {
99 throw  new IllegalArgumentException ();
100 }this.complete ();
101 if (field == 1) {
102 var year = this.internalGet (1);
103 if (this.internalGetEra () == 1) {
104 year += amount;
105 if (year > 0) {
106 this.set (1, year);
107 } else {
108 this.set (1, 1 - year);
109 this.set (0, 0);
110 }} else {
111 year -= amount;
112 if (year > 0) {
113 this.set (1, year);
114 } else {
115 this.set (1, 1 - year);
116 this.set (0, 1);
117 }}this.pinDayOfMonth ();
118 } else if (field == 2) {
119 var month = this.internalGet (2) + amount;
120 var year = this.internalGet (1);
121 var y_amount;
122 if (month >= 0) {
123 y_amount = Clazz.doubleToInt (month / 12);
124 } else {
125 y_amount = Clazz.doubleToInt ((month + 1) / 12) - 1;
126 }if (y_amount != 0) {
127 if (this.internalGetEra () == 1) {
128 year += y_amount;
129 if (year > 0) {
130 this.set (1, year);
131 } else {
132 this.set (1, 1 - year);
133 this.set (0, 0);
134 }} else {
135 year -= y_amount;
136 if (year > 0) {
137 this.set (1, year);
138 } else {
139 this.set (1, 1 - year);
140 this.set (0, 1);
141 }}}if (month >= 0) {
142 this.set (2, (month % 12));
143 } else {
144 month %= 12;
145 if (month < 0) {
146 month += 12;
147 }this.set (2, 0 + month);
148 }this.pinDayOfMonth ();
149 } else if (field == 0) {
150 var era = this.internalGet (0) + amount;
151 if (era < 0) {
152 era = 0;
153 }if (era > 1) {
154 era = 1;
155 }this.set (0, era);
156 } else {
157 var delta = amount;
158 var timeOfDay = 0;
159 switch (field) {
160 case 10:
161 case 11:
162 delta *= 3600000;
163 break;
164 case 12:
165 delta *= 60000;
166 break;
167 case 13:
168 delta *= 1000;
169 break;
170 case 14:
171 break;
172 case 3:
173 case 4:
174 case 8:
175 delta *= 7;
176 break;
177 case 5:
178 case 6:
179 case 7:
180 break;
181 case 9:
182 delta = Clazz.doubleToInt (amount / 2);
183 timeOfDay = 12 * (amount % 2);
184 break;
185 }
186 if (field >= 10) {
187 this.setTimeInMillis (this.time + delta);
188 return;
189 }var fd = this.getCurrentFixedDate ();
190 timeOfDay += this.internalGet (11);
191 timeOfDay *= 60;
192 timeOfDay += this.internalGet (12);
193 timeOfDay *= 60;
194 timeOfDay += this.internalGet (13);
195 timeOfDay *= 1000;
196 timeOfDay += this.internalGet (14);
197 if (timeOfDay >= 86400000) {
198 fd++;
199 timeOfDay -= 86400000;
200 } else if (timeOfDay < 0) {
201 fd--;
202 timeOfDay += 86400000;
203 }fd += delta;
204 var zoneOffset = this.internalGet (15) + this.internalGet (16);
205 this.setTimeInMillis ((fd - 719163) * 86400000 + timeOfDay - zoneOffset);
206 zoneOffset -= this.internalGet (15) + this.internalGet (16);
207 if (zoneOffset != 0) {
208 this.setTimeInMillis (this.time + zoneOffset);
209 var fd2 = this.getCurrentFixedDate ();
210 if (fd2 != fd) {
211 this.setTimeInMillis (this.time - zoneOffset);
212 }}}}, "~N,~N");
213 Clazz.defineMethod (c$, "roll", 
214 function (field, up) {
215 this.roll (field, up ? 1 : -1);
216 }, "~N,~B");
217 Clazz.defineMethod (c$, "roll", 
218 function (field, amount) {
219 if (amount == 0) {
220 return;
221 }if (field < 0 || field >= 15) {
222 throw  new IllegalArgumentException ();
223 }this.complete ();
224 var min = this.getMinimum (field);
225 var max = this.getMaximum (field);
226 switch (field) {
227 case 9:
228 case 0:
229 case 1:
230 case 12:
231 case 13:
232 case 14:
233 break;
234 case 10:
235 case 11:
236 {
237 var unit = max + 1;
238 var h = this.internalGet (field);
239 var nh = (h + amount) % unit;
240 if (nh < 0) {
241 nh += unit;
242 }this.time += 3600000 * (nh - h);
243 var d = this.calsys.getCalendarDate (this.time, this.getZone ());
244 if (this.internalGet (5) != d.getDayOfMonth ()) {
245 d.setDate (this.internalGet (1), this.internalGet (2) + 1, this.internalGet (5));
246 if (field == 10) {
247 d.addHours (12);
248 }this.time = this.calsys.getTime (d);
249 }var hourOfDay = d.getHours ();
250 this.internalSet (field, hourOfDay % unit);
251 if (field == 10) {
252 this.internalSet (11, hourOfDay);
253 } else {
254 this.internalSet (9, Clazz.doubleToInt (hourOfDay / 12));
255 this.internalSet (10, hourOfDay % 12);
256 }var zoneOffset = d.getZoneOffset ();
257 var saving = d.getDaylightSaving ();
258 this.internalSet (15, zoneOffset - saving);
259 this.internalSet (16, saving);
260 return;
261 }case 2:
262 {
263 var mon = (this.internalGet (2) + amount) % 12;
264 if (mon < 0) {
265 mon += 12;
266 }this.set (2, mon);
267 var monthLen = this.monthLength (mon);
268 if (this.internalGet (5) > monthLen) {
269 this.set (5, monthLen);
270 }return;
271 }case 3:
272 {
273 var y = this.cdate.getNormalizedYear ();
274 max = this.getActualMaximum (3);
275 this.set (7, this.internalGet (7));
276 var woy = this.internalGet (3);
277 var value = woy + amount;
278 if (value > min && value < max) {
279 this.set (3, value);
280 return;
281 }var fd = this.getCurrentFixedDate ();
282 var day1 = fd - (7 * (woy - min));
283 if (this.calsys.getYearFromFixedDate (day1) != y) {
284 min++;
285 }fd += 7 * (max - this.internalGet (3));
286 if (this.calsys.getYearFromFixedDate (fd) != y) {
287 max--;
288 }break;
289 }case 4:
290 {
291 var dow = this.internalGet (7) - this.getFirstDayOfWeek ();
292 if (dow < 0) {
293 dow += 7;
294 }var fd = this.getCurrentFixedDate ();
295 var month1;
296 var monthLength;
297 month1 = fd - this.internalGet (5) + 1;
298 monthLength = this.calsys.getMonthLength (this.cdate);
299 var monthDay1st = jssun.util.calendar.AbstractCalendar.getDayOfWeekDateOnOrBefore (month1 + 6, this.getFirstDayOfWeek ());
300 if ((monthDay1st - month1) >= this.getMinimalDaysInFirstWeek ()) {
301 monthDay1st -= 7;
302 }max = this.getActualMaximum (field);
303 var value = java.util.GregorianCalendar.getRolledValue (this.internalGet (field), amount, 1, max) - 1;
304 var nfd = monthDay1st + value * 7 + dow;
305 if (nfd < month1) {
306 nfd = month1;
307 } else if (nfd >= (month1 + monthLength)) {
308 nfd = month1 + monthLength - 1;
309 }var dayOfMonth;
310 dayOfMonth = (nfd - month1) + 1;
311 this.set (5, dayOfMonth);
312 return;
313 }case 5:
314 {
315 max = this.calsys.getMonthLength (this.cdate);
316 break;
317 }case 6:
318 {
319 max = this.getActualMaximum (field);
320 break;
321 }case 7:
322 {
323 var weekOfYear = this.internalGet (3);
324 this.set (3, weekOfYear);
325 max = 7;
326 break;
327 }case 8:
328 {
329 min = 1;
330 var dom = this.internalGet (5);
331 var monthLength = this.calsys.getMonthLength (this.cdate);
332 var lastDays = monthLength % 7;
333 max = Clazz.doubleToInt (monthLength / 7);
334 var x = (dom - 1) % 7;
335 if (x < lastDays) {
336 max++;
337 }this.set (7, this.internalGet (7));
338 break;
339 }}
340 this.set (field, java.util.GregorianCalendar.getRolledValue (this.internalGet (field), amount, min, max));
341 }, "~N,~N");
342 Clazz.overrideMethod (c$, "getMinimum", 
343 function (field) {
344 return java.util.GregorianCalendar.MIN_VALUES[field];
345 }, "~N");
346 Clazz.overrideMethod (c$, "getMaximum", 
347 function (field) {
348 switch (field) {
349 case 2:
350 case 5:
351 case 6:
352 case 3:
353 case 4:
354 case 8:
355 case 1:
356 {
357 if (this.gregorianCutoverYear > 200) {
358 break;
359 }var gc = this.clone ();
360 gc.setLenient (true);
361 gc.setTimeInMillis (this.gregorianCutover);
362 var v1 = gc.getActualMaximum (field);
363 gc.setTimeInMillis (this.gregorianCutover - 1);
364 var v2 = gc.getActualMaximum (field);
365 return Math.max (java.util.GregorianCalendar.MAX_VALUES[field], Math.max (v1, v2));
366 }}
367 return java.util.GregorianCalendar.MAX_VALUES[field];
368 }, "~N");
369 Clazz.overrideMethod (c$, "getGreatestMinimum", 
370 function (field) {
371 return java.util.GregorianCalendar.MIN_VALUES[field];
372 }, "~N");
373 Clazz.overrideMethod (c$, "getLeastMaximum", 
374 function (field) {
375 switch (field) {
376 case 2:
377 case 5:
378 case 6:
379 case 3:
380 case 4:
381 case 8:
382 case 1:
383 {
384 var gc = this.clone ();
385 gc.setLenient (true);
386 gc.setTimeInMillis (this.gregorianCutover);
387 var v1 = gc.getActualMaximum (field);
388 gc.setTimeInMillis (this.gregorianCutover - 1);
389 var v2 = gc.getActualMaximum (field);
390 return Math.min (java.util.GregorianCalendar.LEAST_MAX_VALUES[field], Math.min (v1, v2));
391 }}
392 return java.util.GregorianCalendar.LEAST_MAX_VALUES[field];
393 }, "~N");
394 Clazz.overrideMethod (c$, "getActualMinimum", 
395 function (field) {
396 if (field == 5) {
397 }return this.getMinimum (field);
398 }, "~N");
399 Clazz.overrideMethod (c$, "getActualMaximum", 
400 function (field) {
401 var fieldsForFixedMax = 130689;
402 if ((130689 & (1 << field)) != 0) {
403 return this.getMaximum (field);
404 }var gc = this.getNormalizedCalendar ();
405 var date = gc.cdate;
406 var cal = gc.calsys;
407 var value = -1;
408 var d;
409 var dd;
410 switch (field) {
411 case 2:
412 {
413 }break;
414 case 5:
415 value = cal.getMonthLength (date);
416 break;
417 case 6:
418 value = cal.getYearLength (date);
419 break;
420 case 3:
421 {
422 dd = cal.newCalendarDate (java.util.TimeZone.NO_TIMEZONE);
423 dd.setDate (date.getYear (), 1, 1);
424 var dayOfWeek = cal.getDayOfWeek (dd);
425 dayOfWeek -= this.getFirstDayOfWeek ();
426 if (dayOfWeek < 0) {
427 dayOfWeek += 7;
428 }value = 52;
429 var magic = dayOfWeek + this.getMinimalDaysInFirstWeek () - 1;
430 if ((magic == 6) || (date.isLeapYear () && (magic == 5 || magic == 12))) {
431 value++;
432 }}break;
433 case 4:
434 dd = cal.newCalendarDate (null);
435 dd.setDate (date.getYear (), date.getMonth (), 1);
436 var dayOfWeek = cal.getDayOfWeek (dd);
437 var monthLength = cal.getMonthLength (dd);
438 dayOfWeek -= this.getFirstDayOfWeek ();
439 if (dayOfWeek < 0) {
440 dayOfWeek += 7;
441 }var nDaysFirstWeek = 7 - dayOfWeek;
442 value = 3;
443 if (nDaysFirstWeek >= this.getMinimalDaysInFirstWeek ()) {
444 value++;
445 }monthLength -= nDaysFirstWeek + 21;
446 if (monthLength > 0) {
447 value++;
448 if (monthLength > 7) {
449 value++;
450 }}break;
451 case 8:
452 {
453 var ndays;
454 var dow1;
455 var dow = date.getDayOfWeek ();
456 d = date.clone ();
457 ndays = cal.getMonthLength (d);
458 d.setDayOfMonth (1);
459 cal.normalize (d);
460 dow1 = d.getDayOfWeek ();
461 var x = dow - dow1;
462 if (x < 0) {
463 x += 7;
464 }ndays -= x;
465 value = Clazz.doubleToInt ((ndays + 6) / 7);
466 }break;
467 case 1:
468 {
469 if (gc === this) {
470 gc = this.clone ();
471 }var current = gc.getYearOffsetInMillis ();
472 if (gc.internalGetEra () == 1) {
473 gc.setTimeInMillis (9223372036854775807);
474 value = gc.get (1);
475 var maxEnd = gc.getYearOffsetInMillis ();
476 if (current > maxEnd) {
477 value--;
478 }} else {
479 var mincal = java.util.GregorianCalendar.gcal;
480 dd = mincal.getCalendarDate (-9223372036854775808, this.getZone ());
481 var maxEnd = (cal.getDayOfYear (dd) - 1) * 24 + dd.getHours ();
482 maxEnd *= 60;
483 maxEnd += dd.getMinutes ();
484 maxEnd *= 60;
485 maxEnd += dd.getSeconds ();
486 maxEnd *= 1000;
487 maxEnd += dd.getMillis ();
488 value = dd.getYear ();
489 if (value <= 0) {
490 value = 1 - value;
491 }if (current < maxEnd) {
492 value--;
493 }}}break;
494 default:
495 throw  new ArrayIndexOutOfBoundsException (field);
496 }
497 return value;
498 }, "~N");
499 Clazz.defineMethod (c$, "getYearOffsetInMillis", 
500  function () {
501 var t = (this.internalGet (6) - 1) * 24;
502 t += this.internalGet (11);
503 t *= 60;
504 t += this.internalGet (12);
505 t *= 60;
506 t += this.internalGet (13);
507 t *= 1000;
508 return t + this.internalGet (14) - (this.internalGet (15) + this.internalGet (16));
509 });
510 Clazz.defineMethod (c$, "clone", 
511 function () {
512 var other = Clazz.superCall (this, java.util.GregorianCalendar, "clone", []);
513 other.gdate = this.gdate.clone ();
514 if (this.cdate != null) {
515 if (this.cdate !== this.gdate) {
516 other.cdate = this.cdate.clone ();
517 } else {
518 other.cdate = other.gdate;
519 }}other.originalFields = null;
520 other.zoneOffsets = null;
521 return other;
522 });
523 Clazz.defineMethod (c$, "getTimeZone", 
524 function () {
525 var zone = Clazz.superCall (this, java.util.GregorianCalendar, "getTimeZone", []);
526 this.gdate.setZone (zone);
527 if (this.cdate != null && this.cdate !== this.gdate) {
528 this.cdate.setZone (zone);
529 }return zone;
530 });
531 Clazz.defineMethod (c$, "setTimeZone", 
532 function (zone) {
533 Clazz.superCall (this, java.util.GregorianCalendar, "setTimeZone", [zone]);
534 this.gdate.setZone (zone);
535 if (this.cdate != null && this.cdate !== this.gdate) {
536 this.cdate.setZone (zone);
537 }}, "java.util.TimeZone");
538 Clazz.defineMethod (c$, "computeFields", 
539 function () {
540 var mask = 0;
541 if (this.isPartiallyNormalized ()) {
542 mask = this.getSetStateFields ();
543 var fieldMask = ~mask & 131071;
544 if (fieldMask != 0 || this.calsys == null) {
545 mask |= this.computeFields (fieldMask, mask & (98304));
546 }} else {
547 mask = 131071;
548 this.computeFields (mask, 0);
549 }this.setFieldsComputed (mask);
550 });
551 Clazz.defineMethod (c$, "computeFields", 
552  function (fieldMask, tzMask) {
553 var zoneOffset = 0;
554 var tz = this.getZone ();
555 if (this.zoneOffsets == null) {
556 this.zoneOffsets =  Clazz.newIntArray (2, 0);
557 }if (tzMask != (98304)) {
558 if (Clazz.instanceOf (tz, jssun.util.calendar.ZoneInfo)) {
559 zoneOffset = (tz).getOffsets (this.time, this.zoneOffsets);
560 } else {
561 zoneOffset = tz.getOffset (this.time);
562 this.zoneOffsets[0] = tz.getRawOffset ();
563 this.zoneOffsets[1] = zoneOffset - this.zoneOffsets[0];
564 }}if (tzMask != 0) {
565 if (java.util.Calendar.isFieldSet (tzMask, 15)) {
566 this.zoneOffsets[0] = this.internalGet (15);
567 }if (java.util.Calendar.isFieldSet (tzMask, 16)) {
568 this.zoneOffsets[1] = this.internalGet (16);
569 }zoneOffset = this.zoneOffsets[0] + this.zoneOffsets[1];
570 }var fixedDate = Clazz.doubleToInt (zoneOffset / 86400000);
571 var timeOfDay = zoneOffset % 86400000;
572 fixedDate += Clazz.doubleToInt (this.time / 86400000);
573 timeOfDay += (this.time % 86400000);
574 if (timeOfDay >= 86400000) {
575 timeOfDay -= 86400000;
576 ++fixedDate;
577 } else {
578 while (timeOfDay < 0) {
579 timeOfDay += 86400000;
580 --fixedDate;
581 }
582 }fixedDate += 719163;
583 var era = 1;
584 var year;
585 if (fixedDate != this.cachedFixedDate) {
586 java.util.GregorianCalendar.gcal.getCalendarDateFromFixedDate (this.gdate, fixedDate);
587 this.cachedFixedDate = fixedDate;
588 }year = this.gdate.getYear ();
589 if (year <= 0) {
590 year = 1 - year;
591 era = 0;
592 }this.calsys = java.util.GregorianCalendar.gcal;
593 this.cdate = this.gdate;
594 this.internalSet (0, era);
595 this.internalSet (1, year);
596 var mask = fieldMask | (3);
597 var month = this.cdate.getMonth () - 1;
598 var dayOfMonth = this.cdate.getDayOfMonth ();
599 if ((fieldMask & (164)) != 0) {
600 this.internalSet (2, month);
601 this.internalSet (5, dayOfMonth);
602 this.internalSet (7, this.cdate.getDayOfWeek ());
603 mask |= 164;
604 }if ((fieldMask & (32256)) != 0) {
605 if (timeOfDay != 0) {
606 var hours = Clazz.doubleToInt (timeOfDay / 3600000);
607 this.internalSet (11, hours);
608 this.internalSet (9, Clazz.doubleToInt (hours / 12));
609 this.internalSet (10, hours % 12);
610 var r = timeOfDay % 3600000;
611 this.internalSet (12, Clazz.doubleToInt (r / 60000));
612 r %= 60000;
613 this.internalSet (13, Clazz.doubleToInt (r / 1000));
614 this.internalSet (14, r % 1000);
615 } else {
616 this.internalSet (11, 0);
617 this.internalSet (9, 0);
618 this.internalSet (10, 0);
619 this.internalSet (12, 0);
620 this.internalSet (13, 0);
621 this.internalSet (14, 0);
622 }mask |= (32256);
623 }if ((fieldMask & (98304)) != 0) {
624 this.internalSet (15, this.zoneOffsets[0]);
625 this.internalSet (16, this.zoneOffsets[1]);
626 mask |= (98304);
627 }if ((fieldMask & (344)) != 0) {
628 var normalizedYear = this.cdate.getNormalizedYear ();
629 var fixedDateJan1 = this.calsys.getFixedDate (normalizedYear, 1, 1, this.cdate);
630 var dayOfYear = (fixedDate - fixedDateJan1) + 1;
631 var fixedDateMonth1 = fixedDate - dayOfMonth + 1;
632 var cutoverYear = (this.calsys === java.util.GregorianCalendar.gcal) ? this.gregorianCutoverYear : this.gregorianCutoverYearJulian;
633 var relativeDayOfMonth = dayOfMonth - 1;
634 if (normalizedYear == cutoverYear) {
635 var realDayOfYear = (fixedDate - fixedDateJan1) + 1;
636 dayOfYear = realDayOfYear;
637 relativeDayOfMonth = (fixedDate - fixedDateMonth1);
638 }this.internalSet (6, dayOfYear);
639 this.internalSet (8, Clazz.doubleToInt (relativeDayOfMonth / 7) + 1);
640 var weekOfYear = this.getWeekNumber (fixedDateJan1, fixedDate);
641 if (weekOfYear == 0) {
642 var fixedDec31 = fixedDateJan1 - 1;
643 var prevJan1;
644 prevJan1 = fixedDateJan1 - 365;
645 if (jssun.util.calendar.CalendarUtils.isGregorianLeapYear (normalizedYear - 1)) {
646 --prevJan1;
647 }weekOfYear = this.getWeekNumber (prevJan1, fixedDec31);
648 } else {
649 if (normalizedYear > this.gregorianCutoverYear || normalizedYear < (this.gregorianCutoverYearJulian - 1)) {
650 if (weekOfYear >= 52) {
651 var nextJan1 = fixedDateJan1 + 365;
652 if (this.cdate.isLeapYear ()) {
653 nextJan1++;
654 }var nextJan1st = jssun.util.calendar.AbstractCalendar.getDayOfWeekDateOnOrBefore (nextJan1 + 6, this.getFirstDayOfWeek ());
655 var ndays = (nextJan1st - nextJan1);
656 if (ndays >= this.getMinimalDaysInFirstWeek () && fixedDate >= (nextJan1st - 7)) {
657 weekOfYear = 1;
658 }}} else {
659 var calForJan1 = this.calsys;
660 var nextYear = normalizedYear + 1;
661 var nextJan1 = calForJan1.getFixedDate (nextYear, 1, 1, null);
662 if (nextJan1 < fixedDate) {
663 nextJan1 = this.gregorianCutoverDate;
664 calForJan1 = java.util.GregorianCalendar.gcal;
665 }var nextJan1st = jssun.util.calendar.AbstractCalendar.getDayOfWeekDateOnOrBefore (nextJan1 + 6, this.getFirstDayOfWeek ());
666 var ndays = (nextJan1st - nextJan1);
667 if (ndays >= this.getMinimalDaysInFirstWeek () && fixedDate >= (nextJan1st - 7)) {
668 weekOfYear = 1;
669 }}}this.internalSet (3, weekOfYear);
670 this.internalSet (4, this.getWeekNumber (fixedDateMonth1, fixedDate));
671 mask |= (344);
672 }return mask;
673 }, "~N,~N");
674 Clazz.defineMethod (c$, "getWeekNumber", 
675  function (fixedDay1, fixedDate) {
676 var fixedDay1st = jssun.util.calendar.AbstractCalendar.getDayOfWeekDateOnOrBefore (fixedDay1 + 6, this.getFirstDayOfWeek ());
677 var ndays = (fixedDay1st - fixedDay1);
678 if (ndays >= this.getMinimalDaysInFirstWeek ()) {
679 fixedDay1st -= 7;
680 }var normalizedDayOfPeriod = (fixedDate - fixedDay1st);
681 if (normalizedDayOfPeriod >= 0) {
682 return Clazz.doubleToInt (normalizedDayOfPeriod / 7) + 1;
683 }return jssun.util.calendar.CalendarUtils.floorDivide (normalizedDayOfPeriod, 7) + 1;
684 }, "~N,~N");
685 Clazz.overrideMethod (c$, "computeTime", 
686 function () {
687 if (!this.isLenient ()) {
688 if (this.originalFields == null) {
689 this.originalFields =  Clazz.newIntArray (17, 0);
690 }for (var field = 0; field < 17; field++) {
691 var value = this.internalGet (field);
692 if (this.isExternallySet (field)) {
693 if (value < this.getMinimum (field) || value > this.getMaximum (field)) {
694 throw  new IllegalArgumentException (java.util.Calendar.getFieldName (field));
695 }}this.originalFields[field] = value;
696 }
697 }var fieldMask = this.selectFields ();
698 var year = this.isSet (1) ? this.internalGet (1) : 1970;
699 var era = this.internalGetEra ();
700 if (era == 0) {
701 year = 1 - year;
702 } else if (era != 1) {
703 throw  new IllegalArgumentException ("Invalid era");
704 }if (year <= 0 && !this.isSet (0)) {
705 fieldMask |= 1;
706 this.setFieldsComputed (1);
707 }var timeOfDay = 0;
708 if (java.util.Calendar.isFieldSet (fieldMask, 11)) {
709 timeOfDay += this.internalGet (11);
710 } else {
711 timeOfDay += this.internalGet (10);
712 if (java.util.Calendar.isFieldSet (fieldMask, 9)) {
713 timeOfDay += 12 * this.internalGet (9);
714 }}timeOfDay *= 60;
715 timeOfDay += this.internalGet (12);
716 timeOfDay *= 60;
717 timeOfDay += this.internalGet (13);
718 timeOfDay *= 1000;
719 timeOfDay += this.internalGet (14);
720 var fixedDate = Clazz.doubleToInt (timeOfDay / 86400000);
721 timeOfDay %= 86400000;
722 while (timeOfDay < 0) {
723 timeOfDay += 86400000;
724 --fixedDate;
725 }
726 calculateFixedDate : {
727 var gfd;
728 gfd = fixedDate + this.getFixedDate (java.util.GregorianCalendar.gcal, year, fieldMask);
729 fixedDate = gfd;
730 break calculateFixedDate;
731 }var millis = (fixedDate - 719163) * 86400000 + timeOfDay;
732 var zone = this.getZone ();
733 if (this.zoneOffsets == null) {
734 this.zoneOffsets =  Clazz.newIntArray (2, 0);
735 }var tzMask = fieldMask & (98304);
736 if (tzMask != (98304)) {
737 if (Clazz.instanceOf (zone, jssun.util.calendar.ZoneInfo)) {
738 (zone).getOffsetsByWall (millis, this.zoneOffsets);
739 } else {
740 var gmtOffset = java.util.Calendar.isFieldSet (fieldMask, 15) ? this.internalGet (15) : zone.getRawOffset ();
741 zone.getOffsets (millis - gmtOffset, this.zoneOffsets);
742 }}if (tzMask != 0) {
743 if (java.util.Calendar.isFieldSet (tzMask, 15)) {
744 this.zoneOffsets[0] = this.internalGet (15);
745 }if (java.util.Calendar.isFieldSet (tzMask, 16)) {
746 this.zoneOffsets[1] = this.internalGet (16);
747 }}millis -= this.zoneOffsets[0] + this.zoneOffsets[1];
748 this.time = millis;
749 var mask = this.computeFields (fieldMask | this.getSetStateFields (), tzMask);
750 if (!this.isLenient ()) {
751 for (var field = 0; field < 17; field++) {
752 if (!this.isExternallySet (field)) {
753 continue;
754 }if (this.originalFields[field] != this.internalGet (field)) {
755 System.arraycopy (this.originalFields, 0, this.fields, 0, this.fields.length);
756 throw  new IllegalArgumentException (java.util.Calendar.getFieldName (field));
757 }}
758 }this.setFieldsNormalized (mask);
759 });
760 Clazz.defineMethod (c$, "getFixedDate", 
761  function (cal, year, fieldMask) {
762 var month = 0;
763 if (java.util.Calendar.isFieldSet (fieldMask, 2)) {
764 month = this.internalGet (2);
765 if (month > 11) {
766 year += Clazz.doubleToInt (month / 12);
767 month %= 12;
768 } else if (month < 0) {
769 var rem =  Clazz.newIntArray (1, 0);
770 year += jssun.util.calendar.CalendarUtils.floorDivide (month, 12, rem);
771 month = rem[0];
772 }}var fixedDate = cal.getFixedDate (year, month + 1, 1, cal === java.util.GregorianCalendar.gcal ? this.gdate : null);
773 if (java.util.Calendar.isFieldSet (fieldMask, 2)) {
774 if (java.util.Calendar.isFieldSet (fieldMask, 5)) {
775 if (this.isSet (5)) {
776 fixedDate += this.internalGet (5);
777 fixedDate--;
778 }} else {
779 if (java.util.Calendar.isFieldSet (fieldMask, 4)) {
780 var firstDayOfWeek = jssun.util.calendar.AbstractCalendar.getDayOfWeekDateOnOrBefore (fixedDate + 6, this.getFirstDayOfWeek ());
781 if ((firstDayOfWeek - fixedDate) >= this.getMinimalDaysInFirstWeek ()) {
782 firstDayOfWeek -= 7;
783 }if (java.util.Calendar.isFieldSet (fieldMask, 7)) {
784 firstDayOfWeek = jssun.util.calendar.AbstractCalendar.getDayOfWeekDateOnOrBefore (firstDayOfWeek + 6, this.internalGet (7));
785 }fixedDate = firstDayOfWeek + 7 * (this.internalGet (4) - 1);
786 } else {
787 var dayOfWeek;
788 if (java.util.Calendar.isFieldSet (fieldMask, 7)) {
789 dayOfWeek = this.internalGet (7);
790 } else {
791 dayOfWeek = this.getFirstDayOfWeek ();
792 }var dowim;
793 if (java.util.Calendar.isFieldSet (fieldMask, 8)) {
794 dowim = this.internalGet (8);
795 } else {
796 dowim = 1;
797 }if (dowim >= 0) {
798 fixedDate = jssun.util.calendar.AbstractCalendar.getDayOfWeekDateOnOrBefore (fixedDate + (7 * dowim) - 1, dayOfWeek);
799 } else {
800 var lastDate = this.monthLength (month, year) + (7 * (dowim + 1));
801 fixedDate = jssun.util.calendar.AbstractCalendar.getDayOfWeekDateOnOrBefore (fixedDate + lastDate - 1, dayOfWeek);
802 }}}} else {
803 if (year == this.gregorianCutoverYear && cal === java.util.GregorianCalendar.gcal && fixedDate < this.gregorianCutoverDate && this.gregorianCutoverYear != this.gregorianCutoverYearJulian) {
804 fixedDate = this.gregorianCutoverDate;
805 }if (java.util.Calendar.isFieldSet (fieldMask, 6)) {
806 fixedDate += this.internalGet (6);
807 fixedDate--;
808 } else {
809 var firstDayOfWeek = jssun.util.calendar.AbstractCalendar.getDayOfWeekDateOnOrBefore (fixedDate + 6, this.getFirstDayOfWeek ());
810 if ((firstDayOfWeek - fixedDate) >= this.getMinimalDaysInFirstWeek ()) {
811 firstDayOfWeek -= 7;
812 }if (java.util.Calendar.isFieldSet (fieldMask, 7)) {
813 var dayOfWeek = this.internalGet (7);
814 if (dayOfWeek != this.getFirstDayOfWeek ()) {
815 firstDayOfWeek = jssun.util.calendar.AbstractCalendar.getDayOfWeekDateOnOrBefore (firstDayOfWeek + 6, dayOfWeek);
816 }}fixedDate = firstDayOfWeek + 7 * (this.internalGet (3) - 1);
817 }}return fixedDate;
818 }, "jssun.util.calendar.BaseCalendar,~N,~N");
819 Clazz.defineMethod (c$, "getNormalizedCalendar", 
820  function () {
821 var gc;
822 if (this.isFullyNormalized ()) {
823 gc = this;
824 } else {
825 gc = this.clone ();
826 gc.setLenient (true);
827 gc.complete ();
828 }return gc;
829 });
830 Clazz.defineMethod (c$, "getCalendarDate", 
831  function (fd) {
832 var cal = java.util.GregorianCalendar.gcal;
833 var d = cal.newCalendarDate (java.util.TimeZone.NO_TIMEZONE);
834 cal.getCalendarDateFromFixedDate (d, fd);
835 return d;
836 }, "~N");
837 Clazz.defineMethod (c$, "monthLength", 
838  function (month, year) {
839 return this.isLeapYear (year) ? java.util.GregorianCalendar.LEAP_MONTH_LENGTH[month] : java.util.GregorianCalendar.MONTH_LENGTH[month];
840 }, "~N,~N");
841 Clazz.defineMethod (c$, "monthLength", 
842  function (month) {
843 var year = this.internalGet (1);
844 if (this.internalGetEra () == 0) {
845 year = 1 - year;
846 }return this.monthLength (month, year);
847 }, "~N");
848 Clazz.defineMethod (c$, "pinDayOfMonth", 
849  function () {
850 var year = this.internalGet (1);
851 var monthLen;
852 if (year > this.gregorianCutoverYear || year < this.gregorianCutoverYearJulian) {
853 monthLen = this.monthLength (this.internalGet (2));
854 } else {
855 var gc = this.getNormalizedCalendar ();
856 monthLen = gc.getActualMaximum (5);
857 }var dom = this.internalGet (5);
858 if (dom > monthLen) {
859 this.set (5, monthLen);
860 }});
861 Clazz.defineMethod (c$, "getCurrentFixedDate", 
862  function () {
863 return (this.calsys === java.util.GregorianCalendar.gcal) ? this.cachedFixedDate : this.calsys.getFixedDate (this.cdate);
864 });
865 c$.getRolledValue = Clazz.defineMethod (c$, "getRolledValue", 
866  function (value, amount, min, max) {
867 var range = max - min + 1;
868 amount %= range;
869 var n = value + amount;
870 if (n > max) {
871 n -= range;
872 } else if (n < min) {
873 n += range;
874 }return n;
875 }, "~N,~N,~N,~N");
876 Clazz.defineMethod (c$, "internalGetEra", 
877  function () {
878 return this.isSet (0) ? this.internalGet (0) : 1;
879 });
880 Clazz.defineStatics (c$,
881 "BC", 0,
882 "BCE", 0,
883 "AD", 1,
884 "CE", 1,
885 "EPOCH_OFFSET", 719163,
886 "EPOCH_YEAR", 1970,
887 "MONTH_LENGTH",  Clazz.newIntArray (-1, [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]),
888 "LEAP_MONTH_LENGTH",  Clazz.newIntArray (-1, [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]),
889 "ONE_SECOND", 1000,
890 "ONE_MINUTE", 60000,
891 "ONE_HOUR", 3600000,
892 "ONE_DAY", 86400000,
893 "MIN_VALUES",  Clazz.newIntArray (-1, [0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, -46800000, 0]),
894 "LEAST_MAX_VALUES",  Clazz.newIntArray (-1, [1, 292269054, 11, 52, 4, 28, 365, 7, 4, 1, 11, 23, 59, 59, 999, 50400000, 1200000]),
895 "MAX_VALUES",  Clazz.newIntArray (-1, [1, 292278994, 11, 53, 6, 31, 366, 7, 6, 1, 11, 23, 59, 59, 999, 50400000, 7200000]));
896 c$.gcal = c$.prototype.gcal = jssun.util.calendar.CalendarSystem.getGregorianCalendar ();
897 Clazz.defineStatics (c$,
898 "DEFAULT_GREGORIAN_CUTOVER", -12219292800000);
899 });