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