Merge branch 'master' of https://source.jalview.org/git/jalviewjs.git
[jalviewjs.git] / site / swingjs / j2s / jssun / util / calendar / CalendarDate.js
1 Clazz.declarePackage ("jssun.util.calendar");
2 Clazz.load (null, "jssun.util.calendar.CalendarDate", ["java.lang.InternalError", "$.StringBuilder", "java.util.TimeZone", "jssun.util.calendar.CalendarUtils"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.era = null;
5 this.year = 0;
6 this.month = 0;
7 this.dayOfMonth = 0;
8 this.dayOfWeek = -2147483648;
9 this.leapYear = false;
10 this.hours = 0;
11 this.minutes = 0;
12 this.seconds = 0;
13 this.millis = 0;
14 this.fraction = 0;
15 this.normalized = false;
16 this.zoneinfo = null;
17 this.zoneOffset = 0;
18 this.daylightSaving = 0;
19 this.forceStandardTime = false;
20 this.locale = null;
21 Clazz.instantialize (this, arguments);
22 }, jssun.util.calendar, "CalendarDate", null, Cloneable);
23 Clazz.makeConstructor (c$, 
24 function () {
25 this.construct (java.util.TimeZone.getDefault ());
26 });
27 Clazz.makeConstructor (c$, 
28 function (zone) {
29 this.zoneinfo = zone;
30 }, "java.util.TimeZone");
31 Clazz.defineMethod (c$, "getEra", 
32 function () {
33 return this.era;
34 });
35 Clazz.defineMethod (c$, "setEra", 
36 function (era) {
37 if (this.era === era) {
38 return this;
39 }this.era = era;
40 this.normalized = false;
41 return this;
42 }, "jssun.util.calendar.Era");
43 Clazz.defineMethod (c$, "getYear", 
44 function () {
45 return this.year;
46 });
47 Clazz.defineMethod (c$, "setYear", 
48 function (year) {
49 if (this.year != year) {
50 this.year = year;
51 this.normalized = false;
52 }return this;
53 }, "~N");
54 Clazz.defineMethod (c$, "addYear", 
55 function (n) {
56 if (n != 0) {
57 this.year += n;
58 this.normalized = false;
59 }return this;
60 }, "~N");
61 Clazz.defineMethod (c$, "isLeapYear", 
62 function () {
63 return this.leapYear;
64 });
65 Clazz.defineMethod (c$, "setLeapYear", 
66 function (leapYear) {
67 this.leapYear = leapYear;
68 }, "~B");
69 Clazz.defineMethod (c$, "getMonth", 
70 function () {
71 return this.month;
72 });
73 Clazz.defineMethod (c$, "setMonth", 
74 function (month) {
75 if (this.month != month) {
76 this.month = month;
77 this.normalized = false;
78 }return this;
79 }, "~N");
80 Clazz.defineMethod (c$, "addMonth", 
81 function (n) {
82 if (n != 0) {
83 this.month += n;
84 this.normalized = false;
85 }return this;
86 }, "~N");
87 Clazz.defineMethod (c$, "getDayOfMonth", 
88 function () {
89 return this.dayOfMonth;
90 });
91 Clazz.defineMethod (c$, "setDayOfMonth", 
92 function (date) {
93 if (this.dayOfMonth != date) {
94 this.dayOfMonth = date;
95 this.normalized = false;
96 }return this;
97 }, "~N");
98 Clazz.defineMethod (c$, "addDayOfMonth", 
99 function (n) {
100 if (n != 0) {
101 this.dayOfMonth += n;
102 this.normalized = false;
103 }return this;
104 }, "~N");
105 Clazz.defineMethod (c$, "getDayOfWeek", 
106 function () {
107 if (!this.isNormalized ()) {
108 this.dayOfWeek = -2147483648;
109 }return this.dayOfWeek;
110 });
111 Clazz.defineMethod (c$, "getHours", 
112 function () {
113 return this.hours;
114 });
115 Clazz.defineMethod (c$, "setHours", 
116 function (hours) {
117 if (this.hours != hours) {
118 this.hours = hours;
119 this.normalized = false;
120 }return this;
121 }, "~N");
122 Clazz.defineMethod (c$, "addHours", 
123 function (n) {
124 if (n != 0) {
125 this.hours += n;
126 this.normalized = false;
127 }return this;
128 }, "~N");
129 Clazz.defineMethod (c$, "getMinutes", 
130 function () {
131 return this.minutes;
132 });
133 Clazz.defineMethod (c$, "setMinutes", 
134 function (minutes) {
135 if (this.minutes != minutes) {
136 this.minutes = minutes;
137 this.normalized = false;
138 }return this;
139 }, "~N");
140 Clazz.defineMethod (c$, "addMinutes", 
141 function (n) {
142 if (n != 0) {
143 this.minutes += n;
144 this.normalized = false;
145 }return this;
146 }, "~N");
147 Clazz.defineMethod (c$, "getSeconds", 
148 function () {
149 return this.seconds;
150 });
151 Clazz.defineMethod (c$, "setSeconds", 
152 function (seconds) {
153 if (this.seconds != seconds) {
154 this.seconds = seconds;
155 this.normalized = false;
156 }return this;
157 }, "~N");
158 Clazz.defineMethod (c$, "addSeconds", 
159 function (n) {
160 if (n != 0) {
161 this.seconds += n;
162 this.normalized = false;
163 }return this;
164 }, "~N");
165 Clazz.defineMethod (c$, "getMillis", 
166 function () {
167 return this.millis;
168 });
169 Clazz.defineMethod (c$, "setMillis", 
170 function (millis) {
171 if (this.millis != millis) {
172 this.millis = millis;
173 this.normalized = false;
174 }return this;
175 }, "~N");
176 Clazz.defineMethod (c$, "addMillis", 
177 function (n) {
178 if (n != 0) {
179 this.millis += n;
180 this.normalized = false;
181 }return this;
182 }, "~N");
183 Clazz.defineMethod (c$, "getTimeOfDay", 
184 function () {
185 if (!this.isNormalized ()) {
186 return this.fraction = -9223372036854775808;
187 }return this.fraction;
188 });
189 Clazz.defineMethod (c$, "setDate", 
190 function (year, month, dayOfMonth) {
191 this.setYear (year);
192 this.setMonth (month);
193 this.setDayOfMonth (dayOfMonth);
194 return this;
195 }, "~N,~N,~N");
196 Clazz.defineMethod (c$, "addDate", 
197 function (year, month, dayOfMonth) {
198 this.addYear (year);
199 this.addMonth (month);
200 this.addDayOfMonth (dayOfMonth);
201 return this;
202 }, "~N,~N,~N");
203 Clazz.defineMethod (c$, "setTimeOfDay", 
204 function (hours, minutes, seconds, millis) {
205 this.setHours (hours);
206 this.setMinutes (minutes);
207 this.setSeconds (seconds);
208 this.setMillis (millis);
209 return this;
210 }, "~N,~N,~N,~N");
211 Clazz.defineMethod (c$, "addTimeOfDay", 
212 function (hours, minutes, seconds, millis) {
213 this.addHours (hours);
214 this.addMinutes (minutes);
215 this.addSeconds (seconds);
216 this.addMillis (millis);
217 return this;
218 }, "~N,~N,~N,~N");
219 Clazz.defineMethod (c$, "setTimeOfDay", 
220 function (fraction) {
221 this.fraction = fraction;
222 }, "~N");
223 Clazz.defineMethod (c$, "isNormalized", 
224 function () {
225 return this.normalized;
226 });
227 Clazz.defineMethod (c$, "isStandardTime", 
228 function () {
229 return this.forceStandardTime;
230 });
231 Clazz.defineMethod (c$, "setStandardTime", 
232 function (standardTime) {
233 this.forceStandardTime = standardTime;
234 }, "~B");
235 Clazz.defineMethod (c$, "isDaylightTime", 
236 function () {
237 if (this.isStandardTime ()) {
238 return false;
239 }return this.daylightSaving != 0;
240 });
241 Clazz.defineMethod (c$, "setLocale", 
242 function (loc) {
243 this.locale = loc;
244 }, "java.util.Locale");
245 Clazz.defineMethod (c$, "getZone", 
246 function () {
247 return this.zoneinfo;
248 });
249 Clazz.defineMethod (c$, "setZone", 
250 function (zoneinfo) {
251 this.zoneinfo = zoneinfo;
252 return this;
253 }, "java.util.TimeZone");
254 Clazz.defineMethod (c$, "isSameDate", 
255 function (date) {
256 return this.getDayOfWeek () == date.getDayOfWeek () && this.getMonth () == date.getMonth () && this.getYear () == date.getYear () && this.getEra () === date.getEra ();
257 }, "jssun.util.calendar.CalendarDate");
258 Clazz.defineMethod (c$, "equals", 
259 function (obj) {
260 if (!(Clazz.instanceOf (obj, jssun.util.calendar.CalendarDate))) {
261 return false;
262 }var that = obj;
263 if (this.isNormalized () != that.isNormalized ()) {
264 return false;
265 }var hasZone = this.zoneinfo != null;
266 var thatHasZone = that.zoneinfo != null;
267 if (hasZone != thatHasZone) {
268 return false;
269 }if (hasZone && !this.zoneinfo.equals (that.zoneinfo)) {
270 return false;
271 }return (this.getEra () === that.getEra () && this.year == that.year && this.month == that.month && this.dayOfMonth == that.dayOfMonth && this.hours == that.hours && this.minutes == that.minutes && this.seconds == that.seconds && this.millis == that.millis && this.zoneOffset == that.zoneOffset);
272 }, "~O");
273 Clazz.defineMethod (c$, "hashCode", 
274 function () {
275 var hash = (((((this.year - 1970) * 12) + (this.month - 1)) * 30) + this.dayOfMonth) * 24;
276 hash = ((((((hash + this.hours) * 60) + this.minutes) * 60) + this.seconds) * 1000) + this.millis;
277 hash -= this.zoneOffset;
278 var normalized = this.isNormalized () ? 1 : 0;
279 var era = 0;
280 var e = this.getEra ();
281 if (e != null) {
282 era = e.hashCode ();
283 }var zone = this.zoneinfo != null ? this.zoneinfo.hashCode () : 0;
284 return hash * (hash >> 32) ^ era ^ normalized ^ zone;
285 });
286 Clazz.defineMethod (c$, "clone", 
287 function () {
288 try {
289 return Clazz.superCall (this, jssun.util.calendar.CalendarDate, "clone", []);
290 } catch (e) {
291 if (Clazz.exceptionOf (e, CloneNotSupportedException)) {
292 throw  new InternalError ();
293 } else {
294 throw e;
295 }
296 }
297 });
298 Clazz.overrideMethod (c$, "toString", 
299 function () {
300 var sb =  new StringBuilder ();
301 jssun.util.calendar.CalendarUtils.sprintf0d (sb, this.year, 4).append ('-');
302 jssun.util.calendar.CalendarUtils.sprintf0d (sb, this.month, 2).append ('-');
303 jssun.util.calendar.CalendarUtils.sprintf0d (sb, this.dayOfMonth, 2).append ('T');
304 jssun.util.calendar.CalendarUtils.sprintf0d (sb, this.hours, 2).append (':');
305 jssun.util.calendar.CalendarUtils.sprintf0d (sb, this.minutes, 2).append (':');
306 jssun.util.calendar.CalendarUtils.sprintf0d (sb, this.seconds, 2).append ('.');
307 jssun.util.calendar.CalendarUtils.sprintf0d (sb, this.millis, 3);
308 if (this.zoneOffset == 0) {
309 sb.append ('Z');
310 } else if (this.zoneOffset != -2147483648) {
311 var offset;
312 var sign;
313 if (this.zoneOffset > 0) {
314 offset = this.zoneOffset;
315 sign = '+';
316 } else {
317 offset = -this.zoneOffset;
318 sign = '-';
319 }offset = Clazz.doubleToInt (offset / 60000);
320 sb.append (sign);
321 jssun.util.calendar.CalendarUtils.sprintf0d (sb, Clazz.doubleToInt (offset / 60), 2);
322 jssun.util.calendar.CalendarUtils.sprintf0d (sb, offset % 60, 2);
323 } else {
324 sb.append (" local time");
325 }return sb.toString ();
326 });
327 Clazz.defineMethod (c$, "setDayOfWeek", 
328 function (dayOfWeek) {
329 this.dayOfWeek = dayOfWeek;
330 }, "~N");
331 Clazz.defineMethod (c$, "setNormalized", 
332 function (normalized) {
333 this.normalized = normalized;
334 }, "~B");
335 Clazz.defineMethod (c$, "getZoneOffset", 
336 function () {
337 return this.zoneOffset;
338 });
339 Clazz.defineMethod (c$, "setZoneOffset", 
340 function (offset) {
341 this.zoneOffset = offset;
342 }, "~N");
343 Clazz.defineMethod (c$, "getDaylightSaving", 
344 function () {
345 return this.daylightSaving;
346 });
347 Clazz.defineMethod (c$, "setDaylightSaving", 
348 function (daylightSaving) {
349 this.daylightSaving = daylightSaving;
350 }, "~N");
351 Clazz.defineStatics (c$,
352 "FIELD_UNDEFINED", -2147483648,
353 "TIME_UNDEFINED", -9223372036854775808);
354 });