@js-joda/extra 0.10.2 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/js-joda-extra.esm.js +208 -619
- package/dist/js-joda-extra.esm.js.map +1 -1
- package/dist/js-joda-extra.js +207 -619
- package/dist/js-joda-extra.js.map +1 -1
- package/dist/js-joda-extra.min.js +2 -2
- package/package.json +4 -4
- package/src/Temporals.js +296 -0
- package/src/_init.js +2 -0
- package/src/js-joda-extra.js +2 -0
- package/src/plug.js +2 -0
- package/typings/js-joda-extra.d.ts +12 -2
|
@@ -1,23 +1,20 @@
|
|
|
1
|
-
//! @version @js-joda/extra - 0.
|
|
1
|
+
//! @version @js-joda/extra - 0.11.0
|
|
2
2
|
//! @copyright (c) 2015-present, Philipp Thürwächter, Pattrick Hüper & js-joda contributors
|
|
3
3
|
//! @copyright (c) 2007-present, Stephen Colebourne & Michael Nascimento Santos
|
|
4
4
|
//! @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
|
|
5
5
|
|
|
6
|
-
import { NullPointerException, IllegalArgumentException, _,
|
|
6
|
+
import { NullPointerException, IllegalArgumentException, _, ZoneId, Clock, LocalDate, DateTimeException, ChronoField, UnsupportedTemporalTypeException, TemporalQueries, IsoChronology, Month, MonthDay, TemporalAccessor, TemporalQuery, Year, Duration, Instant, ZonedDateTime, DateTimeParseException, Period, ArithmeticException, ZoneOffset, DateTimeFormatter, TemporalField, TemporalUnit, ChronoUnit, OffsetDateTime, Temporal, IsoFields, IllegalStateException, ParsePosition, TemporalAdjuster, ValueRange, DateTimeFormatterBuilder, SignStyle, DayOfWeek, use } from '@js-joda/core';
|
|
7
7
|
|
|
8
8
|
function _inheritsLoose(subClass, superClass) {
|
|
9
9
|
subClass.prototype = Object.create(superClass.prototype);
|
|
10
10
|
subClass.prototype.constructor = subClass;
|
|
11
|
-
|
|
12
11
|
_setPrototypeOf(subClass, superClass);
|
|
13
12
|
}
|
|
14
|
-
|
|
15
13
|
function _setPrototypeOf(o, p) {
|
|
16
|
-
_setPrototypeOf = Object.setPrototypeOf
|
|
14
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
17
15
|
o.__proto__ = p;
|
|
18
16
|
return o;
|
|
19
17
|
};
|
|
20
|
-
|
|
21
18
|
return _setPrototypeOf(o, p);
|
|
22
19
|
}
|
|
23
20
|
|
|
@@ -38,57 +35,45 @@ function requireNonNull(value, parameterName) {
|
|
|
38
35
|
if (value == null) {
|
|
39
36
|
throw new NullPointerException(parameterName + " must not be null");
|
|
40
37
|
}
|
|
41
|
-
|
|
42
38
|
return value;
|
|
43
39
|
}
|
|
44
40
|
function requireInstance(value, _class, parameterName) {
|
|
45
41
|
if (!(value instanceof _class)) {
|
|
46
42
|
throw new IllegalArgumentException(parameterName + " must be an instance of " + (_class.name ? _class.name : _class) + (value && value.constructor && value.constructor.name ? ", but is " + value.constructor.name : ''));
|
|
47
43
|
}
|
|
48
|
-
|
|
49
44
|
return value;
|
|
50
45
|
}
|
|
51
46
|
|
|
52
|
-
var MathUtil$
|
|
47
|
+
var MathUtil$6 = _.MathUtil;
|
|
53
48
|
var DayOfMonth = function (_TemporalAccessor) {
|
|
54
49
|
_inheritsLoose(DayOfMonth, _TemporalAccessor);
|
|
55
|
-
|
|
56
50
|
DayOfMonth.now = function now(zoneIdOrClock) {
|
|
57
51
|
switch (arguments.length) {
|
|
58
52
|
case 0:
|
|
59
53
|
return DayOfMonth._now0();
|
|
60
|
-
|
|
61
54
|
case 1:
|
|
62
55
|
requireNonNull(zoneIdOrClock, 'clockOrZone');
|
|
63
|
-
|
|
64
56
|
if (zoneIdOrClock instanceof ZoneId) {
|
|
65
57
|
return DayOfMonth._nowZoneId(zoneIdOrClock);
|
|
66
58
|
}
|
|
67
|
-
|
|
68
59
|
if (zoneIdOrClock instanceof Clock) {
|
|
69
60
|
return DayOfMonth._nowClock(zoneIdOrClock);
|
|
70
61
|
}
|
|
71
|
-
|
|
72
62
|
throw new IllegalArgumentException("zoneIdOrClock must be an instance of ZoneId or Clock, but is " + zoneIdOrClock.constructor.name);
|
|
73
|
-
|
|
74
63
|
default:
|
|
75
64
|
throw new IllegalArgumentException("Invalid number of arguments: " + arguments.length);
|
|
76
65
|
}
|
|
77
66
|
};
|
|
78
|
-
|
|
79
67
|
DayOfMonth._now0 = function _now0() {
|
|
80
68
|
return this.now(Clock.systemDefaultZone());
|
|
81
69
|
};
|
|
82
|
-
|
|
83
70
|
DayOfMonth._nowZoneId = function _nowZoneId(zone) {
|
|
84
71
|
return this.now(Clock.system(zone));
|
|
85
72
|
};
|
|
86
|
-
|
|
87
73
|
DayOfMonth._nowClock = function _nowClock(clock) {
|
|
88
74
|
var now = LocalDate.now(clock);
|
|
89
75
|
return DayOfMonth.of(now.dayOfMonth());
|
|
90
76
|
};
|
|
91
|
-
|
|
92
77
|
DayOfMonth.of = function of(dayOfMonth) {
|
|
93
78
|
if (1 <= dayOfMonth && dayOfMonth <= 31) {
|
|
94
79
|
return DayOfMonth.VALUES[dayOfMonth - 1];
|
|
@@ -96,180 +81,138 @@ var DayOfMonth = function (_TemporalAccessor) {
|
|
|
96
81
|
throw new DateTimeException("Invalid value for DayOfMonth: " + dayOfMonth);
|
|
97
82
|
}
|
|
98
83
|
};
|
|
99
|
-
|
|
100
84
|
DayOfMonth.from = function from(temporal) {
|
|
101
85
|
if (temporal instanceof DayOfMonth) {
|
|
102
86
|
return temporal;
|
|
103
87
|
}
|
|
104
|
-
|
|
105
88
|
requireNonNull(temporal, 'temporal');
|
|
106
|
-
|
|
107
89
|
try {
|
|
108
90
|
return DayOfMonth.of(temporal.get(ChronoField.DAY_OF_MONTH));
|
|
109
91
|
} catch (ex) {
|
|
110
92
|
throw new DateTimeException("Unable to obtain DayOfMonth from TemporalAccessor: " + temporal + " of type " + temporal.constructor.name, ex);
|
|
111
93
|
}
|
|
112
94
|
};
|
|
113
|
-
|
|
114
95
|
function DayOfMonth(dayOfMonth) {
|
|
115
96
|
var _this;
|
|
116
|
-
|
|
117
97
|
_this = _TemporalAccessor.call(this) || this;
|
|
118
|
-
_this._day = MathUtil$
|
|
98
|
+
_this._day = MathUtil$6.safeToInt(dayOfMonth);
|
|
119
99
|
return _this;
|
|
120
100
|
}
|
|
121
|
-
|
|
122
101
|
var _proto = DayOfMonth.prototype;
|
|
123
|
-
|
|
124
102
|
_proto.value = function value() {
|
|
125
103
|
return this._day;
|
|
126
104
|
};
|
|
127
|
-
|
|
128
105
|
_proto.isSupported = function isSupported(field) {
|
|
129
106
|
if (field instanceof ChronoField) {
|
|
130
107
|
return field === ChronoField.DAY_OF_MONTH;
|
|
131
108
|
}
|
|
132
|
-
|
|
133
109
|
return field != null && field.isSupportedBy(this);
|
|
134
110
|
};
|
|
135
|
-
|
|
136
111
|
_proto.range = function range(field) {
|
|
137
112
|
requireNonNull(field, 'field');
|
|
138
|
-
|
|
139
113
|
if (field === ChronoField.DAY_OF_MONTH) {
|
|
140
114
|
return field.range();
|
|
141
115
|
}
|
|
142
|
-
|
|
143
116
|
return _TemporalAccessor.prototype.range.call(this, field);
|
|
144
117
|
};
|
|
145
|
-
|
|
146
118
|
_proto.get = function get(field) {
|
|
147
119
|
return this.range(field).checkValidIntValue(this.getLong(field), field);
|
|
148
120
|
};
|
|
149
|
-
|
|
150
121
|
_proto.getLong = function getLong(field) {
|
|
151
122
|
requireNonNull(field, 'field');
|
|
152
|
-
|
|
153
123
|
if (field === ChronoField.DAY_OF_MONTH) {
|
|
154
124
|
return this._day;
|
|
155
125
|
} else if (field instanceof ChronoField) {
|
|
156
126
|
throw new UnsupportedTemporalTypeException("Unsupported field: " + field);
|
|
157
127
|
}
|
|
158
|
-
|
|
159
128
|
return field.getFrom(this);
|
|
160
129
|
};
|
|
161
|
-
|
|
162
130
|
_proto.isValidYearMonth = function isValidYearMonth(yearMonth) {
|
|
163
131
|
return yearMonth != null && yearMonth.isValidDay(this._day);
|
|
164
132
|
};
|
|
165
|
-
|
|
166
133
|
_proto.query = function query(_query) {
|
|
167
134
|
requireNonNull(_query, 'query');
|
|
168
135
|
requireInstance(_query, TemporalQuery, 'query');
|
|
169
|
-
|
|
170
136
|
if (_query === TemporalQueries.chronology()) {
|
|
171
137
|
return IsoChronology.INSTANCE;
|
|
172
138
|
}
|
|
173
|
-
|
|
174
139
|
return _TemporalAccessor.prototype.query.call(this, _query);
|
|
175
140
|
};
|
|
176
|
-
|
|
177
141
|
_proto.adjustInto = function adjustInto(temporal) {
|
|
178
142
|
requireNonNull(temporal, 'temporal');
|
|
179
143
|
return temporal.with(ChronoField.DAY_OF_MONTH, this._day);
|
|
180
144
|
};
|
|
181
|
-
|
|
182
145
|
_proto.atMonth = function atMonth(month) {
|
|
183
146
|
requireNonNull(month, 'month');
|
|
184
|
-
|
|
185
147
|
if (month instanceof Month) {
|
|
186
148
|
return MonthDay.of(month, Math.min(this._day, month.maxLength()));
|
|
187
149
|
} else {
|
|
188
150
|
return MonthDay.of(month, Math.min(this._day, Month.of(month).maxLength()));
|
|
189
151
|
}
|
|
190
152
|
};
|
|
191
|
-
|
|
192
153
|
_proto.atYearMonth = function atYearMonth(yearMonth) {
|
|
193
154
|
requireNonNull(yearMonth, 'yearMonth');
|
|
194
155
|
return yearMonth.atDay(Math.min(this._day, yearMonth.lengthOfMonth()));
|
|
195
156
|
};
|
|
196
|
-
|
|
197
157
|
_proto.compareTo = function compareTo(other) {
|
|
198
158
|
requireNonNull(other, 'other');
|
|
199
159
|
requireInstance(other, DayOfMonth, 'other');
|
|
200
160
|
return this._day - other._day;
|
|
201
161
|
};
|
|
202
|
-
|
|
203
162
|
_proto.equals = function equals(obj) {
|
|
204
163
|
if (this === obj) {
|
|
205
164
|
return true;
|
|
206
165
|
}
|
|
207
|
-
|
|
208
166
|
if (obj instanceof DayOfMonth) {
|
|
209
167
|
return this._day === obj._day;
|
|
210
168
|
}
|
|
211
|
-
|
|
212
169
|
return false;
|
|
213
170
|
};
|
|
214
|
-
|
|
215
171
|
_proto.hashCode = function hashCode() {
|
|
216
172
|
return this._day;
|
|
217
173
|
};
|
|
218
|
-
|
|
219
174
|
_proto.toString = function toString() {
|
|
220
175
|
return "DayOfMonth:" + this._day;
|
|
221
176
|
};
|
|
222
|
-
|
|
223
177
|
return DayOfMonth;
|
|
224
178
|
}(TemporalAccessor);
|
|
225
|
-
function _init$
|
|
179
|
+
function _init$8() {
|
|
226
180
|
DayOfMonth.VALUES = new Array(31);
|
|
227
|
-
|
|
228
181
|
for (var i = 0; i < 31; i++) {
|
|
229
182
|
DayOfMonth.VALUES[i] = new DayOfMonth(i + 1);
|
|
230
183
|
}
|
|
231
184
|
}
|
|
232
185
|
|
|
233
|
-
var MathUtil$
|
|
186
|
+
var MathUtil$5 = _.MathUtil;
|
|
234
187
|
var DayOfYear = function (_TemporalAccessor) {
|
|
235
188
|
_inheritsLoose(DayOfYear, _TemporalAccessor);
|
|
236
|
-
|
|
237
189
|
DayOfYear.now = function now(zoneIdOrClock) {
|
|
238
190
|
switch (arguments.length) {
|
|
239
191
|
case 0:
|
|
240
192
|
return DayOfYear._now0();
|
|
241
|
-
|
|
242
193
|
case 1:
|
|
243
194
|
requireNonNull(zoneIdOrClock, 'clockOrZone');
|
|
244
|
-
|
|
245
195
|
if (zoneIdOrClock instanceof ZoneId) {
|
|
246
196
|
return DayOfYear._nowZoneId(zoneIdOrClock);
|
|
247
197
|
}
|
|
248
|
-
|
|
249
198
|
if (zoneIdOrClock instanceof Clock) {
|
|
250
199
|
return DayOfYear._nowClock(zoneIdOrClock);
|
|
251
200
|
}
|
|
252
|
-
|
|
253
201
|
throw new IllegalArgumentException("zoneIdOrClock must be an instance of ZoneId or Clock, but is " + zoneIdOrClock.constructor.name);
|
|
254
|
-
|
|
255
202
|
default:
|
|
256
203
|
throw new IllegalArgumentException("Invalid number of arguments: " + arguments.length);
|
|
257
204
|
}
|
|
258
205
|
};
|
|
259
|
-
|
|
260
206
|
DayOfYear._now0 = function _now0() {
|
|
261
207
|
return DayOfYear.now(Clock.systemDefaultZone());
|
|
262
208
|
};
|
|
263
|
-
|
|
264
209
|
DayOfYear._nowZoneId = function _nowZoneId(zone) {
|
|
265
210
|
return DayOfYear.now(Clock.system(zone));
|
|
266
211
|
};
|
|
267
|
-
|
|
268
212
|
DayOfYear._nowClock = function _nowClock(clock) {
|
|
269
213
|
var now = LocalDate.now(clock);
|
|
270
214
|
return DayOfYear.of(now.dayOfYear());
|
|
271
215
|
};
|
|
272
|
-
|
|
273
216
|
DayOfYear.of = function of(dayOfYear) {
|
|
274
217
|
if (1 <= dayOfYear && dayOfYear <= 366) {
|
|
275
218
|
return DayOfYear.VALUES[dayOfYear - 1];
|
|
@@ -277,131 +220,100 @@ var DayOfYear = function (_TemporalAccessor) {
|
|
|
277
220
|
throw new DateTimeException("Invalid value for DayOfYear: " + dayOfYear);
|
|
278
221
|
}
|
|
279
222
|
};
|
|
280
|
-
|
|
281
223
|
DayOfYear.from = function from(temporal) {
|
|
282
224
|
requireNonNull(temporal, 'temporal');
|
|
283
225
|
requireInstance(temporal, TemporalAccessor, 'temporal');
|
|
284
|
-
|
|
285
226
|
if (temporal instanceof DayOfYear) {
|
|
286
227
|
return temporal;
|
|
287
228
|
}
|
|
288
|
-
|
|
289
229
|
try {
|
|
290
230
|
return DayOfYear.of(temporal.get(ChronoField.DAY_OF_YEAR));
|
|
291
231
|
} catch (ex) {
|
|
292
232
|
throw new DateTimeException("Unable to obtain DayOfYear from TemporalAccessor: " + temporal + " of type " + temporal.constructor.name, ex);
|
|
293
233
|
}
|
|
294
234
|
};
|
|
295
|
-
|
|
296
235
|
function DayOfYear(dayOfYear) {
|
|
297
236
|
var _this;
|
|
298
|
-
|
|
299
237
|
_this = _TemporalAccessor.call(this) || this;
|
|
300
|
-
_this._day = MathUtil$
|
|
238
|
+
_this._day = MathUtil$5.safeToInt(dayOfYear);
|
|
301
239
|
return _this;
|
|
302
240
|
}
|
|
303
|
-
|
|
304
241
|
var _proto = DayOfYear.prototype;
|
|
305
|
-
|
|
306
242
|
_proto.value = function value() {
|
|
307
243
|
return this._day;
|
|
308
244
|
};
|
|
309
|
-
|
|
310
245
|
_proto.isSupported = function isSupported(field) {
|
|
311
246
|
if (field instanceof ChronoField) {
|
|
312
247
|
return field === ChronoField.DAY_OF_YEAR;
|
|
313
248
|
}
|
|
314
|
-
|
|
315
249
|
return field != null && field.isSupportedBy(this);
|
|
316
250
|
};
|
|
317
|
-
|
|
318
251
|
_proto.range = function range(field) {
|
|
319
252
|
requireNonNull(field, 'field');
|
|
320
|
-
|
|
321
253
|
if (field === ChronoField.DAY_OF_YEAR) {
|
|
322
254
|
return field.range();
|
|
323
255
|
}
|
|
324
|
-
|
|
325
256
|
return _TemporalAccessor.prototype.range.call(this, field);
|
|
326
257
|
};
|
|
327
|
-
|
|
328
258
|
_proto.get = function get(field) {
|
|
329
259
|
return this.range(field).checkValidIntValue(this.getLong(field), field);
|
|
330
260
|
};
|
|
331
|
-
|
|
332
261
|
_proto.getLong = function getLong(field) {
|
|
333
262
|
requireNonNull(field, 'field');
|
|
334
|
-
|
|
335
263
|
if (field === ChronoField.DAY_OF_YEAR) {
|
|
336
264
|
return this._day;
|
|
337
265
|
} else if (field instanceof ChronoField) {
|
|
338
266
|
throw new UnsupportedTemporalTypeException("Unsupported field: " + field);
|
|
339
267
|
}
|
|
340
|
-
|
|
341
268
|
return field.getFrom(this);
|
|
342
269
|
};
|
|
343
|
-
|
|
344
270
|
_proto.isValidYear = function isValidYear(year) {
|
|
345
271
|
return this._day < 366 || Year.isLeap(year);
|
|
346
272
|
};
|
|
347
|
-
|
|
348
273
|
_proto.query = function query(_query) {
|
|
349
274
|
requireNonNull(_query, 'query');
|
|
350
275
|
requireInstance(_query, TemporalQuery, 'query');
|
|
351
|
-
|
|
352
276
|
if (_query === TemporalQueries.chronology()) {
|
|
353
277
|
return IsoChronology.INSTANCE;
|
|
354
278
|
}
|
|
355
|
-
|
|
356
279
|
return _TemporalAccessor.prototype.query.call(this, _query);
|
|
357
280
|
};
|
|
358
|
-
|
|
359
281
|
_proto.adjustInto = function adjustInto(temporal) {
|
|
360
282
|
requireNonNull(temporal, 'temporal');
|
|
361
283
|
return temporal.with(ChronoField.DAY_OF_YEAR, this._day);
|
|
362
284
|
};
|
|
363
|
-
|
|
364
285
|
_proto.atYear = function atYear(year) {
|
|
365
286
|
requireNonNull(year, 'year');
|
|
366
|
-
|
|
367
287
|
if (year instanceof Year) {
|
|
368
288
|
return year.atDay(this._day);
|
|
369
289
|
} else {
|
|
370
290
|
return LocalDate.ofYearDay(year, this._day);
|
|
371
291
|
}
|
|
372
292
|
};
|
|
373
|
-
|
|
374
293
|
_proto.compareTo = function compareTo(other) {
|
|
375
294
|
requireNonNull(other, 'other');
|
|
376
295
|
requireInstance(other, DayOfYear, 'other');
|
|
377
296
|
return this._day - other._day;
|
|
378
297
|
};
|
|
379
|
-
|
|
380
298
|
_proto.equals = function equals(obj) {
|
|
381
299
|
if (this === obj) {
|
|
382
300
|
return true;
|
|
383
301
|
}
|
|
384
|
-
|
|
385
302
|
if (obj instanceof DayOfYear) {
|
|
386
303
|
return this._day === obj._day;
|
|
387
304
|
}
|
|
388
|
-
|
|
389
305
|
return false;
|
|
390
306
|
};
|
|
391
|
-
|
|
392
307
|
_proto.hashCode = function hashCode() {
|
|
393
308
|
return this._day;
|
|
394
309
|
};
|
|
395
|
-
|
|
396
310
|
_proto.toString = function toString() {
|
|
397
311
|
return "DayOfYear:" + this._day;
|
|
398
312
|
};
|
|
399
|
-
|
|
400
313
|
return DayOfYear;
|
|
401
314
|
}(TemporalAccessor);
|
|
402
|
-
function _init$
|
|
315
|
+
function _init$7() {
|
|
403
316
|
DayOfYear.VALUES = new Array(366);
|
|
404
|
-
|
|
405
317
|
for (var i = 0; i < 366; i++) {
|
|
406
318
|
DayOfYear.VALUES[i] = new DayOfYear(i + 1);
|
|
407
319
|
}
|
|
@@ -420,148 +332,113 @@ var Interval = function () {
|
|
|
420
332
|
return Interval.ofInstantInstant(startInstant, endInstantOrDuration);
|
|
421
333
|
}
|
|
422
334
|
};
|
|
423
|
-
|
|
424
335
|
Interval.ofInstantInstant = function ofInstantInstant(startInclusive, endExclusive) {
|
|
425
336
|
requireNonNull(startInclusive, 'startInclusive');
|
|
426
337
|
requireNonNull(endExclusive, 'endExclusive');
|
|
427
338
|
requireInstance(startInclusive, Instant, 'startInclusive');
|
|
428
339
|
requireInstance(endExclusive, Instant, 'endExclusive');
|
|
429
|
-
|
|
430
340
|
if (endExclusive.isBefore(startInclusive)) {
|
|
431
341
|
throw new DateTimeException('End instant must on or after start instant');
|
|
432
342
|
}
|
|
433
|
-
|
|
434
343
|
return new Interval(startInclusive, endExclusive);
|
|
435
344
|
};
|
|
436
|
-
|
|
437
345
|
Interval.ofInstantDuration = function ofInstantDuration(startInclusive, duration) {
|
|
438
346
|
requireNonNull(startInclusive, 'startInclusive');
|
|
439
347
|
requireNonNull(duration, 'duration');
|
|
440
348
|
requireInstance(startInclusive, Instant, 'startInclusive');
|
|
441
349
|
requireInstance(duration, Duration, 'duration');
|
|
442
|
-
|
|
443
350
|
if (duration.isNegative()) {
|
|
444
351
|
throw new DateTimeException('Duration must not be zero or negative');
|
|
445
352
|
}
|
|
446
|
-
|
|
447
353
|
return new Interval(startInclusive, startInclusive.plus(duration));
|
|
448
354
|
};
|
|
449
|
-
|
|
450
355
|
Interval.parse = function parse(text) {
|
|
451
356
|
requireNonNull(text, 'text');
|
|
452
|
-
|
|
453
357
|
if (!(typeof text === 'string')) {
|
|
454
358
|
throw new IllegalArgumentException("text must be a string, but is " + text.constructor.name);
|
|
455
359
|
}
|
|
456
|
-
|
|
457
360
|
for (var i = 0; i < text.length; i += 1) {
|
|
458
361
|
if (text.charAt(i) === '/') {
|
|
459
362
|
var firstChar = text.charAt(0);
|
|
460
|
-
|
|
461
363
|
if (firstChar === 'P' || firstChar === 'p') {
|
|
462
364
|
var duration = Duration.parse(text.substring(0, i));
|
|
463
365
|
var end = ZonedDateTime.parse(text.substring(i + 1, text.length)).toInstant();
|
|
464
366
|
return Interval.of(end.minus(duration), end);
|
|
465
367
|
} else {
|
|
466
368
|
var start = ZonedDateTime.parse(text.substring(0, i)).toInstant();
|
|
467
|
-
|
|
468
369
|
if (i + 1 < text.length) {
|
|
469
370
|
var c = text.charAt(i + 1);
|
|
470
|
-
|
|
471
371
|
if (c === 'P' || c === 'p') {
|
|
472
372
|
var _duration = Duration.parse(text.substring(i + 1, text.length));
|
|
473
|
-
|
|
474
373
|
return Interval.of(start, start.plus(_duration));
|
|
475
374
|
}
|
|
476
375
|
}
|
|
477
|
-
|
|
478
376
|
var _end = ZonedDateTime.parse(text.substring(i + 1, text.length)).toInstant();
|
|
479
|
-
|
|
480
377
|
return Interval.of(start, _end);
|
|
481
378
|
}
|
|
482
379
|
}
|
|
483
380
|
}
|
|
484
|
-
|
|
485
381
|
throw new DateTimeParseException('Interval cannot be parsed, no forward slash found', text, 0);
|
|
486
382
|
};
|
|
487
|
-
|
|
488
383
|
function Interval(startInclusive, endExclusive) {
|
|
489
384
|
this._start = startInclusive;
|
|
490
385
|
this._end = endExclusive;
|
|
491
386
|
}
|
|
492
|
-
|
|
493
387
|
var _proto = Interval.prototype;
|
|
494
|
-
|
|
495
388
|
_proto.start = function start() {
|
|
496
389
|
return this._start;
|
|
497
390
|
};
|
|
498
|
-
|
|
499
391
|
_proto.end = function end() {
|
|
500
392
|
return this._end;
|
|
501
393
|
};
|
|
502
|
-
|
|
503
394
|
_proto.isEmpty = function isEmpty() {
|
|
504
395
|
return this._start.equals(this._end);
|
|
505
396
|
};
|
|
506
|
-
|
|
507
397
|
_proto.isUnboundedStart = function isUnboundedStart() {
|
|
508
398
|
return this._start.equals(Instant.MIN);
|
|
509
399
|
};
|
|
510
|
-
|
|
511
400
|
_proto.isUnboundedEnd = function isUnboundedEnd() {
|
|
512
401
|
return this._end.equals(Instant.MAX);
|
|
513
402
|
};
|
|
514
|
-
|
|
515
403
|
_proto.withStart = function withStart(start) {
|
|
516
404
|
return Interval.of(start, this._end);
|
|
517
405
|
};
|
|
518
|
-
|
|
519
406
|
_proto.withEnd = function withEnd(end) {
|
|
520
407
|
return Interval.of(this._start, end);
|
|
521
408
|
};
|
|
522
|
-
|
|
523
409
|
_proto.contains = function contains(instant) {
|
|
524
410
|
requireNonNull(instant, 'instant');
|
|
525
411
|
requireInstance(instant, Instant, 'instant');
|
|
526
412
|
return this._start.compareTo(instant) <= 0 && (instant.compareTo(this._end) < 0 || this.isUnboundedEnd());
|
|
527
413
|
};
|
|
528
|
-
|
|
529
414
|
_proto.encloses = function encloses(other) {
|
|
530
415
|
requireNonNull(other, 'other');
|
|
531
416
|
requireInstance(other, Interval, 'other');
|
|
532
417
|
return this._start.compareTo(other.start()) <= 0 && other.end().compareTo(this._end) <= 0;
|
|
533
418
|
};
|
|
534
|
-
|
|
535
419
|
_proto.abuts = function abuts(other) {
|
|
536
420
|
requireNonNull(other, 'other');
|
|
537
421
|
requireInstance(other, Interval, 'other');
|
|
538
422
|
return !this._end.equals(other.start()) !== !this._start.equals(other.end());
|
|
539
423
|
};
|
|
540
|
-
|
|
541
424
|
_proto.isConnected = function isConnected(other) {
|
|
542
425
|
requireNonNull(other, 'other');
|
|
543
426
|
requireInstance(other, Interval, 'other');
|
|
544
427
|
return this.equals(other) || this._start.compareTo(other.end()) <= 0 && other.start().compareTo(this._end) <= 0;
|
|
545
428
|
};
|
|
546
|
-
|
|
547
429
|
_proto.overlaps = function overlaps(other) {
|
|
548
430
|
requireNonNull(other, 'other');
|
|
549
431
|
requireInstance(other, Interval, 'other');
|
|
550
432
|
return other.equals(this) || this._start.compareTo(other.end()) < 0 && other.start().compareTo(this._end) < 0;
|
|
551
433
|
};
|
|
552
|
-
|
|
553
434
|
_proto.intersection = function intersection(other) {
|
|
554
435
|
requireNonNull(other, 'other');
|
|
555
436
|
requireInstance(other, Interval, 'other');
|
|
556
|
-
|
|
557
437
|
if (this.isConnected(other) === false) {
|
|
558
438
|
throw new DateTimeException("Intervals do not connect: " + this + " and " + other);
|
|
559
439
|
}
|
|
560
|
-
|
|
561
440
|
var cmpStart = this._start.compareTo(other.start());
|
|
562
|
-
|
|
563
441
|
var cmpEnd = this._end.compareTo(other.end());
|
|
564
|
-
|
|
565
442
|
if (cmpStart >= 0 && cmpEnd <= 0) {
|
|
566
443
|
return this;
|
|
567
444
|
} else if (cmpStart <= 0 && cmpEnd >= 0) {
|
|
@@ -572,19 +449,14 @@ var Interval = function () {
|
|
|
572
449
|
return Interval.of(newStart, newEnd);
|
|
573
450
|
}
|
|
574
451
|
};
|
|
575
|
-
|
|
576
452
|
_proto.union = function union(other) {
|
|
577
453
|
requireNonNull(other, 'other');
|
|
578
454
|
requireInstance(other, Interval, 'other');
|
|
579
|
-
|
|
580
455
|
if (this.isConnected(other) === false) {
|
|
581
456
|
throw new DateTimeException("Intervals do not connect: " + this + " and " + other);
|
|
582
457
|
}
|
|
583
|
-
|
|
584
458
|
var cmpStart = this._start.compareTo(other.start());
|
|
585
|
-
|
|
586
459
|
var cmpEnd = this._end.compareTo(other.end());
|
|
587
|
-
|
|
588
460
|
if (cmpStart >= 0 && cmpEnd <= 0) {
|
|
589
461
|
return other;
|
|
590
462
|
} else if (cmpStart <= 0 && cmpEnd >= 0) {
|
|
@@ -595,20 +467,15 @@ var Interval = function () {
|
|
|
595
467
|
return Interval.of(newStart, newEnd);
|
|
596
468
|
}
|
|
597
469
|
};
|
|
598
|
-
|
|
599
470
|
_proto.span = function span(other) {
|
|
600
471
|
requireNonNull(other, 'other');
|
|
601
472
|
requireInstance(other, Interval, 'other');
|
|
602
|
-
|
|
603
473
|
var cmpStart = this._start.compareTo(other.start());
|
|
604
|
-
|
|
605
474
|
var cmpEnd = this._end.compareTo(other.end());
|
|
606
|
-
|
|
607
475
|
var newStart = cmpStart >= 0 ? other.start() : this._start;
|
|
608
476
|
var newEnd = cmpEnd <= 0 ? other.end() : this._end;
|
|
609
477
|
return Interval.of(newStart, newEnd);
|
|
610
478
|
};
|
|
611
|
-
|
|
612
479
|
_proto.isAfter = function isAfter(instantOrInterval) {
|
|
613
480
|
if (instantOrInterval instanceof Instant) {
|
|
614
481
|
return this.isAfterInstant(instantOrInterval);
|
|
@@ -616,7 +483,6 @@ var Interval = function () {
|
|
|
616
483
|
return this.isAfterInterval(instantOrInterval);
|
|
617
484
|
}
|
|
618
485
|
};
|
|
619
|
-
|
|
620
486
|
_proto.isBefore = function isBefore(instantOrInterval) {
|
|
621
487
|
if (instantOrInterval instanceof Instant) {
|
|
622
488
|
return this.isBeforeInstant(instantOrInterval);
|
|
@@ -624,50 +490,39 @@ var Interval = function () {
|
|
|
624
490
|
return this.isBeforeInterval(instantOrInterval);
|
|
625
491
|
}
|
|
626
492
|
};
|
|
627
|
-
|
|
628
493
|
_proto.isAfterInstant = function isAfterInstant(instant) {
|
|
629
494
|
return this._start.compareTo(instant) > 0;
|
|
630
495
|
};
|
|
631
|
-
|
|
632
496
|
_proto.isBeforeInstant = function isBeforeInstant(instant) {
|
|
633
497
|
return this._end.compareTo(instant) <= 0 && this._start.compareTo(instant) < 0;
|
|
634
498
|
};
|
|
635
|
-
|
|
636
499
|
_proto.isAfterInterval = function isAfterInterval(interval) {
|
|
637
500
|
return this._start.compareTo(interval.end()) >= 0 && !interval.equals(this);
|
|
638
501
|
};
|
|
639
|
-
|
|
640
502
|
_proto.isBeforeInterval = function isBeforeInterval(interval) {
|
|
641
503
|
return this._end.compareTo(interval.start()) <= 0 && !interval.equals(this);
|
|
642
504
|
};
|
|
643
|
-
|
|
644
505
|
_proto.toDuration = function toDuration() {
|
|
645
506
|
return Duration.between(this._start, this._end);
|
|
646
507
|
};
|
|
647
|
-
|
|
648
508
|
_proto.equals = function equals(obj) {
|
|
649
509
|
if (this === obj) {
|
|
650
510
|
return true;
|
|
651
511
|
}
|
|
652
|
-
|
|
653
512
|
if (obj instanceof Interval) {
|
|
654
513
|
return this._start.equals(obj.start()) && this._end.equals(obj.end());
|
|
655
514
|
}
|
|
656
|
-
|
|
657
515
|
return false;
|
|
658
516
|
};
|
|
659
|
-
|
|
660
517
|
_proto.hashCode = function hashCode() {
|
|
661
518
|
return this._start.hashCode() ^ this._end.hashCode();
|
|
662
519
|
};
|
|
663
|
-
|
|
664
520
|
_proto.toString = function toString() {
|
|
665
521
|
return this._start.toString() + "/" + this._end.toString();
|
|
666
522
|
};
|
|
667
|
-
|
|
668
523
|
return Interval;
|
|
669
524
|
}();
|
|
670
|
-
function _init$
|
|
525
|
+
function _init$6() {
|
|
671
526
|
Interval.ALL = Interval.of(Instant.MIN, Instant.MAX);
|
|
672
527
|
}
|
|
673
528
|
|
|
@@ -683,24 +538,18 @@ var LocalDateRange = function () {
|
|
|
683
538
|
if (startInclusive instanceof LocalDate && endExclusiveOrPeriod instanceof LocalDate) {
|
|
684
539
|
return LocalDateRange._ofLocalDateLocalDate(startInclusive, endExclusiveOrPeriod);
|
|
685
540
|
}
|
|
686
|
-
|
|
687
541
|
if (startInclusive instanceof LocalDate && endExclusiveOrPeriod instanceof Period) {
|
|
688
542
|
return LocalDateRange._ofLocalDatePeriod(startInclusive, endExclusiveOrPeriod);
|
|
689
543
|
}
|
|
690
|
-
|
|
691
544
|
var messageParts = [];
|
|
692
|
-
|
|
693
545
|
if (!(startInclusive instanceof LocalDate)) {
|
|
694
546
|
messageParts.push("startInclusive must be an instance of LocalDate but is " + startInclusive.constructor.name);
|
|
695
547
|
}
|
|
696
|
-
|
|
697
548
|
if (!(endExclusiveOrPeriod instanceof LocalDate || endExclusiveOrPeriod instanceof Period)) {
|
|
698
549
|
messageParts.push("endExclusiveOrPeriod must be an instance of LocalDate or Period but is " + endExclusiveOrPeriod.constructor.name);
|
|
699
550
|
}
|
|
700
|
-
|
|
701
551
|
throw new IllegalArgumentException(messageParts.join(' and '));
|
|
702
552
|
};
|
|
703
|
-
|
|
704
553
|
LocalDateRange._ofLocalDateLocalDate = function _ofLocalDateLocalDate(startInclusive, endExclusive) {
|
|
705
554
|
requireNonNull(startInclusive, 'startInclusive');
|
|
706
555
|
requireNonNull(endExclusive, 'endExclusive');
|
|
@@ -708,188 +557,143 @@ var LocalDateRange = function () {
|
|
|
708
557
|
requireInstance(endExclusive, LocalDate, 'endExclusive');
|
|
709
558
|
return new LocalDateRange(startInclusive, endExclusive);
|
|
710
559
|
};
|
|
711
|
-
|
|
712
560
|
LocalDateRange._ofLocalDatePeriod = function _ofLocalDatePeriod(startInclusive, period) {
|
|
713
561
|
requireNonNull(startInclusive, 'startInclusive');
|
|
714
562
|
requireNonNull(period, 'period');
|
|
715
563
|
requireInstance(startInclusive, LocalDate, 'startInclusive');
|
|
716
564
|
requireInstance(period, Period, 'period');
|
|
717
|
-
|
|
718
565
|
if (period.isNegative()) {
|
|
719
566
|
throw new DateTimeException('Period must not be zero or negative');
|
|
720
567
|
}
|
|
721
|
-
|
|
722
568
|
return new LocalDateRange(startInclusive, startInclusive.plus(period));
|
|
723
569
|
};
|
|
724
|
-
|
|
725
570
|
LocalDateRange.ofClosed = function ofClosed(startInclusive, endInclusive) {
|
|
726
571
|
requireNonNull(startInclusive, 'startInclusive');
|
|
727
572
|
requireNonNull(endInclusive, 'endInclusive');
|
|
728
573
|
requireInstance(startInclusive, LocalDate, 'startInclusive');
|
|
729
574
|
requireInstance(endInclusive, LocalDate, 'endInclusive');
|
|
730
|
-
|
|
731
575
|
if (endInclusive.isBefore(startInclusive)) {
|
|
732
576
|
throw new DateTimeException('Start date must be on or before end date');
|
|
733
577
|
}
|
|
734
|
-
|
|
735
578
|
var end = endInclusive.equals(LocalDate.MAX) ? LocalDate.MAX : endInclusive.plusDays(1);
|
|
736
579
|
return new LocalDateRange(startInclusive, end);
|
|
737
580
|
};
|
|
738
|
-
|
|
739
581
|
LocalDateRange.ofEmpty = function ofEmpty(date) {
|
|
740
582
|
requireNonNull(date, 'date');
|
|
741
583
|
requireInstance(date, LocalDate, 'date');
|
|
742
584
|
return new LocalDateRange(date, date);
|
|
743
585
|
};
|
|
744
|
-
|
|
745
586
|
LocalDateRange.ofUnbounded = function ofUnbounded() {
|
|
746
587
|
return LocalDateRange.ALL;
|
|
747
588
|
};
|
|
748
|
-
|
|
749
589
|
LocalDateRange.ofUnboundedStart = function ofUnboundedStart(endExclusive) {
|
|
750
590
|
requireNonNull(endExclusive, 'endExclusive');
|
|
751
591
|
requireInstance(endExclusive, LocalDate, 'endExclusive');
|
|
752
592
|
return LocalDateRange.of(LocalDate.MIN, endExclusive);
|
|
753
593
|
};
|
|
754
|
-
|
|
755
594
|
LocalDateRange.ofUnboundedEnd = function ofUnboundedEnd(startInclusive) {
|
|
756
595
|
return LocalDateRange.of(startInclusive, LocalDate.MAX);
|
|
757
596
|
};
|
|
758
|
-
|
|
759
597
|
LocalDateRange.parse = function parse(text) {
|
|
760
598
|
requireNonNull(text, 'text');
|
|
761
|
-
|
|
762
599
|
for (var i = 0; i < text.length; i++) {
|
|
763
600
|
if (text[i] === '/') {
|
|
764
601
|
var firstChar = text.charAt(0);
|
|
765
|
-
|
|
766
602
|
if (firstChar === 'P' || firstChar === 'p') {
|
|
767
603
|
var duration = Period.parse(text.slice(0, i));
|
|
768
604
|
var end = LocalDate.parse(text.slice(i + 1, text.length));
|
|
769
605
|
return LocalDateRange.of(end.minus(duration), end);
|
|
770
606
|
} else {
|
|
771
607
|
var start = LocalDate.parse(text.slice(0, i));
|
|
772
|
-
|
|
773
608
|
if (i + 1 < text.length) {
|
|
774
609
|
var c = text[i + 1];
|
|
775
|
-
|
|
776
610
|
if (c === 'P' || c === 'p') {
|
|
777
611
|
var _duration = Period.parse(text.slice(i + 1, text.length));
|
|
778
|
-
|
|
779
612
|
return LocalDateRange.of(start, start.plus(_duration));
|
|
780
613
|
}
|
|
781
614
|
}
|
|
782
|
-
|
|
783
615
|
var _end = LocalDate.parse(text.slice(i + 1, text.length));
|
|
784
|
-
|
|
785
616
|
return LocalDateRange.of(start, _end);
|
|
786
617
|
}
|
|
787
618
|
}
|
|
788
619
|
}
|
|
789
|
-
|
|
790
620
|
throw new DateTimeParseException('LocalDateRange cannot be parsed, no forward slash found', text, 0);
|
|
791
621
|
};
|
|
792
|
-
|
|
793
622
|
function LocalDateRange(startInclusive, endExclusive) {
|
|
794
623
|
requireNonNull(startInclusive, 'startInclusive');
|
|
795
624
|
requireNonNull(endExclusive, 'endExclusive');
|
|
796
625
|
requireInstance(startInclusive, LocalDate, 'startInclusive');
|
|
797
626
|
requireInstance(endExclusive, LocalDate, 'endExclusive');
|
|
798
|
-
|
|
799
627
|
if (endExclusive.isBefore(startInclusive)) {
|
|
800
628
|
throw new DateTimeException('End date must be on or after start date');
|
|
801
629
|
}
|
|
802
|
-
|
|
803
630
|
if (startInclusive.equals(MAXM1)) {
|
|
804
631
|
throw new DateTimeException('Range must not start at LocalDate.MAX.minusDays(1)');
|
|
805
632
|
}
|
|
806
|
-
|
|
807
633
|
if (endExclusive.equals(MINP1)) {
|
|
808
634
|
throw new DateTimeException('Range must not end at LocalDate.MIN.plusDays(1)');
|
|
809
635
|
}
|
|
810
|
-
|
|
811
636
|
if (endExclusive.equals(LocalDate.MIN) || startInclusive.equals(LocalDate.MAX)) {
|
|
812
637
|
throw new DateTimeException('Empty range must not be at LocalDate.MIN or LocalDate.MAX');
|
|
813
638
|
}
|
|
814
|
-
|
|
815
639
|
this._start = startInclusive;
|
|
816
640
|
this._end = endExclusive;
|
|
817
641
|
}
|
|
818
|
-
|
|
819
642
|
var _proto = LocalDateRange.prototype;
|
|
820
|
-
|
|
821
643
|
_proto.start = function start() {
|
|
822
644
|
return this._start;
|
|
823
645
|
};
|
|
824
|
-
|
|
825
646
|
_proto.end = function end() {
|
|
826
647
|
return this._end;
|
|
827
648
|
};
|
|
828
|
-
|
|
829
649
|
_proto.endInclusive = function endInclusive() {
|
|
830
650
|
if (this.isUnboundedEnd()) {
|
|
831
651
|
return LocalDate.MAX;
|
|
832
652
|
}
|
|
833
|
-
|
|
834
653
|
return this._end.minusDays(1);
|
|
835
654
|
};
|
|
836
|
-
|
|
837
655
|
_proto.isEmpty = function isEmpty() {
|
|
838
656
|
return this._start.equals(this._end);
|
|
839
657
|
};
|
|
840
|
-
|
|
841
658
|
_proto.isUnboundedStart = function isUnboundedStart() {
|
|
842
659
|
return this._start.equals(LocalDate.MIN);
|
|
843
660
|
};
|
|
844
|
-
|
|
845
661
|
_proto.isUnboundedEnd = function isUnboundedEnd() {
|
|
846
662
|
return this._end.equals(LocalDate.MAX);
|
|
847
663
|
};
|
|
848
|
-
|
|
849
664
|
_proto.withStart = function withStart(adjuster) {
|
|
850
665
|
return LocalDateRange.of(this._start.with(adjuster), this._end);
|
|
851
666
|
};
|
|
852
|
-
|
|
853
667
|
_proto.withEnd = function withEnd(adjuster) {
|
|
854
668
|
return LocalDateRange.of(this._start, this._end.with(adjuster));
|
|
855
669
|
};
|
|
856
|
-
|
|
857
670
|
_proto.contains = function contains(date) {
|
|
858
671
|
requireNonNull(date, 'date');
|
|
859
672
|
return this._start.compareTo(date) <= 0 && (date.compareTo(this._end) < 0 || this.isUnboundedEnd());
|
|
860
673
|
};
|
|
861
|
-
|
|
862
674
|
_proto.encloses = function encloses(other) {
|
|
863
675
|
requireNonNull(other, 'other');
|
|
864
676
|
return this._start.compareTo(other._start) <= 0 && other._end.compareTo(this._end) <= 0;
|
|
865
677
|
};
|
|
866
|
-
|
|
867
678
|
_proto.abuts = function abuts(other) {
|
|
868
679
|
requireNonNull(other, 'other');
|
|
869
680
|
return this._end.equals(other._start) !== this._start.equals(other._end);
|
|
870
681
|
};
|
|
871
|
-
|
|
872
682
|
_proto.isConnected = function isConnected(other) {
|
|
873
683
|
requireNonNull(other, 'other');
|
|
874
684
|
return this.equals(other) || this._start.compareTo(other._end) <= 0 && other._start.compareTo(this._end) <= 0;
|
|
875
685
|
};
|
|
876
|
-
|
|
877
686
|
_proto.overlaps = function overlaps(other) {
|
|
878
687
|
requireNonNull(other, 'other');
|
|
879
688
|
return other.equals(this) || this._start.compareTo(other._end) < 0 && other._start.compareTo(this._end) < 0;
|
|
880
689
|
};
|
|
881
|
-
|
|
882
690
|
_proto.intersection = function intersection(other) {
|
|
883
691
|
requireNonNull(other, 'other');
|
|
884
|
-
|
|
885
692
|
if (this.isConnected(other) === false) {
|
|
886
693
|
throw new DateTimeException("Ranges do not connect: " + this + " and " + other);
|
|
887
694
|
}
|
|
888
|
-
|
|
889
695
|
var cmpStart = this._start.compareTo(other._start);
|
|
890
|
-
|
|
891
696
|
var cmpEnd = this._end.compareTo(other._end);
|
|
892
|
-
|
|
893
697
|
if (cmpStart >= 0 && cmpEnd <= 0) {
|
|
894
698
|
return this;
|
|
895
699
|
} else if (cmpStart <= 0 && cmpEnd >= 0) {
|
|
@@ -900,18 +704,13 @@ var LocalDateRange = function () {
|
|
|
900
704
|
return LocalDateRange.of(newStart, newEnd);
|
|
901
705
|
}
|
|
902
706
|
};
|
|
903
|
-
|
|
904
707
|
_proto.union = function union(other) {
|
|
905
708
|
requireNonNull(other, 'other');
|
|
906
|
-
|
|
907
709
|
if (this.isConnected(other) === false) {
|
|
908
710
|
throw new DateTimeException("Ranges do not connect: " + this + " and " + other);
|
|
909
711
|
}
|
|
910
|
-
|
|
911
712
|
var cmpStart = this._start.compareTo(other._start);
|
|
912
|
-
|
|
913
713
|
var cmpEnd = this._end.compareTo(other._end);
|
|
914
|
-
|
|
915
714
|
if (cmpStart >= 0 && cmpEnd <= 0) {
|
|
916
715
|
return other;
|
|
917
716
|
} else if (cmpStart <= 0 && cmpEnd >= 0) {
|
|
@@ -922,107 +721,82 @@ var LocalDateRange = function () {
|
|
|
922
721
|
return LocalDateRange.of(newStart, newEnd);
|
|
923
722
|
}
|
|
924
723
|
};
|
|
925
|
-
|
|
926
724
|
_proto.span = function span(other) {
|
|
927
725
|
requireNonNull(other, 'other');
|
|
928
|
-
|
|
929
726
|
var cmpStart = this._start.compareTo(other._start);
|
|
930
|
-
|
|
931
727
|
var cmpEnd = this._end.compareTo(other._end);
|
|
932
|
-
|
|
933
728
|
var newStart = cmpStart >= 0 ? other._start : this._start;
|
|
934
729
|
var newEnd = cmpEnd <= 0 ? other._end : this._end;
|
|
935
730
|
return LocalDateRange.of(newStart, newEnd);
|
|
936
731
|
};
|
|
937
|
-
|
|
938
732
|
_proto.isAfter = function isAfter(localDateOrLocalDateRange) {
|
|
939
733
|
if (localDateOrLocalDateRange instanceof LocalDate) {
|
|
940
734
|
return this._isAfterLocalDate(localDateOrLocalDateRange);
|
|
941
735
|
}
|
|
942
|
-
|
|
943
736
|
if (localDateOrLocalDateRange instanceof LocalDateRange) {
|
|
944
737
|
return this._isAfterLocalDateRange(localDateOrLocalDateRange);
|
|
945
738
|
}
|
|
946
|
-
|
|
947
739
|
throw new IllegalArgumentException("localDateOrLocalDateRange must be an instance of LocalDate or LocalDateRange but is " + localDateOrLocalDateRange.constructor.name);
|
|
948
740
|
};
|
|
949
|
-
|
|
950
741
|
_proto.isBefore = function isBefore(localDateOrLocalDateRange) {
|
|
951
742
|
if (localDateOrLocalDateRange instanceof LocalDate) {
|
|
952
743
|
return this._isBeforeLocalDate(localDateOrLocalDateRange);
|
|
953
744
|
}
|
|
954
|
-
|
|
955
745
|
if (localDateOrLocalDateRange instanceof LocalDateRange) {
|
|
956
746
|
return this._isBeforeLocalDateRange(localDateOrLocalDateRange);
|
|
957
747
|
}
|
|
958
|
-
|
|
959
748
|
throw new IllegalArgumentException("localDateOrLocalDateRange must be an instance of LocalDate or LocalDateRange but is " + localDateOrLocalDateRange.constructor.name);
|
|
960
749
|
};
|
|
961
|
-
|
|
962
750
|
_proto._isAfterLocalDate = function _isAfterLocalDate(date) {
|
|
963
751
|
return this._start.compareTo(date) > 0;
|
|
964
752
|
};
|
|
965
|
-
|
|
966
753
|
_proto._isBeforeLocalDate = function _isBeforeLocalDate(date) {
|
|
967
754
|
return this._end.compareTo(date) <= 0 && this._start.compareTo(date) < 0;
|
|
968
755
|
};
|
|
969
|
-
|
|
970
756
|
_proto._isAfterLocalDateRange = function _isAfterLocalDateRange(other) {
|
|
971
757
|
return this._start.compareTo(other._end) >= 0 && !other.equals(this);
|
|
972
758
|
};
|
|
973
|
-
|
|
974
759
|
_proto._isBeforeLocalDateRange = function _isBeforeLocalDateRange(range) {
|
|
975
760
|
return this._end.compareTo(range._start) <= 0 && !range.equals(this);
|
|
976
761
|
};
|
|
977
|
-
|
|
978
762
|
_proto.lengthInDays = function lengthInDays() {
|
|
979
763
|
if (this.isUnboundedStart() || this.isUnboundedEnd()) {
|
|
980
764
|
return Number.POSITIVE_INFINITY;
|
|
981
765
|
}
|
|
982
|
-
|
|
983
766
|
return this._end.toEpochDay() - this._start.toEpochDay();
|
|
984
767
|
};
|
|
985
|
-
|
|
986
768
|
_proto.toPeriod = function toPeriod() {
|
|
987
769
|
if (this.isUnboundedStart() || this.isUnboundedEnd()) {
|
|
988
770
|
throw new ArithmeticException('Unbounded range cannot be converted to a Period');
|
|
989
771
|
}
|
|
990
|
-
|
|
991
772
|
return Period.between(this._start, this._end);
|
|
992
773
|
};
|
|
993
|
-
|
|
994
774
|
_proto.equals = function equals(obj) {
|
|
995
775
|
if (this === obj) {
|
|
996
776
|
return true;
|
|
997
777
|
}
|
|
998
|
-
|
|
999
778
|
if (obj instanceof LocalDateRange) {
|
|
1000
779
|
var other = obj;
|
|
1001
780
|
return this._start.equals(other._start) && this._end.equals(other._end);
|
|
1002
781
|
}
|
|
1003
|
-
|
|
1004
782
|
return false;
|
|
1005
783
|
};
|
|
1006
|
-
|
|
1007
784
|
_proto.hashCode = function hashCode() {
|
|
1008
785
|
return this._start.hashCode() ^ this._end.hashCode();
|
|
1009
786
|
};
|
|
1010
|
-
|
|
1011
787
|
_proto.toString = function toString() {
|
|
1012
788
|
return this._start.toString() + "/" + this._end.toString();
|
|
1013
789
|
};
|
|
1014
|
-
|
|
1015
790
|
return LocalDateRange;
|
|
1016
791
|
}();
|
|
1017
|
-
function _init$
|
|
792
|
+
function _init$5() {
|
|
1018
793
|
LocalDateRange.ALL = new LocalDateRange(LocalDate.MIN, LocalDate.MAX);
|
|
1019
794
|
}
|
|
1020
795
|
|
|
1021
|
-
var MathUtil$
|
|
796
|
+
var MathUtil$4 = _.MathUtil;
|
|
1022
797
|
var SECONDS_PER_DAY = 86400;
|
|
1023
798
|
var OffsetDate = function (_Temporal) {
|
|
1024
799
|
_inheritsLoose(OffsetDate, _Temporal);
|
|
1025
|
-
|
|
1026
800
|
OffsetDate.now = function now(zoneIdOrClock) {
|
|
1027
801
|
if (arguments.length === 0) {
|
|
1028
802
|
return OffsetDate._now0();
|
|
@@ -1032,61 +806,49 @@ var OffsetDate = function (_Temporal) {
|
|
|
1032
806
|
return OffsetDate._nowClock(zoneIdOrClock);
|
|
1033
807
|
}
|
|
1034
808
|
};
|
|
1035
|
-
|
|
1036
809
|
OffsetDate._now0 = function _now0() {
|
|
1037
810
|
return OffsetDate.now(Clock.systemDefaultZone());
|
|
1038
811
|
};
|
|
1039
|
-
|
|
1040
812
|
OffsetDate._nowZoneId = function _nowZoneId(zone) {
|
|
1041
813
|
return OffsetDate.now(Clock.system(zone));
|
|
1042
814
|
};
|
|
1043
|
-
|
|
1044
815
|
OffsetDate._nowClock = function _nowClock(clock) {
|
|
1045
816
|
requireNonNull(clock, 'clock');
|
|
1046
817
|
var now = clock.instant();
|
|
1047
818
|
return OffsetDate.ofInstant(now, clock.zone().rules().offset(now));
|
|
1048
819
|
};
|
|
1049
|
-
|
|
1050
820
|
OffsetDate.of = function of() {
|
|
1051
821
|
switch (arguments.length) {
|
|
1052
822
|
case 2:
|
|
1053
823
|
return OffsetDate._ofLocalDateZoneOffset.apply(OffsetDate, arguments);
|
|
1054
|
-
|
|
1055
824
|
case 4:
|
|
1056
825
|
return OffsetDate._ofIntIntIntZoneOffset.apply(OffsetDate, arguments);
|
|
1057
|
-
|
|
1058
826
|
default:
|
|
1059
827
|
throw new IllegalArgumentException('Illegal number of arguments');
|
|
1060
828
|
}
|
|
1061
829
|
};
|
|
1062
|
-
|
|
1063
830
|
OffsetDate._ofLocalDateZoneOffset = function _ofLocalDateZoneOffset(date, offset) {
|
|
1064
831
|
return new OffsetDate(date, offset);
|
|
1065
832
|
};
|
|
1066
|
-
|
|
1067
833
|
OffsetDate._ofIntIntIntZoneOffset = function _ofIntIntIntZoneOffset(year, month, dayOfMonth, offset) {
|
|
1068
834
|
var d = LocalDate.of(year, month, dayOfMonth);
|
|
1069
835
|
return new OffsetDate(d, offset);
|
|
1070
836
|
};
|
|
1071
|
-
|
|
1072
837
|
OffsetDate.ofInstant = function ofInstant(instant, zone) {
|
|
1073
838
|
requireNonNull(instant, 'instant');
|
|
1074
839
|
requireNonNull(zone, 'zone');
|
|
1075
840
|
var rules = zone.rules();
|
|
1076
841
|
var offset = rules.offset(instant);
|
|
1077
842
|
var epochSec = instant.epochSecond() + offset.totalSeconds();
|
|
1078
|
-
var epochDay = MathUtil$
|
|
843
|
+
var epochDay = MathUtil$4.floorDiv(epochSec, SECONDS_PER_DAY);
|
|
1079
844
|
var date = LocalDate.ofEpochDay(epochDay);
|
|
1080
845
|
return new OffsetDate(date, offset);
|
|
1081
846
|
};
|
|
1082
|
-
|
|
1083
847
|
OffsetDate.from = function from(temporal) {
|
|
1084
848
|
if (temporal instanceof OffsetDate) {
|
|
1085
849
|
return temporal;
|
|
1086
850
|
}
|
|
1087
|
-
|
|
1088
851
|
requireNonNull(temporal, 'temporal');
|
|
1089
|
-
|
|
1090
852
|
try {
|
|
1091
853
|
var date = LocalDate.from(temporal);
|
|
1092
854
|
var offset = ZoneOffset.from(temporal);
|
|
@@ -1095,140 +857,106 @@ var OffsetDate = function (_Temporal) {
|
|
|
1095
857
|
throw new DateTimeException("Unable to obtain OffsetDate from TemporalAccessor: " + temporal.constructor.name, ex);
|
|
1096
858
|
}
|
|
1097
859
|
};
|
|
1098
|
-
|
|
1099
860
|
OffsetDate.parse = function parse(text, formatter) {
|
|
1100
861
|
if (formatter === void 0) {
|
|
1101
862
|
formatter = DateTimeFormatter.ISO_OFFSET_DATE;
|
|
1102
863
|
}
|
|
1103
|
-
|
|
1104
864
|
requireNonNull(formatter, 'formatter');
|
|
1105
865
|
return formatter.parse(text, OffsetDate.FROM);
|
|
1106
866
|
};
|
|
1107
|
-
|
|
1108
867
|
function OffsetDate(date, offset) {
|
|
1109
868
|
var _this;
|
|
1110
|
-
|
|
1111
869
|
_this = _Temporal.call(this) || this;
|
|
1112
870
|
_this._date = requireNonNull(date, 'date');
|
|
1113
871
|
_this._offset = requireNonNull(offset, 'offset');
|
|
1114
872
|
return _this;
|
|
1115
873
|
}
|
|
1116
|
-
|
|
1117
874
|
var _proto = OffsetDate.prototype;
|
|
1118
|
-
|
|
1119
875
|
_proto._with = function _with(date, offset) {
|
|
1120
876
|
if (this._date === date && this._offset.equals(offset)) {
|
|
1121
877
|
return this;
|
|
1122
878
|
}
|
|
1123
|
-
|
|
1124
879
|
return new OffsetDate(date, offset);
|
|
1125
880
|
};
|
|
1126
|
-
|
|
1127
881
|
_proto.isSupported = function isSupported(fieldOrUnit) {
|
|
1128
882
|
if (fieldOrUnit instanceof TemporalField) {
|
|
1129
883
|
return this._isSupportedField(fieldOrUnit);
|
|
1130
884
|
}
|
|
1131
|
-
|
|
1132
885
|
if (fieldOrUnit instanceof TemporalUnit) {
|
|
1133
886
|
return this._isSupportedUnit(fieldOrUnit);
|
|
1134
887
|
}
|
|
1135
|
-
|
|
1136
888
|
if (fieldOrUnit == null) {
|
|
1137
889
|
return false;
|
|
1138
890
|
}
|
|
1139
|
-
|
|
1140
891
|
throw new IllegalArgumentException("fieldOrUnit must be an instance of TemporalField or TemporalUnit, but is " + fieldOrUnit.constructor.name);
|
|
1141
892
|
};
|
|
1142
|
-
|
|
1143
893
|
_proto._isSupportedField = function _isSupportedField(field) {
|
|
1144
894
|
if (field instanceof ChronoField) {
|
|
1145
895
|
return field.isDateBased() || field === ChronoField.OFFSET_SECONDS;
|
|
1146
896
|
}
|
|
1147
|
-
|
|
1148
897
|
return field != null && field.isSupportedBy(this);
|
|
1149
898
|
};
|
|
1150
|
-
|
|
1151
899
|
_proto._isSupportedUnit = function _isSupportedUnit(unit) {
|
|
1152
900
|
if (unit instanceof ChronoUnit) {
|
|
1153
901
|
return unit.isDateBased();
|
|
1154
902
|
}
|
|
1155
|
-
|
|
1156
903
|
return unit != null && unit.isSupportedBy(this);
|
|
1157
904
|
};
|
|
1158
|
-
|
|
1159
905
|
_proto.range = function range(field) {
|
|
1160
906
|
requireNonNull(field, 'field');
|
|
1161
907
|
requireInstance(field, TemporalField, 'field');
|
|
1162
|
-
|
|
1163
908
|
if (field instanceof ChronoField) {
|
|
1164
909
|
if (field === ChronoField.OFFSET_SECONDS) {
|
|
1165
910
|
return field.range();
|
|
1166
911
|
}
|
|
1167
|
-
|
|
1168
912
|
return this._date.range(field);
|
|
1169
913
|
}
|
|
1170
|
-
|
|
1171
914
|
return field.rangeRefinedBy(this);
|
|
1172
915
|
};
|
|
1173
|
-
|
|
1174
916
|
_proto.get = function get(field) {
|
|
1175
917
|
requireNonNull(field, 'field');
|
|
1176
918
|
requireInstance(field, TemporalField, 'field');
|
|
1177
919
|
return this.range(field).checkValidIntValue(this.getLong(field), field);
|
|
1178
920
|
};
|
|
1179
|
-
|
|
1180
921
|
_proto.getLong = function getLong(field) {
|
|
1181
922
|
requireNonNull(field, 'field');
|
|
1182
923
|
requireInstance(field, TemporalField, 'field');
|
|
1183
|
-
|
|
1184
924
|
if (field instanceof ChronoField) {
|
|
1185
925
|
if (field === ChronoField.OFFSET_SECONDS) {
|
|
1186
926
|
return this.offset().totalSeconds();
|
|
1187
927
|
}
|
|
1188
|
-
|
|
1189
928
|
return this._date.getLong(field);
|
|
1190
929
|
}
|
|
1191
|
-
|
|
1192
930
|
return field.getFrom(this);
|
|
1193
931
|
};
|
|
1194
|
-
|
|
1195
932
|
_proto.offset = function offset() {
|
|
1196
933
|
return this._offset;
|
|
1197
934
|
};
|
|
1198
|
-
|
|
1199
935
|
_proto.withOffsetSameLocal = function withOffsetSameLocal(offset) {
|
|
1200
936
|
requireNonNull(offset, 'offset');
|
|
1201
937
|
return this._with(this._date, offset);
|
|
1202
938
|
};
|
|
1203
|
-
|
|
1204
939
|
_proto.toLocalDate = function toLocalDate() {
|
|
1205
940
|
return this._date;
|
|
1206
941
|
};
|
|
1207
|
-
|
|
1208
942
|
_proto.year = function year() {
|
|
1209
943
|
return this._date.year();
|
|
1210
944
|
};
|
|
1211
|
-
|
|
1212
945
|
_proto.monthValue = function monthValue() {
|
|
1213
946
|
return this._date.monthValue();
|
|
1214
947
|
};
|
|
1215
|
-
|
|
1216
948
|
_proto.month = function month() {
|
|
1217
949
|
return this._date.month();
|
|
1218
950
|
};
|
|
1219
|
-
|
|
1220
951
|
_proto.dayOfMonth = function dayOfMonth() {
|
|
1221
952
|
return this._date.dayOfMonth();
|
|
1222
953
|
};
|
|
1223
|
-
|
|
1224
954
|
_proto.dayOfYear = function dayOfYear() {
|
|
1225
955
|
return this._date.dayOfYear();
|
|
1226
956
|
};
|
|
1227
|
-
|
|
1228
957
|
_proto.dayOfWeek = function dayOfWeek() {
|
|
1229
958
|
return this._date.dayOfWeek();
|
|
1230
959
|
};
|
|
1231
|
-
|
|
1232
960
|
_proto._withAdjuster = function _withAdjuster(adjuster) {
|
|
1233
961
|
if (adjuster instanceof LocalDate) {
|
|
1234
962
|
return this._with(adjuster, this._offset);
|
|
@@ -1237,86 +965,65 @@ var OffsetDate = function (_Temporal) {
|
|
|
1237
965
|
} else if (adjuster instanceof OffsetDate) {
|
|
1238
966
|
return adjuster;
|
|
1239
967
|
}
|
|
1240
|
-
|
|
1241
968
|
return _Temporal.prototype._withAdjuster.call(this, adjuster);
|
|
1242
969
|
};
|
|
1243
|
-
|
|
1244
970
|
_proto._withField = function _withField(field, newValue) {
|
|
1245
971
|
requireNonNull(field, 'field');
|
|
1246
972
|
requireInstance(field, TemporalField, 'field');
|
|
1247
|
-
|
|
1248
973
|
if (field instanceof ChronoField) {
|
|
1249
974
|
if (field === ChronoField.OFFSET_SECONDS) {
|
|
1250
975
|
var f = field;
|
|
1251
976
|
return this._with(this._date, ZoneOffset.ofTotalSeconds(f.checkValidIntValue(newValue)));
|
|
1252
977
|
}
|
|
1253
|
-
|
|
1254
978
|
return this._with(this._date.with(field, newValue), this._offset);
|
|
1255
979
|
}
|
|
1256
|
-
|
|
1257
980
|
return field.adjustInto(this, newValue);
|
|
1258
981
|
};
|
|
1259
|
-
|
|
1260
982
|
_proto.withYear = function withYear(year) {
|
|
1261
983
|
return this._with(this._date.withYear(year), this._offset);
|
|
1262
984
|
};
|
|
1263
|
-
|
|
1264
985
|
_proto.withMonth = function withMonth(month) {
|
|
1265
986
|
return this._with(this._date.withMonth(month), this._offset);
|
|
1266
987
|
};
|
|
1267
|
-
|
|
1268
988
|
_proto.withDayOfMonth = function withDayOfMonth(dayOfMonth) {
|
|
1269
989
|
return this._with(this._date.withDayOfMonth(dayOfMonth), this._offset);
|
|
1270
990
|
};
|
|
1271
|
-
|
|
1272
991
|
_proto.withDayOfYear = function withDayOfYear(dayOfYear) {
|
|
1273
992
|
return this._with(this._date.withDayOfYear(dayOfYear), this._offset);
|
|
1274
993
|
};
|
|
1275
|
-
|
|
1276
994
|
_proto._plusUnit = function _plusUnit(amountToAdd, unit) {
|
|
1277
995
|
if (unit instanceof ChronoUnit) {
|
|
1278
996
|
return this._with(this._date.plus(amountToAdd, unit), this._offset);
|
|
1279
997
|
}
|
|
1280
|
-
|
|
1281
998
|
return unit.addTo(this, amountToAdd);
|
|
1282
999
|
};
|
|
1283
|
-
|
|
1284
1000
|
_proto.plusYears = function plusYears(years) {
|
|
1285
1001
|
return this._with(this._date.plusYears(years), this._offset);
|
|
1286
1002
|
};
|
|
1287
|
-
|
|
1288
1003
|
_proto.plusMonths = function plusMonths(months) {
|
|
1289
1004
|
return this._with(this._date.plusMonths(months), this._offset);
|
|
1290
1005
|
};
|
|
1291
|
-
|
|
1292
1006
|
_proto.plusWeeks = function plusWeeks(weeks) {
|
|
1293
1007
|
return this._with(this._date.plusWeeks(weeks), this._offset);
|
|
1294
1008
|
};
|
|
1295
|
-
|
|
1296
1009
|
_proto.plusDays = function plusDays(days) {
|
|
1297
1010
|
return this._with(this._date.plusDays(days), this._offset);
|
|
1298
1011
|
};
|
|
1299
|
-
|
|
1300
1012
|
_proto.minusYears = function minusYears(years) {
|
|
1301
1013
|
return this._with(this._date.minusYears(years), this._offset);
|
|
1302
1014
|
};
|
|
1303
|
-
|
|
1304
1015
|
_proto.minusMonths = function minusMonths(months) {
|
|
1305
1016
|
return this._with(this._date.minusMonths(months), this._offset);
|
|
1306
1017
|
};
|
|
1307
|
-
|
|
1308
1018
|
_proto.minusWeeks = function minusWeeks(weeks) {
|
|
1309
1019
|
return this._with(this._date.minusWeeks(weeks), this._offset);
|
|
1310
1020
|
};
|
|
1311
|
-
|
|
1312
1021
|
_proto.minusDays = function minusDays(days) {
|
|
1313
1022
|
return this._with(this._date.minusDays(days), this._offset);
|
|
1314
1023
|
};
|
|
1315
|
-
|
|
1316
1024
|
_proto.query = function query(_query) {
|
|
1317
1025
|
requireNonNull(_query, 'query');
|
|
1318
1026
|
requireInstance(_query, TemporalQuery, 'query');
|
|
1319
|
-
|
|
1320
1027
|
if (_query === TemporalQueries.chronology()) {
|
|
1321
1028
|
return IsoChronology.INSTANCE;
|
|
1322
1029
|
} else if (_query === TemporalQueries.precision()) {
|
|
@@ -1324,349 +1031,268 @@ var OffsetDate = function (_Temporal) {
|
|
|
1324
1031
|
} else if (_query === TemporalQueries.offset() || _query === TemporalQueries.zone()) {
|
|
1325
1032
|
return this.offset();
|
|
1326
1033
|
}
|
|
1327
|
-
|
|
1328
1034
|
return _Temporal.prototype.query.call(this, _query);
|
|
1329
1035
|
};
|
|
1330
|
-
|
|
1331
1036
|
_proto.adjustInto = function adjustInto(temporal) {
|
|
1332
1037
|
return temporal.with(ChronoField.OFFSET_SECONDS, this.offset().totalSeconds()).with(ChronoField.EPOCH_DAY, this.toLocalDate().toEpochDay());
|
|
1333
1038
|
};
|
|
1334
|
-
|
|
1335
1039
|
_proto.until = function until(endExclusive, unit) {
|
|
1336
1040
|
var end = OffsetDate.from(endExclusive);
|
|
1337
|
-
|
|
1338
1041
|
if (unit instanceof ChronoUnit) {
|
|
1339
1042
|
var offsetDiff = end._offset.totalSeconds() - this._offset.totalSeconds();
|
|
1340
|
-
|
|
1341
|
-
var endLocal = end._date.plusDays(MathUtil$3.intDiv(-offsetDiff, SECONDS_PER_DAY));
|
|
1342
|
-
|
|
1043
|
+
var endLocal = end._date.plusDays(MathUtil$4.intDiv(-offsetDiff, SECONDS_PER_DAY));
|
|
1343
1044
|
return this._date.until(endLocal, unit);
|
|
1344
1045
|
}
|
|
1345
|
-
|
|
1346
1046
|
return unit.between(this, end);
|
|
1347
1047
|
};
|
|
1348
|
-
|
|
1349
1048
|
_proto.format = function format(formatter) {
|
|
1350
1049
|
requireNonNull(formatter, 'formatter');
|
|
1351
1050
|
return formatter.format(this);
|
|
1352
1051
|
};
|
|
1353
|
-
|
|
1354
1052
|
_proto.atTime = function atTime(time) {
|
|
1355
1053
|
return OffsetDateTime.of(this._date, time, this._offset);
|
|
1356
1054
|
};
|
|
1357
|
-
|
|
1358
1055
|
_proto._toEpochSecond = function _toEpochSecond() {
|
|
1359
1056
|
var epochDay = this._date.toEpochDay();
|
|
1360
|
-
|
|
1361
1057
|
var secs = epochDay * SECONDS_PER_DAY;
|
|
1362
1058
|
return secs - this._offset.totalSeconds();
|
|
1363
1059
|
};
|
|
1364
|
-
|
|
1365
1060
|
_proto.toEpochSecond = function toEpochSecond(time) {
|
|
1366
1061
|
requireNonNull(time, 'time');
|
|
1367
1062
|
return this._toEpochSecond() + time.toSecondOfDay();
|
|
1368
1063
|
};
|
|
1369
|
-
|
|
1370
1064
|
_proto.compareTo = function compareTo(other) {
|
|
1371
1065
|
requireNonNull(other, 'other');
|
|
1372
1066
|
requireInstance(other, OffsetDate, 'other');
|
|
1373
|
-
|
|
1374
1067
|
if (this._offset.equals(other._offset)) {
|
|
1375
1068
|
return this._date.compareTo(other._date);
|
|
1376
1069
|
}
|
|
1377
|
-
|
|
1378
1070
|
var compare = this._toEpochSecond() - other._toEpochSecond();
|
|
1379
|
-
|
|
1380
1071
|
if (compare === 0) {
|
|
1381
1072
|
compare = this._date.compareTo(other._date);
|
|
1382
1073
|
}
|
|
1383
|
-
|
|
1384
1074
|
return compare;
|
|
1385
1075
|
};
|
|
1386
|
-
|
|
1387
1076
|
_proto.isAfter = function isAfter(other) {
|
|
1388
1077
|
requireNonNull(other, 'other');
|
|
1389
1078
|
requireInstance(other, OffsetDate, 'other');
|
|
1390
1079
|
return this._toEpochSecond() > other._toEpochSecond();
|
|
1391
1080
|
};
|
|
1392
|
-
|
|
1393
1081
|
_proto.isBefore = function isBefore(other) {
|
|
1394
1082
|
requireNonNull(other, 'other');
|
|
1395
1083
|
requireInstance(other, OffsetDate, 'other');
|
|
1396
1084
|
return this._toEpochSecond() < other._toEpochSecond();
|
|
1397
1085
|
};
|
|
1398
|
-
|
|
1399
1086
|
_proto.isEqual = function isEqual(other) {
|
|
1400
1087
|
requireNonNull(other, 'other');
|
|
1401
1088
|
requireInstance(other, OffsetDate, 'other');
|
|
1402
1089
|
return this._toEpochSecond() === other._toEpochSecond();
|
|
1403
1090
|
};
|
|
1404
|
-
|
|
1405
1091
|
_proto.equals = function equals(obj) {
|
|
1406
1092
|
if (this === obj) {
|
|
1407
1093
|
return true;
|
|
1408
1094
|
}
|
|
1409
|
-
|
|
1410
1095
|
if (obj instanceof OffsetDate) {
|
|
1411
1096
|
var other = obj;
|
|
1412
1097
|
return this._date.equals(other._date) && this._offset.equals(other._offset);
|
|
1413
1098
|
}
|
|
1414
|
-
|
|
1415
1099
|
return false;
|
|
1416
1100
|
};
|
|
1417
|
-
|
|
1418
1101
|
_proto.hashCode = function hashCode() {
|
|
1419
1102
|
return this._date.hashCode() ^ this._offset.hashCode();
|
|
1420
1103
|
};
|
|
1421
|
-
|
|
1422
1104
|
_proto.toString = function toString() {
|
|
1423
1105
|
return this._date.toString() + this._offset.toString();
|
|
1424
1106
|
};
|
|
1425
|
-
|
|
1426
1107
|
return OffsetDate;
|
|
1427
1108
|
}(Temporal);
|
|
1428
|
-
function _init$
|
|
1109
|
+
function _init$4() {
|
|
1429
1110
|
OffsetDate.MIN = OffsetDate.of(LocalDate.MIN, ZoneOffset.MAX);
|
|
1430
1111
|
OffsetDate.MAX = OffsetDate.of(LocalDate.MAX, ZoneOffset.MIN);
|
|
1431
1112
|
OffsetDate.FROM = createTemporalQuery$3('OffsetDate.FROM', function (temporal) {
|
|
1432
1113
|
return OffsetDate.from(temporal);
|
|
1433
1114
|
});
|
|
1434
1115
|
}
|
|
1435
|
-
|
|
1436
1116
|
function createTemporalQuery$3(name, queryFromFunction) {
|
|
1437
1117
|
var ExtendedTemporalQuery = function (_TemporalQuery) {
|
|
1438
1118
|
_inheritsLoose(ExtendedTemporalQuery, _TemporalQuery);
|
|
1439
|
-
|
|
1440
1119
|
function ExtendedTemporalQuery() {
|
|
1441
1120
|
return _TemporalQuery.apply(this, arguments) || this;
|
|
1442
1121
|
}
|
|
1443
|
-
|
|
1444
1122
|
return ExtendedTemporalQuery;
|
|
1445
1123
|
}(TemporalQuery);
|
|
1446
|
-
|
|
1447
1124
|
ExtendedTemporalQuery.prototype.queryFrom = queryFromFunction;
|
|
1448
1125
|
return new ExtendedTemporalQuery(name);
|
|
1449
1126
|
}
|
|
1450
1127
|
|
|
1451
|
-
var MathUtil$
|
|
1128
|
+
var MathUtil$3 = _.MathUtil;
|
|
1452
1129
|
var Quarter = function (_TemporalAccessor) {
|
|
1453
1130
|
_inheritsLoose(Quarter, _TemporalAccessor);
|
|
1454
|
-
|
|
1455
1131
|
Quarter.valueOf = function valueOf(name) {
|
|
1456
1132
|
requireNonNull(name, 'name');
|
|
1457
|
-
|
|
1458
1133
|
switch (name) {
|
|
1459
1134
|
case 'Q1':
|
|
1460
1135
|
return Quarter.Q1;
|
|
1461
|
-
|
|
1462
1136
|
case 'Q2':
|
|
1463
1137
|
return Quarter.Q2;
|
|
1464
|
-
|
|
1465
1138
|
case 'Q3':
|
|
1466
1139
|
return Quarter.Q3;
|
|
1467
|
-
|
|
1468
1140
|
case 'Q4':
|
|
1469
1141
|
return Quarter.Q4;
|
|
1470
1142
|
}
|
|
1471
|
-
|
|
1472
1143
|
throw new IllegalArgumentException("No enum constant Quarter." + name);
|
|
1473
1144
|
};
|
|
1474
|
-
|
|
1475
1145
|
Quarter.values = function values() {
|
|
1476
1146
|
return QUARTERS.slice();
|
|
1477
1147
|
};
|
|
1478
|
-
|
|
1479
1148
|
Quarter.of = function of(quarterOfYear) {
|
|
1480
1149
|
requireNonNull(quarterOfYear, 'quarterOfYear');
|
|
1481
|
-
|
|
1482
1150
|
switch (quarterOfYear) {
|
|
1483
1151
|
case 1:
|
|
1484
1152
|
return Quarter.Q1;
|
|
1485
|
-
|
|
1486
1153
|
case 2:
|
|
1487
1154
|
return Quarter.Q2;
|
|
1488
|
-
|
|
1489
1155
|
case 3:
|
|
1490
1156
|
return Quarter.Q3;
|
|
1491
|
-
|
|
1492
1157
|
case 4:
|
|
1493
1158
|
return Quarter.Q4;
|
|
1494
|
-
|
|
1495
1159
|
default:
|
|
1496
1160
|
throw new DateTimeException("Invalid value for Quarter: " + quarterOfYear);
|
|
1497
1161
|
}
|
|
1498
1162
|
};
|
|
1499
|
-
|
|
1500
1163
|
Quarter.ofMonth = function ofMonth(monthOfYear) {
|
|
1501
1164
|
requireNonNull(monthOfYear, 'monthOfYear');
|
|
1502
1165
|
ChronoField.MONTH_OF_YEAR.range().checkValidValue(monthOfYear, ChronoField.MONTH_OF_YEAR);
|
|
1503
|
-
return Quarter.of(MathUtil$
|
|
1166
|
+
return Quarter.of(MathUtil$3.intDiv(monthOfYear - 1, 3) + 1);
|
|
1504
1167
|
};
|
|
1505
|
-
|
|
1506
1168
|
Quarter.from = function from(temporal) {
|
|
1507
1169
|
if (temporal instanceof Quarter) {
|
|
1508
1170
|
return temporal;
|
|
1509
1171
|
} else if (temporal instanceof Month) {
|
|
1510
1172
|
var month = temporal;
|
|
1511
|
-
return Quarter.of(MathUtil$
|
|
1173
|
+
return Quarter.of(MathUtil$3.intDiv(month.ordinal(), 3) + 1);
|
|
1512
1174
|
}
|
|
1513
|
-
|
|
1514
1175
|
try {
|
|
1515
|
-
var qoy = MathUtil$
|
|
1176
|
+
var qoy = MathUtil$3.safeToInt(temporal.getLong(IsoFields.QUARTER_OF_YEAR));
|
|
1516
1177
|
return Quarter.of(qoy);
|
|
1517
1178
|
} catch (ex) {
|
|
1518
1179
|
throw new DateTimeException("Unable to obtain Quarter from TemporalAccessor: " + temporal + " of type " + temporal.constructor.name, ex);
|
|
1519
1180
|
}
|
|
1520
1181
|
};
|
|
1521
|
-
|
|
1522
1182
|
function Quarter(value, name) {
|
|
1523
1183
|
var _this;
|
|
1524
|
-
|
|
1525
1184
|
_this = _TemporalAccessor.call(this) || this;
|
|
1526
|
-
_this._value = MathUtil$
|
|
1185
|
+
_this._value = MathUtil$3.safeToInt(value);
|
|
1527
1186
|
_this._name = name;
|
|
1528
1187
|
return _this;
|
|
1529
1188
|
}
|
|
1530
|
-
|
|
1531
1189
|
var _proto = Quarter.prototype;
|
|
1532
|
-
|
|
1533
1190
|
_proto.value = function value() {
|
|
1534
1191
|
return this._value;
|
|
1535
1192
|
};
|
|
1536
|
-
|
|
1537
1193
|
_proto.displayName = function displayName(style, locale) {
|
|
1538
1194
|
throw new IllegalArgumentException('Pattern using (localized) text not implemented yet!');
|
|
1539
1195
|
};
|
|
1540
|
-
|
|
1541
1196
|
_proto.isSupported = function isSupported(field) {
|
|
1542
1197
|
if (field === IsoFields.QUARTER_OF_YEAR) {
|
|
1543
1198
|
return true;
|
|
1544
1199
|
} else if (field instanceof ChronoField) {
|
|
1545
1200
|
return false;
|
|
1546
1201
|
}
|
|
1547
|
-
|
|
1548
1202
|
return field != null && field.isSupportedBy(this);
|
|
1549
1203
|
};
|
|
1550
|
-
|
|
1551
1204
|
_proto.range = function range(field) {
|
|
1552
1205
|
requireNonNull(field, 'field');
|
|
1553
|
-
|
|
1554
1206
|
if (field === IsoFields.QUARTER_OF_YEAR) {
|
|
1555
1207
|
return field.range();
|
|
1556
1208
|
} else if (field instanceof ChronoField) {
|
|
1557
1209
|
throw new UnsupportedTemporalTypeException("Unsupported field: " + field);
|
|
1558
1210
|
}
|
|
1559
|
-
|
|
1560
1211
|
return _TemporalAccessor.prototype.range.call(this, field);
|
|
1561
1212
|
};
|
|
1562
|
-
|
|
1563
1213
|
_proto.get = function get(field) {
|
|
1564
1214
|
requireNonNull(field, 'field');
|
|
1565
1215
|
requireInstance(field, TemporalField, 'field');
|
|
1566
1216
|
return this.range(field).checkValidIntValue(this.getLong(field), field);
|
|
1567
1217
|
};
|
|
1568
|
-
|
|
1569
1218
|
_proto.getLong = function getLong(field) {
|
|
1570
1219
|
requireNonNull(field, 'field');
|
|
1571
|
-
|
|
1572
1220
|
if (field === IsoFields.QUARTER_OF_YEAR) {
|
|
1573
1221
|
return this.value();
|
|
1574
1222
|
} else if (field instanceof ChronoField) {
|
|
1575
1223
|
throw new UnsupportedTemporalTypeException("Unsupported field: " + field);
|
|
1576
1224
|
}
|
|
1577
|
-
|
|
1578
1225
|
return field.getFrom(this);
|
|
1579
1226
|
};
|
|
1580
|
-
|
|
1581
1227
|
_proto.plus = function plus(quarters) {
|
|
1582
|
-
var amount = MathUtil$
|
|
1228
|
+
var amount = MathUtil$3.intMod(quarters, 4);
|
|
1583
1229
|
return QUARTERS[(this.ordinal() + amount + 4) % 4];
|
|
1584
1230
|
};
|
|
1585
|
-
|
|
1586
1231
|
_proto.minus = function minus(quarters) {
|
|
1587
|
-
return this.plus(-MathUtil$
|
|
1232
|
+
return this.plus(-MathUtil$3.intMod(quarters, 4));
|
|
1588
1233
|
};
|
|
1589
|
-
|
|
1590
1234
|
_proto.length = function length(leapYear) {
|
|
1591
1235
|
switch (this) {
|
|
1592
1236
|
case Quarter.Q1:
|
|
1593
1237
|
return leapYear ? 91 : 90;
|
|
1594
|
-
|
|
1595
1238
|
case Quarter.Q2:
|
|
1596
1239
|
return 91;
|
|
1597
|
-
|
|
1598
1240
|
default:
|
|
1599
1241
|
return 92;
|
|
1600
1242
|
}
|
|
1601
1243
|
};
|
|
1602
|
-
|
|
1603
1244
|
_proto.firstMonth = function firstMonth() {
|
|
1604
1245
|
switch (this) {
|
|
1605
1246
|
case Quarter.Q1:
|
|
1606
1247
|
return Month.JANUARY;
|
|
1607
|
-
|
|
1608
1248
|
case Quarter.Q2:
|
|
1609
1249
|
return Month.APRIL;
|
|
1610
|
-
|
|
1611
1250
|
case Quarter.Q3:
|
|
1612
1251
|
return Month.JULY;
|
|
1613
|
-
|
|
1614
1252
|
case Quarter.Q4:
|
|
1615
1253
|
return Month.OCTOBER;
|
|
1616
|
-
|
|
1617
1254
|
default:
|
|
1618
1255
|
throw new IllegalStateException('Unreachable');
|
|
1619
1256
|
}
|
|
1620
1257
|
};
|
|
1621
|
-
|
|
1622
1258
|
_proto.query = function query(_query) {
|
|
1623
1259
|
requireNonNull(_query, 'query');
|
|
1624
1260
|
requireInstance(_query, TemporalQuery, 'query');
|
|
1625
|
-
|
|
1626
1261
|
if (_query === TemporalQueries.chronology()) {
|
|
1627
1262
|
return IsoChronology.INSTANCE;
|
|
1628
1263
|
} else if (_query === TemporalQueries.precision()) {
|
|
1629
1264
|
return IsoFields.QUARTER_YEARS;
|
|
1630
1265
|
}
|
|
1631
|
-
|
|
1632
1266
|
return _TemporalAccessor.prototype.query.call(this, _query);
|
|
1633
1267
|
};
|
|
1634
|
-
|
|
1635
1268
|
_proto.adjustInto = function adjustInto(temporal) {
|
|
1636
1269
|
requireNonNull(temporal, 'temporal');
|
|
1637
1270
|
return temporal.with(IsoFields.QUARTER_OF_YEAR, this.value());
|
|
1638
1271
|
};
|
|
1639
|
-
|
|
1640
1272
|
_proto.ordinal = function ordinal() {
|
|
1641
1273
|
return this._value - 1;
|
|
1642
1274
|
};
|
|
1643
|
-
|
|
1644
1275
|
_proto.name = function name() {
|
|
1645
1276
|
return this._name;
|
|
1646
1277
|
};
|
|
1647
|
-
|
|
1648
1278
|
_proto.compareTo = function compareTo(other) {
|
|
1649
1279
|
requireNonNull(other, 'other');
|
|
1650
1280
|
requireInstance(other, Quarter, 'other');
|
|
1651
1281
|
return this._value - other._value;
|
|
1652
1282
|
};
|
|
1653
|
-
|
|
1654
1283
|
_proto.toString = function toString() {
|
|
1655
1284
|
return this.name();
|
|
1656
1285
|
};
|
|
1657
|
-
|
|
1658
1286
|
_proto.equals = function equals(other) {
|
|
1659
1287
|
return this === other;
|
|
1660
1288
|
};
|
|
1661
|
-
|
|
1662
1289
|
_proto.hashCode = function hashCode() {
|
|
1663
1290
|
return this._value;
|
|
1664
1291
|
};
|
|
1665
|
-
|
|
1666
1292
|
return Quarter;
|
|
1667
1293
|
}(TemporalAccessor);
|
|
1668
1294
|
var QUARTERS;
|
|
1669
|
-
function _init$
|
|
1295
|
+
function _init$3() {
|
|
1670
1296
|
Quarter.Q1 = new Quarter(1, 'Q1');
|
|
1671
1297
|
Quarter.Q2 = new Quarter(2, 'Q2');
|
|
1672
1298
|
Quarter.Q3 = new Quarter(3, 'Q3');
|
|
@@ -1676,26 +1302,204 @@ function _init$2() {
|
|
|
1676
1302
|
});
|
|
1677
1303
|
QUARTERS = [Quarter.Q1, Quarter.Q2, Quarter.Q3, Quarter.Q4];
|
|
1678
1304
|
}
|
|
1679
|
-
|
|
1680
1305
|
function createTemporalQuery$2(name, queryFromFunction) {
|
|
1681
1306
|
var ExtendedTemporalQuery = function (_TemporalQuery) {
|
|
1682
1307
|
_inheritsLoose(ExtendedTemporalQuery, _TemporalQuery);
|
|
1683
|
-
|
|
1684
1308
|
function ExtendedTemporalQuery() {
|
|
1685
1309
|
return _TemporalQuery.apply(this, arguments) || this;
|
|
1686
1310
|
}
|
|
1687
|
-
|
|
1688
1311
|
return ExtendedTemporalQuery;
|
|
1689
1312
|
}(TemporalQuery);
|
|
1690
|
-
|
|
1691
1313
|
ExtendedTemporalQuery.prototype.queryFrom = queryFromFunction;
|
|
1692
1314
|
return new ExtendedTemporalQuery(name);
|
|
1693
1315
|
}
|
|
1694
1316
|
|
|
1317
|
+
var MathUtil$2 = _.MathUtil;
|
|
1318
|
+
var Temporals = function () {
|
|
1319
|
+
Temporals.nextWorkingDay = function nextWorkingDay() {
|
|
1320
|
+
return Adjuster.NEXT_WORKING;
|
|
1321
|
+
};
|
|
1322
|
+
Temporals.nextWorkingDayOrSame = function nextWorkingDayOrSame() {
|
|
1323
|
+
return Adjuster.NEXT_WORKING_OR_SAME;
|
|
1324
|
+
};
|
|
1325
|
+
Temporals.previousWorkingDay = function previousWorkingDay() {
|
|
1326
|
+
return Adjuster.PREVIOUS_WORKING;
|
|
1327
|
+
};
|
|
1328
|
+
Temporals.previousWorkingDayOrSame = function previousWorkingDayOrSame() {
|
|
1329
|
+
return Adjuster.PREVIOUS_WORKING_OR_SAME;
|
|
1330
|
+
};
|
|
1331
|
+
Temporals.parseFirstMatching = function parseFirstMatching(text, query) {
|
|
1332
|
+
requireNonNull(text, 'text');
|
|
1333
|
+
requireNonNull(query, 'query');
|
|
1334
|
+
for (var _len = arguments.length, formatters = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
1335
|
+
formatters[_key - 2] = arguments[_key];
|
|
1336
|
+
}
|
|
1337
|
+
requireNonNull(formatters, 'formatters');
|
|
1338
|
+
if (formatters.length === 0) {
|
|
1339
|
+
throw new DateTimeParseException('No formatters specified', text, 0);
|
|
1340
|
+
}
|
|
1341
|
+
if (formatters.length === 1) {
|
|
1342
|
+
return formatters[0].parse(text, query);
|
|
1343
|
+
}
|
|
1344
|
+
for (var _i = 0, _formatters = formatters; _i < _formatters.length; _i++) {
|
|
1345
|
+
var formatter = _formatters[_i];
|
|
1346
|
+
try {
|
|
1347
|
+
var pp = new ParsePosition(0);
|
|
1348
|
+
formatter.parseUnresolved(text, pp);
|
|
1349
|
+
var len = text.length;
|
|
1350
|
+
if (pp.getErrorIndex() === -1 && pp.getIndex() === len) {
|
|
1351
|
+
return formatter.parse(text, query);
|
|
1352
|
+
}
|
|
1353
|
+
} catch (ignored) {}
|
|
1354
|
+
}
|
|
1355
|
+
throw new DateTimeParseException("Text '" + text + "' could not be parsed", text, 0);
|
|
1356
|
+
};
|
|
1357
|
+
Temporals.convertAmount = function convertAmount(amount, fromUnit, toUnit) {
|
|
1358
|
+
requireNonNull(fromUnit, 'fromUnit');
|
|
1359
|
+
requireNonNull(toUnit, 'toUnit');
|
|
1360
|
+
Temporals._validateUnit(fromUnit);
|
|
1361
|
+
Temporals._validateUnit(toUnit);
|
|
1362
|
+
if (fromUnit === toUnit) {
|
|
1363
|
+
return [amount, 0];
|
|
1364
|
+
}
|
|
1365
|
+
if (Temporals._isPrecise(fromUnit) && Temporals._isPrecise(toUnit)) {
|
|
1366
|
+
var fromNanos = fromUnit.duration().toNanos();
|
|
1367
|
+
var toNanos = toUnit.duration().toNanos();
|
|
1368
|
+
if (fromNanos > toNanos) {
|
|
1369
|
+
var multiple = MathUtil$2.intDiv(fromNanos, toNanos);
|
|
1370
|
+
return [MathUtil$2.safeMultiply(amount, multiple), 0];
|
|
1371
|
+
} else {
|
|
1372
|
+
var _multiple = MathUtil$2.intDiv(toNanos, fromNanos);
|
|
1373
|
+
return [MathUtil$2.intDiv(amount, _multiple), MathUtil$2.intMod(amount, _multiple)];
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
var fromMonthFactor = Temporals._monthMonthFactor(fromUnit, fromUnit, toUnit);
|
|
1377
|
+
var toMonthFactor = Temporals._monthMonthFactor(toUnit, fromUnit, toUnit);
|
|
1378
|
+
if (fromMonthFactor > toMonthFactor) {
|
|
1379
|
+
var _multiple2 = MathUtil$2.intDiv(fromMonthFactor, toMonthFactor);
|
|
1380
|
+
return [MathUtil$2.safeMultiply(amount, _multiple2), 0];
|
|
1381
|
+
} else {
|
|
1382
|
+
var _multiple3 = MathUtil$2.intDiv(toMonthFactor, fromMonthFactor);
|
|
1383
|
+
return [MathUtil$2.intDiv(amount, _multiple3), MathUtil$2.intMod(amount, _multiple3)];
|
|
1384
|
+
}
|
|
1385
|
+
};
|
|
1386
|
+
Temporals._validateUnit = function _validateUnit(unit) {
|
|
1387
|
+
if (unit instanceof ChronoUnit) {
|
|
1388
|
+
if (unit === ChronoUnit.ERAS || unit === ChronoUnit.FOREVER) {
|
|
1389
|
+
throw new UnsupportedTemporalTypeException("Unsupported TemporalUnit: " + unit);
|
|
1390
|
+
}
|
|
1391
|
+
} else if (unit !== IsoFields.QUARTER_YEARS) {
|
|
1392
|
+
throw new UnsupportedTemporalTypeException("Unsupported TemporalUnit: " + unit);
|
|
1393
|
+
}
|
|
1394
|
+
};
|
|
1395
|
+
Temporals._isPrecise = function _isPrecise(unit) {
|
|
1396
|
+
return unit instanceof ChronoUnit && unit.compareTo(ChronoUnit.WEEKS) <= 0;
|
|
1397
|
+
};
|
|
1398
|
+
Temporals._monthMonthFactor = function _monthMonthFactor(unit, fromUnit, toUnit) {
|
|
1399
|
+
if (unit instanceof ChronoUnit) {
|
|
1400
|
+
switch (unit) {
|
|
1401
|
+
case ChronoUnit.MONTHS:
|
|
1402
|
+
return 1;
|
|
1403
|
+
case ChronoUnit.YEARS:
|
|
1404
|
+
return 12;
|
|
1405
|
+
case ChronoUnit.DECADES:
|
|
1406
|
+
return 120;
|
|
1407
|
+
case ChronoUnit.CENTURIES:
|
|
1408
|
+
return 1200;
|
|
1409
|
+
case ChronoUnit.MILLENNIA:
|
|
1410
|
+
return 12000;
|
|
1411
|
+
default:
|
|
1412
|
+
throw new DateTimeException("Unable to convert between units: " + fromUnit + " to " + toUnit);
|
|
1413
|
+
}
|
|
1414
|
+
}
|
|
1415
|
+
return 3;
|
|
1416
|
+
};
|
|
1417
|
+
function Temporals() {}
|
|
1418
|
+
return Temporals;
|
|
1419
|
+
}();
|
|
1420
|
+
var Adjuster = {};
|
|
1421
|
+
function _init$2() {
|
|
1422
|
+
Adjuster.NEXT_WORKING = new (function (_TemporalAdjuster) {
|
|
1423
|
+
_inheritsLoose(_class, _TemporalAdjuster);
|
|
1424
|
+
function _class() {
|
|
1425
|
+
return _TemporalAdjuster.apply(this, arguments) || this;
|
|
1426
|
+
}
|
|
1427
|
+
var _proto = _class.prototype;
|
|
1428
|
+
_proto.adjustInto = function adjustInto(temporal) {
|
|
1429
|
+
var dow = temporal.get(ChronoField.DAY_OF_WEEK);
|
|
1430
|
+
switch (dow) {
|
|
1431
|
+
case 6:
|
|
1432
|
+
return temporal.plus(2, ChronoUnit.DAYS);
|
|
1433
|
+
case 5:
|
|
1434
|
+
return temporal.plus(3, ChronoUnit.DAYS);
|
|
1435
|
+
default:
|
|
1436
|
+
return temporal.plus(1, ChronoUnit.DAYS);
|
|
1437
|
+
}
|
|
1438
|
+
};
|
|
1439
|
+
return _class;
|
|
1440
|
+
}(TemporalAdjuster))();
|
|
1441
|
+
Adjuster.PREVIOUS_WORKING = new (function (_TemporalAdjuster2) {
|
|
1442
|
+
_inheritsLoose(_class2, _TemporalAdjuster2);
|
|
1443
|
+
function _class2() {
|
|
1444
|
+
return _TemporalAdjuster2.apply(this, arguments) || this;
|
|
1445
|
+
}
|
|
1446
|
+
var _proto2 = _class2.prototype;
|
|
1447
|
+
_proto2.adjustInto = function adjustInto(temporal) {
|
|
1448
|
+
var dow = temporal.get(ChronoField.DAY_OF_WEEK);
|
|
1449
|
+
switch (dow) {
|
|
1450
|
+
case 1:
|
|
1451
|
+
return temporal.minus(3, ChronoUnit.DAYS);
|
|
1452
|
+
case 7:
|
|
1453
|
+
return temporal.minus(2, ChronoUnit.DAYS);
|
|
1454
|
+
default:
|
|
1455
|
+
return temporal.minus(1, ChronoUnit.DAYS);
|
|
1456
|
+
}
|
|
1457
|
+
};
|
|
1458
|
+
return _class2;
|
|
1459
|
+
}(TemporalAdjuster))();
|
|
1460
|
+
Adjuster.NEXT_WORKING_OR_SAME = new (function (_TemporalAdjuster3) {
|
|
1461
|
+
_inheritsLoose(_class3, _TemporalAdjuster3);
|
|
1462
|
+
function _class3() {
|
|
1463
|
+
return _TemporalAdjuster3.apply(this, arguments) || this;
|
|
1464
|
+
}
|
|
1465
|
+
var _proto3 = _class3.prototype;
|
|
1466
|
+
_proto3.adjustInto = function adjustInto(temporal) {
|
|
1467
|
+
var dow = temporal.get(ChronoField.DAY_OF_WEEK);
|
|
1468
|
+
switch (dow) {
|
|
1469
|
+
case 6:
|
|
1470
|
+
return temporal.plus(2, ChronoUnit.DAYS);
|
|
1471
|
+
case 7:
|
|
1472
|
+
return temporal.plus(1, ChronoUnit.DAYS);
|
|
1473
|
+
default:
|
|
1474
|
+
return temporal;
|
|
1475
|
+
}
|
|
1476
|
+
};
|
|
1477
|
+
return _class3;
|
|
1478
|
+
}(TemporalAdjuster))();
|
|
1479
|
+
Adjuster.PREVIOUS_WORKING_OR_SAME = new (function (_TemporalAdjuster4) {
|
|
1480
|
+
_inheritsLoose(_class4, _TemporalAdjuster4);
|
|
1481
|
+
function _class4() {
|
|
1482
|
+
return _TemporalAdjuster4.apply(this, arguments) || this;
|
|
1483
|
+
}
|
|
1484
|
+
var _proto4 = _class4.prototype;
|
|
1485
|
+
_proto4.adjustInto = function adjustInto(temporal) {
|
|
1486
|
+
var dow = temporal.get(ChronoField.DAY_OF_WEEK);
|
|
1487
|
+
switch (dow) {
|
|
1488
|
+
case 6:
|
|
1489
|
+
return temporal.minus(1, ChronoUnit.DAYS);
|
|
1490
|
+
case 7:
|
|
1491
|
+
return temporal.minus(2, ChronoUnit.DAYS);
|
|
1492
|
+
default:
|
|
1493
|
+
return temporal;
|
|
1494
|
+
}
|
|
1495
|
+
};
|
|
1496
|
+
return _class4;
|
|
1497
|
+
}(TemporalAdjuster))();
|
|
1498
|
+
}
|
|
1499
|
+
|
|
1695
1500
|
var MathUtil$1 = _.MathUtil;
|
|
1696
1501
|
var YearQuarter = function (_Temporal) {
|
|
1697
1502
|
_inheritsLoose(YearQuarter, _Temporal);
|
|
1698
|
-
|
|
1699
1503
|
YearQuarter.now = function now(zoneIdOrClock) {
|
|
1700
1504
|
if (arguments.length === 0) {
|
|
1701
1505
|
return YearQuarter._now0();
|
|
@@ -1705,68 +1509,53 @@ var YearQuarter = function (_Temporal) {
|
|
|
1705
1509
|
return YearQuarter._nowClock(zoneIdOrClock);
|
|
1706
1510
|
}
|
|
1707
1511
|
};
|
|
1708
|
-
|
|
1709
1512
|
YearQuarter._now0 = function _now0() {
|
|
1710
1513
|
return YearQuarter.now(Clock.systemDefaultZone());
|
|
1711
1514
|
};
|
|
1712
|
-
|
|
1713
1515
|
YearQuarter._nowZoneId = function _nowZoneId(zone) {
|
|
1714
1516
|
return YearQuarter.now(Clock.system(zone));
|
|
1715
1517
|
};
|
|
1716
|
-
|
|
1717
1518
|
YearQuarter._nowClock = function _nowClock(clock) {
|
|
1718
1519
|
var now = LocalDate.now(clock);
|
|
1719
1520
|
return YearQuarter.of(now.getYear(), Quarter.from(now.getMonth()));
|
|
1720
1521
|
};
|
|
1721
|
-
|
|
1722
1522
|
YearQuarter.of = function of(year, quarter) {
|
|
1723
1523
|
if (year instanceof Year && quarter instanceof Quarter) {
|
|
1724
1524
|
return YearQuarter._ofYearQuarter(year, quarter);
|
|
1725
1525
|
}
|
|
1726
|
-
|
|
1727
1526
|
if (year instanceof Year && typeof quarter === 'number') {
|
|
1728
1527
|
return YearQuarter._ofYearInt(year, quarter);
|
|
1729
1528
|
}
|
|
1730
|
-
|
|
1731
1529
|
if (typeof year === 'number' && quarter instanceof Quarter) {
|
|
1732
1530
|
return YearQuarter._ofIntQuarter(year, quarter);
|
|
1733
1531
|
}
|
|
1734
|
-
|
|
1735
1532
|
if (typeof year === 'number' && typeof quarter === 'number') {
|
|
1736
1533
|
return YearQuarter._ofIntInt(year, quarter);
|
|
1737
1534
|
}
|
|
1738
|
-
|
|
1739
1535
|
var yearMessage = "year must be an instance of Year or number but is " + year.constructor.name;
|
|
1740
1536
|
var quarterMessage = "quarter must be an instance of Quarter or number but is " + quarter.constructor.name;
|
|
1741
1537
|
throw new IllegalArgumentException(yearMessage + " and " + quarterMessage);
|
|
1742
1538
|
};
|
|
1743
|
-
|
|
1744
1539
|
YearQuarter._ofYearQuarter = function _ofYearQuarter(year, quarter) {
|
|
1745
1540
|
return YearQuarter.of(year.value(), quarter);
|
|
1746
1541
|
};
|
|
1747
|
-
|
|
1748
1542
|
YearQuarter._ofYearInt = function _ofYearInt(year, quarter) {
|
|
1749
1543
|
return YearQuarter.of(year.value(), Quarter.of(quarter));
|
|
1750
1544
|
};
|
|
1751
|
-
|
|
1752
1545
|
YearQuarter._ofIntQuarter = function _ofIntQuarter(year, quarter) {
|
|
1753
1546
|
ChronoField.YEAR.checkValidValue(year);
|
|
1754
1547
|
requireNonNull(quarter, 'quarter');
|
|
1755
1548
|
return new YearQuarter(year, quarter);
|
|
1756
1549
|
};
|
|
1757
|
-
|
|
1758
1550
|
YearQuarter._ofIntInt = function _ofIntInt(year, quarter) {
|
|
1759
1551
|
ChronoField.YEAR.checkValidValue(year);
|
|
1760
1552
|
return new YearQuarter(year, Quarter.of(quarter));
|
|
1761
1553
|
};
|
|
1762
|
-
|
|
1763
1554
|
YearQuarter.from = function from(temporal) {
|
|
1764
1555
|
if (temporal instanceof YearQuarter) {
|
|
1765
1556
|
return temporal;
|
|
1766
1557
|
}
|
|
1767
|
-
|
|
1768
1558
|
requireNonNull(temporal, 'temporal');
|
|
1769
|
-
|
|
1770
1559
|
try {
|
|
1771
1560
|
var year = MathUtil$1.safeToInt(temporal.getLong(ChronoField.YEAR));
|
|
1772
1561
|
var qoy = MathUtil$1.safeToInt(temporal.getLong(IsoFields.QUARTER_OF_YEAR));
|
|
@@ -1775,195 +1564,149 @@ var YearQuarter = function (_Temporal) {
|
|
|
1775
1564
|
throw new DateTimeException("Unable to obtain YearQuarter from TemporalAccessor: " + temporal + " of type " + temporal.constructor.name, ex);
|
|
1776
1565
|
}
|
|
1777
1566
|
};
|
|
1778
|
-
|
|
1779
1567
|
YearQuarter.parse = function parse(text, formatter) {
|
|
1780
1568
|
if (formatter === void 0) {
|
|
1781
1569
|
formatter = YearQuarter.PARSER;
|
|
1782
1570
|
}
|
|
1783
|
-
|
|
1784
1571
|
requireNonNull(formatter, 'formatter');
|
|
1785
1572
|
requireInstance(formatter, DateTimeFormatter, 'formatter');
|
|
1786
1573
|
return formatter.parse(text, YearQuarter.FROM);
|
|
1787
1574
|
};
|
|
1788
|
-
|
|
1789
1575
|
function YearQuarter(year, quarter) {
|
|
1790
1576
|
var _this;
|
|
1791
|
-
|
|
1792
1577
|
_this = _Temporal.call(this) || this;
|
|
1793
1578
|
_this._year = MathUtil$1.safeToInt(year);
|
|
1794
1579
|
_this._quarter = requireInstance(quarter, Quarter, 'Quarter');
|
|
1795
1580
|
return _this;
|
|
1796
1581
|
}
|
|
1797
|
-
|
|
1798
1582
|
var _proto = YearQuarter.prototype;
|
|
1799
|
-
|
|
1800
1583
|
_proto._with = function _with(newYear, newQuarter) {
|
|
1801
1584
|
if (this._year === newYear && this._quarter === newQuarter) {
|
|
1802
1585
|
return this;
|
|
1803
1586
|
}
|
|
1804
|
-
|
|
1805
1587
|
return new YearQuarter(newYear, newQuarter);
|
|
1806
1588
|
};
|
|
1807
|
-
|
|
1808
1589
|
_proto.isSupported = function isSupported(fieldOrUnit) {
|
|
1809
1590
|
if (fieldOrUnit instanceof TemporalField) {
|
|
1810
1591
|
return this._isSupportedField(fieldOrUnit);
|
|
1811
1592
|
}
|
|
1812
|
-
|
|
1813
1593
|
if (fieldOrUnit instanceof TemporalUnit) {
|
|
1814
1594
|
return this._isSupportedUnit(fieldOrUnit);
|
|
1815
1595
|
}
|
|
1816
|
-
|
|
1817
1596
|
if (fieldOrUnit == null) {
|
|
1818
1597
|
return false;
|
|
1819
1598
|
}
|
|
1820
|
-
|
|
1821
1599
|
throw new IllegalArgumentException("fieldOrUnit must be an instance of TemporalField or TemporalUnit, but is " + fieldOrUnit.constructor.name);
|
|
1822
1600
|
};
|
|
1823
|
-
|
|
1824
1601
|
_proto._isSupportedField = function _isSupportedField(field) {
|
|
1825
1602
|
if (field === IsoFields.QUARTER_OF_YEAR) {
|
|
1826
1603
|
return true;
|
|
1827
1604
|
} else if (field instanceof ChronoField) {
|
|
1828
1605
|
return field === ChronoField.YEAR || field === ChronoField.YEAR_OF_ERA || field === ChronoField.ERA;
|
|
1829
1606
|
}
|
|
1830
|
-
|
|
1831
1607
|
return field != null && field.isSupportedBy(this);
|
|
1832
1608
|
};
|
|
1833
|
-
|
|
1834
1609
|
_proto._isSupportedUnit = function _isSupportedUnit(unit) {
|
|
1835
1610
|
if (unit === IsoFields.QUARTER_YEARS) {
|
|
1836
1611
|
return true;
|
|
1837
1612
|
} else if (unit instanceof ChronoUnit) {
|
|
1838
1613
|
return unit === ChronoUnit.YEARS || unit === ChronoUnit.DECADES || unit === ChronoUnit.CENTURIES || unit === ChronoUnit.MILLENNIA || unit === ChronoUnit.ERAS;
|
|
1839
1614
|
}
|
|
1840
|
-
|
|
1841
1615
|
return unit != null && unit.isSupportedBy(this);
|
|
1842
1616
|
};
|
|
1843
|
-
|
|
1844
1617
|
_proto.range = function range(field) {
|
|
1845
1618
|
requireNonNull(field, 'field');
|
|
1846
1619
|
requireInstance(field, TemporalField, 'field');
|
|
1847
|
-
|
|
1848
1620
|
if (field === IsoFields.QUARTER_OF_YEAR) {
|
|
1849
1621
|
return IsoFields.QUARTER_OF_YEAR.range();
|
|
1850
1622
|
}
|
|
1851
|
-
|
|
1852
1623
|
if (field === ChronoField.YEAR_OF_ERA) {
|
|
1853
1624
|
return this.year() <= 0 ? ValueRange.of(1, Year.MAX_VALUE + 1) : ValueRange.of(1, Year.MAX_VALUE);
|
|
1854
1625
|
}
|
|
1855
|
-
|
|
1856
1626
|
return _Temporal.prototype.range.call(this, field);
|
|
1857
1627
|
};
|
|
1858
|
-
|
|
1859
1628
|
_proto.get = function get(field) {
|
|
1860
1629
|
requireNonNull(field, 'field');
|
|
1861
1630
|
requireInstance(field, TemporalField, 'field');
|
|
1862
1631
|
return this.range(field).checkValidIntValue(this.getLong(field), field);
|
|
1863
1632
|
};
|
|
1864
|
-
|
|
1865
1633
|
_proto.getLong = function getLong(field) {
|
|
1866
1634
|
requireNonNull(field, 'field');
|
|
1867
1635
|
requireInstance(field, TemporalField, 'field');
|
|
1868
|
-
|
|
1869
1636
|
if (field === IsoFields.QUARTER_OF_YEAR) {
|
|
1870
1637
|
return this._quarter.value();
|
|
1871
1638
|
} else if (field instanceof ChronoField) {
|
|
1872
1639
|
switch (field) {
|
|
1873
1640
|
case ChronoField.YEAR_OF_ERA:
|
|
1874
1641
|
return this._year < 1 ? 1 - this._year : this._year;
|
|
1875
|
-
|
|
1876
1642
|
case ChronoField.YEAR:
|
|
1877
1643
|
return this._year;
|
|
1878
|
-
|
|
1879
1644
|
case ChronoField.ERA:
|
|
1880
1645
|
return this._year < 1 ? 0 : 1;
|
|
1881
|
-
|
|
1882
1646
|
default:
|
|
1883
1647
|
throw new UnsupportedTemporalTypeException("Unsupported field: " + field);
|
|
1884
1648
|
}
|
|
1885
1649
|
}
|
|
1886
|
-
|
|
1887
1650
|
return _Temporal.prototype.get.call(this, field);
|
|
1888
1651
|
};
|
|
1889
|
-
|
|
1890
1652
|
_proto._prolepticQuarter = function _prolepticQuarter() {
|
|
1891
1653
|
return this._year * 4 + (this._quarter.value() - 1);
|
|
1892
1654
|
};
|
|
1893
|
-
|
|
1894
1655
|
_proto.year = function year() {
|
|
1895
1656
|
return this._year;
|
|
1896
1657
|
};
|
|
1897
|
-
|
|
1898
1658
|
_proto.quarterValue = function quarterValue() {
|
|
1899
1659
|
return this._quarter.value();
|
|
1900
1660
|
};
|
|
1901
|
-
|
|
1902
1661
|
_proto.quarter = function quarter() {
|
|
1903
1662
|
return this._quarter;
|
|
1904
1663
|
};
|
|
1905
|
-
|
|
1906
1664
|
_proto.isLeapYear = function isLeapYear() {
|
|
1907
1665
|
return IsoChronology.isLeapYear(this._year);
|
|
1908
1666
|
};
|
|
1909
|
-
|
|
1910
1667
|
_proto.isValidDay = function isValidDay(dayOfQuarter) {
|
|
1911
1668
|
return dayOfQuarter >= 1 && dayOfQuarter <= this.lengthOfQuarter();
|
|
1912
1669
|
};
|
|
1913
|
-
|
|
1914
1670
|
_proto.lengthOfQuarter = function lengthOfQuarter() {
|
|
1915
1671
|
return this._quarter.length(this.isLeapYear());
|
|
1916
1672
|
};
|
|
1917
|
-
|
|
1918
1673
|
_proto.lengthOfYear = function lengthOfYear() {
|
|
1919
1674
|
return this.isLeapYear() ? 366 : 365;
|
|
1920
1675
|
};
|
|
1921
|
-
|
|
1922
1676
|
_proto._withAdjuster = function _withAdjuster(adjuster) {
|
|
1923
1677
|
if (adjuster instanceof YearQuarter) {
|
|
1924
1678
|
return adjuster;
|
|
1925
1679
|
}
|
|
1926
|
-
|
|
1927
1680
|
return _Temporal.prototype._withAdjuster.call(this, adjuster);
|
|
1928
1681
|
};
|
|
1929
|
-
|
|
1930
1682
|
_proto._withField = function _withField(field, newValue) {
|
|
1931
1683
|
requireNonNull(field, 'field');
|
|
1932
1684
|
requireInstance(field, TemporalField, 'field');
|
|
1933
|
-
|
|
1934
1685
|
if (field === IsoFields.QUARTER_OF_YEAR) {
|
|
1935
1686
|
return this.withQuarter(IsoFields.QUARTER_OF_YEAR.range().checkValidIntValue(newValue, IsoFields.QUARTER_OF_YEAR));
|
|
1936
1687
|
} else if (field instanceof ChronoField) {
|
|
1937
1688
|
field.checkValidValue(newValue);
|
|
1938
|
-
|
|
1939
1689
|
switch (field) {
|
|
1940
1690
|
case ChronoField.YEAR_OF_ERA:
|
|
1941
1691
|
return this.withYear(this._year < 1 ? 1 - newValue : newValue);
|
|
1942
|
-
|
|
1943
1692
|
case ChronoField.YEAR:
|
|
1944
1693
|
return this.withYear(newValue);
|
|
1945
|
-
|
|
1946
1694
|
case ChronoField.ERA:
|
|
1947
1695
|
return this.getLong(ChronoField.ERA) === newValue ? this : this.withYear(1 - this._year);
|
|
1948
|
-
|
|
1949
1696
|
default:
|
|
1950
1697
|
throw new UnsupportedTemporalTypeException("Unsupported field: " + field);
|
|
1951
1698
|
}
|
|
1952
1699
|
}
|
|
1953
|
-
|
|
1954
1700
|
return field.adjustInto(this, newValue);
|
|
1955
1701
|
};
|
|
1956
|
-
|
|
1957
1702
|
_proto.withYear = function withYear(year) {
|
|
1958
1703
|
ChronoField.YEAR.checkValidValue(year);
|
|
1959
1704
|
return this._with(year, this._quarter);
|
|
1960
1705
|
};
|
|
1961
|
-
|
|
1962
1706
|
_proto.withQuarter = function withQuarter(quarter) {
|
|
1963
1707
|
IsoFields.QUARTER_OF_YEAR.range().checkValidValue(quarter, IsoFields.QUARTER_OF_YEAR);
|
|
1964
1708
|
return this._with(this._year, Quarter.of(quarter));
|
|
1965
1709
|
};
|
|
1966
|
-
|
|
1967
1710
|
_proto._plusUnit = function _plusUnit(amountToAdd, unit) {
|
|
1968
1711
|
if (unit === IsoFields.QUARTER_YEARS) {
|
|
1969
1712
|
return this.plusQuarters(amountToAdd);
|
|
@@ -1971,176 +1714,133 @@ var YearQuarter = function (_Temporal) {
|
|
|
1971
1714
|
switch (unit) {
|
|
1972
1715
|
case ChronoUnit.YEARS:
|
|
1973
1716
|
return this.plusYears(amountToAdd);
|
|
1974
|
-
|
|
1975
1717
|
case ChronoUnit.DECADES:
|
|
1976
1718
|
return this.plusYears(MathUtil$1.safeMultiply(amountToAdd, 10));
|
|
1977
|
-
|
|
1978
1719
|
case ChronoUnit.CENTURIES:
|
|
1979
1720
|
return this.plusYears(MathUtil$1.safeMultiply(amountToAdd, 100));
|
|
1980
|
-
|
|
1981
1721
|
case ChronoUnit.MILLENNIA:
|
|
1982
1722
|
return this.plusYears(MathUtil$1.safeMultiply(amountToAdd, 1000));
|
|
1983
|
-
|
|
1984
1723
|
case ChronoUnit.ERAS:
|
|
1985
1724
|
return this.with(ChronoField.ERA, MathUtil$1.safeAdd(this.getLong(ChronoField.ERA), amountToAdd));
|
|
1986
|
-
|
|
1987
1725
|
default:
|
|
1988
1726
|
throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit);
|
|
1989
1727
|
}
|
|
1990
1728
|
}
|
|
1991
|
-
|
|
1992
1729
|
return unit.addTo(this, amountToAdd);
|
|
1993
1730
|
};
|
|
1994
|
-
|
|
1995
1731
|
_proto.plusYears = function plusYears(yearsToAdd) {
|
|
1996
1732
|
if (yearsToAdd === 0) {
|
|
1997
1733
|
return this;
|
|
1998
1734
|
}
|
|
1999
|
-
|
|
2000
1735
|
var newYear = ChronoField.YEAR.checkValidIntValue(this._year + yearsToAdd);
|
|
2001
1736
|
return this._with(newYear, this._quarter);
|
|
2002
1737
|
};
|
|
2003
|
-
|
|
2004
1738
|
_proto.plusQuarters = function plusQuarters(quartersToAdd) {
|
|
2005
1739
|
if (quartersToAdd === 0) {
|
|
2006
1740
|
return this;
|
|
2007
1741
|
}
|
|
2008
|
-
|
|
2009
1742
|
var quarterCount = this._year * 4 + (this._quarter.value() - 1);
|
|
2010
1743
|
var calcQuarters = quarterCount + quartersToAdd;
|
|
2011
1744
|
var newYear = ChronoField.YEAR.checkValidIntValue(MathUtil$1.intDiv(calcQuarters, 4));
|
|
2012
1745
|
var newQuarter = MathUtil$1.floorMod(calcQuarters, 4) + 1;
|
|
2013
1746
|
return this._with(newYear, Quarter.of(newQuarter));
|
|
2014
1747
|
};
|
|
2015
|
-
|
|
2016
1748
|
_proto.minusYears = function minusYears(yearsToSubtract) {
|
|
2017
1749
|
return yearsToSubtract === MathUtil$1.MIN_SAFE_INTEGER ? this.plusYears(MathUtil$1.MIN_SAFE_INTEGER).plusYears(1) : this.plusYears(-yearsToSubtract);
|
|
2018
1750
|
};
|
|
2019
|
-
|
|
2020
1751
|
_proto.minusQuarters = function minusQuarters(quartersToSubtract) {
|
|
2021
1752
|
return quartersToSubtract === MathUtil$1.MIN_SAFE_INTEGER ? this.plusQuarters(MathUtil$1.MIN_SAFE_INTEGER).plusQuarters(1) : this.plusQuarters(-quartersToSubtract);
|
|
2022
1753
|
};
|
|
2023
|
-
|
|
2024
1754
|
_proto.query = function query(_query) {
|
|
2025
1755
|
if (_query === TemporalQueries.chronology()) {
|
|
2026
1756
|
return IsoChronology.INSTANCE;
|
|
2027
1757
|
} else if (_query === TemporalQueries.precision()) {
|
|
2028
1758
|
return IsoFields.QUARTER_YEARS;
|
|
2029
1759
|
}
|
|
2030
|
-
|
|
2031
1760
|
return _Temporal.prototype.query.call(this, _query);
|
|
2032
1761
|
};
|
|
2033
|
-
|
|
2034
1762
|
_proto.adjustInto = function adjustInto(temporal) {
|
|
2035
1763
|
var newProlepticQuarter = this._prolepticQuarter();
|
|
2036
|
-
|
|
2037
1764
|
var oldProlepticQuarter = temporal.get(ChronoField.YEAR) * 4 + (temporal.get(IsoFields.QUARTER_OF_YEAR) - 1);
|
|
2038
1765
|
return temporal.plus(newProlepticQuarter - oldProlepticQuarter, IsoFields.QUARTER_YEARS);
|
|
2039
1766
|
};
|
|
2040
|
-
|
|
2041
1767
|
_proto.until = function until(endExclusive, unit) {
|
|
2042
1768
|
requireNonNull(endExclusive, 'endExclusive');
|
|
2043
1769
|
requireNonNull(unit, 'unit');
|
|
2044
1770
|
requireInstance(endExclusive, Temporal, 'endExclusive');
|
|
2045
1771
|
requireInstance(unit, TemporalUnit, 'unit');
|
|
2046
1772
|
var end = YearQuarter.from(endExclusive);
|
|
2047
|
-
|
|
2048
1773
|
var quartersUntil = end._prolepticQuarter() - this._prolepticQuarter();
|
|
2049
|
-
|
|
2050
1774
|
if (unit === IsoFields.QUARTER_YEARS) {
|
|
2051
1775
|
return quartersUntil;
|
|
2052
1776
|
} else if (unit instanceof ChronoUnit) {
|
|
2053
1777
|
switch (unit) {
|
|
2054
1778
|
case ChronoUnit.YEARS:
|
|
2055
1779
|
return MathUtil$1.intDiv(quartersUntil, 4);
|
|
2056
|
-
|
|
2057
1780
|
case ChronoUnit.DECADES:
|
|
2058
1781
|
return MathUtil$1.intDiv(quartersUntil, 40);
|
|
2059
|
-
|
|
2060
1782
|
case ChronoUnit.CENTURIES:
|
|
2061
1783
|
return MathUtil$1.intDiv(quartersUntil, 400);
|
|
2062
|
-
|
|
2063
1784
|
case ChronoUnit.MILLENNIA:
|
|
2064
1785
|
return MathUtil$1.intDiv(quartersUntil, 4000);
|
|
2065
|
-
|
|
2066
1786
|
case ChronoUnit.ERAS:
|
|
2067
1787
|
return end.getLong(ChronoField.ERA) - this.getLong(ChronoField.ERA);
|
|
2068
|
-
|
|
2069
1788
|
default:
|
|
2070
1789
|
throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit);
|
|
2071
1790
|
}
|
|
2072
1791
|
}
|
|
2073
|
-
|
|
2074
1792
|
return unit.between(this, end);
|
|
2075
1793
|
};
|
|
2076
|
-
|
|
2077
1794
|
_proto.format = function format(formatter) {
|
|
2078
1795
|
requireNonNull(formatter, 'formatter');
|
|
2079
1796
|
return formatter.format(this);
|
|
2080
1797
|
};
|
|
2081
|
-
|
|
2082
1798
|
_proto.atDay = function atDay(dayOfQuarter) {
|
|
2083
1799
|
ValueRange.of(1, this.lengthOfQuarter()).checkValidValue(dayOfQuarter, IsoFields.DAY_OF_QUARTER);
|
|
2084
1800
|
var leap = Year.isLeap(this._year);
|
|
2085
|
-
|
|
2086
1801
|
var month = this._quarter.firstMonth();
|
|
2087
|
-
|
|
2088
1802
|
while (dayOfQuarter > month.length(leap)) {
|
|
2089
1803
|
dayOfQuarter -= month.length(leap);
|
|
2090
1804
|
month = month.plus(1);
|
|
2091
1805
|
}
|
|
2092
|
-
|
|
2093
1806
|
return LocalDate.of(this._year, month, dayOfQuarter);
|
|
2094
1807
|
};
|
|
2095
|
-
|
|
2096
1808
|
_proto.atEndOfQuarter = function atEndOfQuarter() {
|
|
2097
1809
|
var month = this._quarter.firstMonth().plus(2);
|
|
2098
|
-
|
|
2099
1810
|
return LocalDate.of(this._year, month, month.maxLength());
|
|
2100
1811
|
};
|
|
2101
|
-
|
|
2102
1812
|
_proto.compareTo = function compareTo(other) {
|
|
2103
1813
|
requireNonNull(other, 'other');
|
|
2104
1814
|
requireInstance(other, YearQuarter, 'other');
|
|
2105
1815
|
var cmp = this._year - other._year;
|
|
2106
|
-
|
|
2107
1816
|
if (cmp === 0) {
|
|
2108
1817
|
cmp = this._quarter.compareTo(other._quarter);
|
|
2109
1818
|
}
|
|
2110
|
-
|
|
2111
1819
|
return cmp;
|
|
2112
1820
|
};
|
|
2113
|
-
|
|
2114
1821
|
_proto.isAfter = function isAfter(other) {
|
|
2115
1822
|
return this.compareTo(other) > 0;
|
|
2116
1823
|
};
|
|
2117
|
-
|
|
2118
1824
|
_proto.isBefore = function isBefore(other) {
|
|
2119
1825
|
return this.compareTo(other) < 0;
|
|
2120
1826
|
};
|
|
2121
|
-
|
|
2122
1827
|
_proto.equals = function equals(obj) {
|
|
2123
1828
|
if (this === obj) {
|
|
2124
1829
|
return true;
|
|
2125
1830
|
}
|
|
2126
|
-
|
|
2127
1831
|
if (obj instanceof YearQuarter) {
|
|
2128
1832
|
var other = obj;
|
|
2129
1833
|
return this._year === other._year && this._quarter === other._quarter;
|
|
2130
1834
|
}
|
|
2131
|
-
|
|
2132
1835
|
return false;
|
|
2133
1836
|
};
|
|
2134
|
-
|
|
2135
1837
|
_proto.hashCode = function hashCode() {
|
|
2136
1838
|
return this._year ^ this._quarter.value() << 27;
|
|
2137
1839
|
};
|
|
2138
|
-
|
|
2139
1840
|
_proto.toString = function toString() {
|
|
2140
1841
|
var yearString;
|
|
2141
1842
|
var yearValue = this._year;
|
|
2142
1843
|
var absYear = Math.abs(yearValue);
|
|
2143
|
-
|
|
2144
1844
|
if (absYear < 1000) {
|
|
2145
1845
|
if (yearValue < 0) {
|
|
2146
1846
|
yearString = "-" + ("" + (yearValue - 10000)).slice(-4);
|
|
@@ -2154,10 +1854,8 @@ var YearQuarter = function (_Temporal) {
|
|
|
2154
1854
|
yearString = "" + yearValue;
|
|
2155
1855
|
}
|
|
2156
1856
|
}
|
|
2157
|
-
|
|
2158
1857
|
return yearString.concat('-').concat(this._quarter);
|
|
2159
1858
|
};
|
|
2160
|
-
|
|
2161
1859
|
return YearQuarter;
|
|
2162
1860
|
}(Temporal);
|
|
2163
1861
|
function _init$1() {
|
|
@@ -2166,18 +1864,14 @@ function _init$1() {
|
|
|
2166
1864
|
return YearQuarter.from(temporal);
|
|
2167
1865
|
});
|
|
2168
1866
|
}
|
|
2169
|
-
|
|
2170
1867
|
function createTemporalQuery$1(name, queryFromFunction) {
|
|
2171
1868
|
var ExtendedTemporalQuery = function (_TemporalQuery) {
|
|
2172
1869
|
_inheritsLoose(ExtendedTemporalQuery, _TemporalQuery);
|
|
2173
|
-
|
|
2174
1870
|
function ExtendedTemporalQuery() {
|
|
2175
1871
|
return _TemporalQuery.apply(this, arguments) || this;
|
|
2176
1872
|
}
|
|
2177
|
-
|
|
2178
1873
|
return ExtendedTemporalQuery;
|
|
2179
1874
|
}(TemporalQuery);
|
|
2180
|
-
|
|
2181
1875
|
ExtendedTemporalQuery.prototype.queryFrom = queryFromFunction;
|
|
2182
1876
|
return new ExtendedTemporalQuery(name);
|
|
2183
1877
|
}
|
|
@@ -2185,46 +1879,35 @@ function createTemporalQuery$1(name, queryFromFunction) {
|
|
|
2185
1879
|
var MathUtil = _.MathUtil;
|
|
2186
1880
|
var YearWeek = function (_Temporal) {
|
|
2187
1881
|
_inheritsLoose(YearWeek, _Temporal);
|
|
2188
|
-
|
|
2189
1882
|
YearWeek.now = function now(zoneIdOrClock) {
|
|
2190
1883
|
switch (arguments.length) {
|
|
2191
1884
|
case 0:
|
|
2192
1885
|
return YearWeek._now0();
|
|
2193
|
-
|
|
2194
1886
|
case 1:
|
|
2195
1887
|
requireNonNull(zoneIdOrClock, 'clockOrZone');
|
|
2196
|
-
|
|
2197
1888
|
if (zoneIdOrClock instanceof ZoneId) {
|
|
2198
1889
|
return YearWeek._nowZoneId(zoneIdOrClock);
|
|
2199
1890
|
}
|
|
2200
|
-
|
|
2201
1891
|
if (zoneIdOrClock instanceof Clock) {
|
|
2202
1892
|
return YearWeek._nowClock(zoneIdOrClock);
|
|
2203
1893
|
}
|
|
2204
|
-
|
|
2205
1894
|
throw new IllegalArgumentException("zoneIdOrClock must be an instance of ZoneId or Clock, but is " + zoneIdOrClock.constructor.name);
|
|
2206
|
-
|
|
2207
1895
|
default:
|
|
2208
1896
|
throw new IllegalArgumentException("Invalid number of arguments: " + arguments.length);
|
|
2209
1897
|
}
|
|
2210
1898
|
};
|
|
2211
|
-
|
|
2212
1899
|
YearWeek._now0 = function _now0() {
|
|
2213
1900
|
return YearWeek.now(Clock.systemDefaultZone());
|
|
2214
1901
|
};
|
|
2215
|
-
|
|
2216
1902
|
YearWeek._nowZoneId = function _nowZoneId(zone) {
|
|
2217
1903
|
return YearWeek.now(Clock.system(zone));
|
|
2218
1904
|
};
|
|
2219
|
-
|
|
2220
1905
|
YearWeek._nowClock = function _nowClock(clock) {
|
|
2221
1906
|
var now = LocalDate.now(clock);
|
|
2222
1907
|
return YearWeek.of(now.get(IsoFields.WEEK_BASED_YEAR), now.get(IsoFields.WEEK_OF_WEEK_BASED_YEAR));
|
|
2223
1908
|
};
|
|
2224
|
-
|
|
2225
1909
|
YearWeek.of = function of(year, week) {
|
|
2226
1910
|
MathUtil.verifyInt(week);
|
|
2227
|
-
|
|
2228
1911
|
if (year instanceof Year) {
|
|
2229
1912
|
return this._ofYearWeek(year, week);
|
|
2230
1913
|
} else {
|
|
@@ -2232,42 +1915,32 @@ var YearWeek = function (_Temporal) {
|
|
|
2232
1915
|
return this._ofWeekBasedYear(year, week);
|
|
2233
1916
|
}
|
|
2234
1917
|
};
|
|
2235
|
-
|
|
2236
1918
|
YearWeek._ofYearWeek = function _ofYearWeek(year, week) {
|
|
2237
1919
|
var weekBasedYear = year.value();
|
|
2238
1920
|
return this._ofWeekBasedYear(weekBasedYear, week);
|
|
2239
1921
|
};
|
|
2240
|
-
|
|
2241
1922
|
YearWeek._ofWeekBasedYear = function _ofWeekBasedYear(weekBasedYear, week) {
|
|
2242
1923
|
IsoFields.WEEK_BASED_YEAR.range().checkValidValue(weekBasedYear, IsoFields.WEEK_BASED_YEAR);
|
|
2243
1924
|
IsoFields.WEEK_OF_WEEK_BASED_YEAR.range().checkValidValue(week, IsoFields.WEEK_OF_WEEK_BASED_YEAR);
|
|
2244
|
-
|
|
2245
1925
|
if (week === 53 && YearWeek._weekRange(weekBasedYear) < 53) {
|
|
2246
1926
|
week = 1;
|
|
2247
1927
|
weekBasedYear++;
|
|
2248
1928
|
IsoFields.WEEK_BASED_YEAR.range().checkValidValue(weekBasedYear, IsoFields.WEEK_BASED_YEAR);
|
|
2249
1929
|
}
|
|
2250
|
-
|
|
2251
1930
|
return new YearWeek(weekBasedYear, week);
|
|
2252
1931
|
};
|
|
2253
|
-
|
|
2254
1932
|
YearWeek._weekRange = function _weekRange(weekBasedYear) {
|
|
2255
1933
|
var date = LocalDate.of(weekBasedYear, 1, 1);
|
|
2256
|
-
|
|
2257
1934
|
if (date.dayOfWeek() === DayOfWeek.THURSDAY || date.dayOfWeek() === DayOfWeek.WEDNESDAY && date.isLeapYear()) {
|
|
2258
1935
|
return 53;
|
|
2259
1936
|
}
|
|
2260
|
-
|
|
2261
1937
|
return 52;
|
|
2262
1938
|
};
|
|
2263
|
-
|
|
2264
1939
|
YearWeek.from = function from(temporal) {
|
|
2265
1940
|
if (temporal instanceof YearWeek) {
|
|
2266
1941
|
return temporal;
|
|
2267
1942
|
}
|
|
2268
|
-
|
|
2269
1943
|
requireNonNull(temporal, 'temporal');
|
|
2270
|
-
|
|
2271
1944
|
try {
|
|
2272
1945
|
var year = MathUtil.safeToInt(temporal.getLong(IsoFields.WEEK_BASED_YEAR));
|
|
2273
1946
|
var week = MathUtil.safeToInt(temporal.getLong(IsoFields.WEEK_OF_WEEK_BASED_YEAR));
|
|
@@ -2276,123 +1949,93 @@ var YearWeek = function (_Temporal) {
|
|
|
2276
1949
|
throw new DateTimeException("Unable to obtain YearWeek from TemporalAccessor: " + temporal.constructor.name, ex);
|
|
2277
1950
|
}
|
|
2278
1951
|
};
|
|
2279
|
-
|
|
2280
1952
|
YearWeek.parse = function parse(text, formatter) {
|
|
2281
1953
|
if (formatter === void 0) {
|
|
2282
1954
|
formatter = YearWeek.PARSER;
|
|
2283
1955
|
}
|
|
2284
|
-
|
|
2285
1956
|
assert(formatter != null, 'formatter', NullPointerException);
|
|
2286
1957
|
return formatter.parse(text, YearWeek.FROM);
|
|
2287
1958
|
};
|
|
2288
|
-
|
|
2289
1959
|
function YearWeek(weekBasedYear, week) {
|
|
2290
1960
|
var _this;
|
|
2291
|
-
|
|
2292
1961
|
_this = _Temporal.call(this) || this;
|
|
2293
1962
|
_this._year = weekBasedYear;
|
|
2294
1963
|
_this._week = week;
|
|
2295
1964
|
return _this;
|
|
2296
1965
|
}
|
|
2297
|
-
|
|
2298
1966
|
var _proto = YearWeek.prototype;
|
|
2299
|
-
|
|
2300
1967
|
_proto.isSupported = function isSupported(fieldOrUnit) {
|
|
2301
1968
|
if (fieldOrUnit instanceof TemporalField) {
|
|
2302
1969
|
return this._isSupportedField(fieldOrUnit);
|
|
2303
1970
|
}
|
|
2304
|
-
|
|
2305
1971
|
if (fieldOrUnit instanceof TemporalUnit) {
|
|
2306
1972
|
return this._isSupportedUnit(fieldOrUnit);
|
|
2307
1973
|
}
|
|
2308
|
-
|
|
2309
1974
|
if (fieldOrUnit == null) {
|
|
2310
1975
|
return false;
|
|
2311
1976
|
}
|
|
2312
|
-
|
|
2313
1977
|
throw new IllegalArgumentException("fieldOrUnit must be an instance of TemporalField or TemporalUnit, but is " + fieldOrUnit.constructor.name);
|
|
2314
1978
|
};
|
|
2315
|
-
|
|
2316
1979
|
_proto._isSupportedField = function _isSupportedField(field) {
|
|
2317
1980
|
if (field === IsoFields.WEEK_OF_WEEK_BASED_YEAR || field === IsoFields.WEEK_BASED_YEAR) {
|
|
2318
1981
|
return true;
|
|
2319
1982
|
} else if (field instanceof ChronoField) {
|
|
2320
1983
|
return false;
|
|
2321
1984
|
}
|
|
2322
|
-
|
|
2323
1985
|
return field != null && field.isSupportedBy(this);
|
|
2324
1986
|
};
|
|
2325
|
-
|
|
2326
1987
|
_proto._isSupportedUnit = function _isSupportedUnit(unit) {
|
|
2327
1988
|
if (unit === ChronoUnit.WEEKS || unit === IsoFields.WEEK_BASED_YEARS) {
|
|
2328
1989
|
return true;
|
|
2329
1990
|
} else if (unit instanceof ChronoUnit) {
|
|
2330
1991
|
return false;
|
|
2331
1992
|
}
|
|
2332
|
-
|
|
2333
1993
|
return unit != null && unit.isSupportedBy(this);
|
|
2334
1994
|
};
|
|
2335
|
-
|
|
2336
1995
|
_proto.range = function range(field) {
|
|
2337
1996
|
requireNonNull(field, 'field');
|
|
2338
|
-
|
|
2339
1997
|
if (field === IsoFields.WEEK_BASED_YEAR) {
|
|
2340
1998
|
return IsoFields.WEEK_BASED_YEAR.range();
|
|
2341
1999
|
}
|
|
2342
|
-
|
|
2343
2000
|
if (field === IsoFields.WEEK_OF_WEEK_BASED_YEAR) {
|
|
2344
2001
|
return ValueRange.of(1, YearWeek._weekRange(this._year));
|
|
2345
2002
|
}
|
|
2346
|
-
|
|
2347
2003
|
return _Temporal.prototype.range.call(this, field);
|
|
2348
2004
|
};
|
|
2349
|
-
|
|
2350
2005
|
_proto.get = function get(field) {
|
|
2351
2006
|
return this.range(field).checkValidIntValue(this.getLong(field), field);
|
|
2352
2007
|
};
|
|
2353
|
-
|
|
2354
2008
|
_proto.getLong = function getLong(field) {
|
|
2355
2009
|
requireNonNull(field, 'field');
|
|
2356
|
-
|
|
2357
2010
|
if (field === IsoFields.WEEK_BASED_YEAR) {
|
|
2358
2011
|
return this._year;
|
|
2359
2012
|
}
|
|
2360
|
-
|
|
2361
2013
|
if (field === IsoFields.WEEK_OF_WEEK_BASED_YEAR) {
|
|
2362
2014
|
return this._week;
|
|
2363
2015
|
}
|
|
2364
|
-
|
|
2365
2016
|
if (field instanceof ChronoField) {
|
|
2366
2017
|
throw new UnsupportedTemporalTypeException("Unsupported field: " + field);
|
|
2367
2018
|
}
|
|
2368
|
-
|
|
2369
2019
|
return field.getFrom(this);
|
|
2370
2020
|
};
|
|
2371
|
-
|
|
2372
2021
|
_proto.year = function year() {
|
|
2373
2022
|
return this._year;
|
|
2374
2023
|
};
|
|
2375
|
-
|
|
2376
2024
|
_proto.week = function week() {
|
|
2377
2025
|
return this._week;
|
|
2378
2026
|
};
|
|
2379
|
-
|
|
2380
2027
|
_proto.is53WeekYear = function is53WeekYear() {
|
|
2381
2028
|
return YearWeek._weekRange(this._year) === 53;
|
|
2382
2029
|
};
|
|
2383
|
-
|
|
2384
2030
|
_proto.lengthOfYear = function lengthOfYear() {
|
|
2385
2031
|
return this.is53WeekYear() ? 371 : 364;
|
|
2386
2032
|
};
|
|
2387
|
-
|
|
2388
2033
|
_proto._withAdjuster = function _withAdjuster(adjuster) {
|
|
2389
2034
|
if (adjuster instanceof YearWeek) {
|
|
2390
2035
|
return adjuster;
|
|
2391
2036
|
}
|
|
2392
|
-
|
|
2393
2037
|
return _Temporal.prototype._withAdjuster.call(this, adjuster);
|
|
2394
2038
|
};
|
|
2395
|
-
|
|
2396
2039
|
_proto._withField = function _withField(field, newValue) {
|
|
2397
2040
|
if (field === IsoFields.WEEK_OF_WEEK_BASED_YEAR) {
|
|
2398
2041
|
return this.withWeek(IsoFields.WEEK_OF_WEEK_BASED_YEAR.range().checkValidIntValue(newValue, IsoFields.WEEK_OF_WEEK_BASED_YEAR));
|
|
@@ -2401,22 +2044,17 @@ var YearWeek = function (_Temporal) {
|
|
|
2401
2044
|
} else if (field instanceof ChronoField) {
|
|
2402
2045
|
throw new UnsupportedTemporalTypeException("Unsupported field: " + field);
|
|
2403
2046
|
}
|
|
2404
|
-
|
|
2405
2047
|
return field.adjustInto(this, newValue);
|
|
2406
2048
|
};
|
|
2407
|
-
|
|
2408
2049
|
_proto.withYear = function withYear(weekBasedYear) {
|
|
2409
2050
|
if (this._week === 53 && YearWeek._weekRange(weekBasedYear) < 53) {
|
|
2410
2051
|
return YearWeek.of(weekBasedYear, 52);
|
|
2411
2052
|
}
|
|
2412
|
-
|
|
2413
2053
|
return YearWeek.of(weekBasedYear, this._week);
|
|
2414
2054
|
};
|
|
2415
|
-
|
|
2416
2055
|
_proto.withWeek = function withWeek(week) {
|
|
2417
2056
|
return YearWeek.of(this._year, week);
|
|
2418
2057
|
};
|
|
2419
|
-
|
|
2420
2058
|
_proto._plusUnit = function _plusUnit(amountToAdd, unit) {
|
|
2421
2059
|
if (unit === ChronoUnit.WEEKS) {
|
|
2422
2060
|
return this.plusWeeks(amountToAdd);
|
|
@@ -2425,70 +2063,54 @@ var YearWeek = function (_Temporal) {
|
|
|
2425
2063
|
} else if (unit instanceof ChronoUnit) {
|
|
2426
2064
|
throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit);
|
|
2427
2065
|
}
|
|
2428
|
-
|
|
2429
2066
|
return unit.addTo(this, amountToAdd);
|
|
2430
2067
|
};
|
|
2431
|
-
|
|
2432
2068
|
_proto.plusYears = function plusYears(yearsToAdd) {
|
|
2433
2069
|
if (yearsToAdd === 0) {
|
|
2434
2070
|
return this;
|
|
2435
2071
|
}
|
|
2436
|
-
|
|
2437
2072
|
var newYear = MathUtil.safeToInt(MathUtil.safeAdd(this._year, yearsToAdd));
|
|
2438
2073
|
return this.withYear(newYear);
|
|
2439
2074
|
};
|
|
2440
|
-
|
|
2441
2075
|
_proto.plusWeeks = function plusWeeks(weeksToAdd) {
|
|
2442
2076
|
if (weeksToAdd === 0) {
|
|
2443
2077
|
return this;
|
|
2444
2078
|
}
|
|
2445
|
-
|
|
2446
2079
|
var mondayOfWeek = this.atDay(DayOfWeek.MONDAY).plusWeeks(weeksToAdd);
|
|
2447
2080
|
return YearWeek.from(mondayOfWeek);
|
|
2448
2081
|
};
|
|
2449
|
-
|
|
2450
2082
|
_proto._minusUnit = function _minusUnit(amountToSubtract, unit) {
|
|
2451
2083
|
requireNonNull(amountToSubtract, 'amountToSubtract');
|
|
2452
2084
|
requireNonNull(unit, 'unit');
|
|
2453
2085
|
return this._plusUnit(-amountToSubtract, unit);
|
|
2454
2086
|
};
|
|
2455
|
-
|
|
2456
2087
|
_proto.minusYears = function minusYears(yearsToSubtract) {
|
|
2457
2088
|
if (yearsToSubtract === 0) {
|
|
2458
2089
|
return this;
|
|
2459
2090
|
}
|
|
2460
|
-
|
|
2461
2091
|
var newYear = MathUtil.safeToInt(MathUtil.safeSubtract(this._year, yearsToSubtract));
|
|
2462
2092
|
return this.withYear(newYear);
|
|
2463
2093
|
};
|
|
2464
|
-
|
|
2465
2094
|
_proto.minusWeeks = function minusWeeks(weeksToSubtract) {
|
|
2466
2095
|
if (weeksToSubtract === 0) {
|
|
2467
2096
|
return this;
|
|
2468
2097
|
}
|
|
2469
|
-
|
|
2470
2098
|
var mondayOfWeek = this.atDay(DayOfWeek.MONDAY).minusWeeks(weeksToSubtract);
|
|
2471
2099
|
return YearWeek.from(mondayOfWeek);
|
|
2472
2100
|
};
|
|
2473
|
-
|
|
2474
2101
|
_proto.query = function query(_query) {
|
|
2475
2102
|
requireNonNull(_query, 'query');
|
|
2476
2103
|
requireInstance(_query, TemporalQuery, 'query');
|
|
2477
|
-
|
|
2478
2104
|
if (_query === TemporalQueries.chronology()) {
|
|
2479
2105
|
return IsoChronology.INSTANCE;
|
|
2480
2106
|
}
|
|
2481
|
-
|
|
2482
2107
|
return _Temporal.prototype.query.call(this, _query);
|
|
2483
2108
|
};
|
|
2484
|
-
|
|
2485
2109
|
_proto.adjustInto = function adjustInto(temporal) {
|
|
2486
2110
|
return temporal.with(IsoFields.WEEK_BASED_YEAR, this._year).with(IsoFields.WEEK_OF_WEEK_BASED_YEAR, this._week);
|
|
2487
2111
|
};
|
|
2488
|
-
|
|
2489
2112
|
_proto.until = function until(endExclusive, unit) {
|
|
2490
2113
|
var end = YearWeek.from(endExclusive);
|
|
2491
|
-
|
|
2492
2114
|
if (unit === ChronoUnit.WEEKS) {
|
|
2493
2115
|
return this._daysUntil(end);
|
|
2494
2116
|
} else if (unit === IsoFields.WEEK_BASED_YEARS) {
|
|
@@ -2496,46 +2118,36 @@ var YearWeek = function (_Temporal) {
|
|
|
2496
2118
|
} else if (unit instanceof ChronoUnit) {
|
|
2497
2119
|
throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit);
|
|
2498
2120
|
}
|
|
2499
|
-
|
|
2500
2121
|
return unit.between(this, end);
|
|
2501
2122
|
};
|
|
2502
|
-
|
|
2503
2123
|
_proto._daysUntil = function _daysUntil(end) {
|
|
2504
2124
|
var startDate = this.atDay(DayOfWeek.MONDAY);
|
|
2505
2125
|
var endDate = end.atDay(DayOfWeek.MONDAY);
|
|
2506
2126
|
var days = endDate.toEpochDay() - startDate.toEpochDay();
|
|
2507
2127
|
return MathUtil.intDiv(days, 7);
|
|
2508
2128
|
};
|
|
2509
|
-
|
|
2510
2129
|
_proto._yearsUntil = function _yearsUntil(end) {
|
|
2511
2130
|
var yearsDiff = end._year - this._year;
|
|
2512
|
-
|
|
2513
2131
|
if (yearsDiff > 0 && end._week < this._week) {
|
|
2514
2132
|
return yearsDiff - 1;
|
|
2515
2133
|
}
|
|
2516
|
-
|
|
2517
2134
|
if (yearsDiff < 0 && end._week > this._week) {
|
|
2518
2135
|
return yearsDiff + 1;
|
|
2519
2136
|
}
|
|
2520
|
-
|
|
2521
2137
|
return yearsDiff;
|
|
2522
2138
|
};
|
|
2523
|
-
|
|
2524
2139
|
_proto.format = function format(formatter) {
|
|
2525
2140
|
requireNonNull(formatter, 'formatter');
|
|
2526
2141
|
return formatter.format(this);
|
|
2527
2142
|
};
|
|
2528
|
-
|
|
2529
2143
|
_proto.atDay = function atDay(dayOfWeek) {
|
|
2530
2144
|
requireNonNull(dayOfWeek, 'dayOfWeek');
|
|
2531
2145
|
var correction = LocalDate.of(this._year, 1, 4).dayOfWeek().value() + 3;
|
|
2532
2146
|
var dayOfYear = this._week * 7 + dayOfWeek.value() - correction;
|
|
2533
2147
|
var maxDaysOfYear = Year.isLeap(this._year) ? 366 : 365;
|
|
2534
|
-
|
|
2535
2148
|
if (dayOfYear > maxDaysOfYear) {
|
|
2536
2149
|
return LocalDate.ofYearDay(this._year + 1, dayOfYear - maxDaysOfYear);
|
|
2537
2150
|
}
|
|
2538
|
-
|
|
2539
2151
|
if (dayOfYear > 0) {
|
|
2540
2152
|
return LocalDate.ofYearDay(this._year, dayOfYear);
|
|
2541
2153
|
} else {
|
|
@@ -2543,48 +2155,37 @@ var YearWeek = function (_Temporal) {
|
|
|
2543
2155
|
return LocalDate.ofYearDay(this._year - 1, daysOfPreviousYear + dayOfYear);
|
|
2544
2156
|
}
|
|
2545
2157
|
};
|
|
2546
|
-
|
|
2547
2158
|
_proto.compareTo = function compareTo(other) {
|
|
2548
2159
|
requireNonNull(other, 'other');
|
|
2549
2160
|
requireInstance(other, YearWeek, 'other');
|
|
2550
2161
|
var cmp = this._year - other._year;
|
|
2551
|
-
|
|
2552
2162
|
if (cmp === 0) {
|
|
2553
2163
|
cmp = this._week - other._week;
|
|
2554
2164
|
}
|
|
2555
|
-
|
|
2556
2165
|
return cmp;
|
|
2557
2166
|
};
|
|
2558
|
-
|
|
2559
2167
|
_proto.isAfter = function isAfter(other) {
|
|
2560
2168
|
return this.compareTo(other) > 0;
|
|
2561
2169
|
};
|
|
2562
|
-
|
|
2563
2170
|
_proto.isBefore = function isBefore(other) {
|
|
2564
2171
|
return this.compareTo(other) < 0;
|
|
2565
2172
|
};
|
|
2566
|
-
|
|
2567
2173
|
_proto.equals = function equals(obj) {
|
|
2568
2174
|
if (this === obj) {
|
|
2569
2175
|
return true;
|
|
2570
2176
|
}
|
|
2571
|
-
|
|
2572
2177
|
if (obj instanceof YearWeek) {
|
|
2573
2178
|
return this._year === obj._year && this._week === obj._week;
|
|
2574
2179
|
}
|
|
2575
|
-
|
|
2576
2180
|
return false;
|
|
2577
2181
|
};
|
|
2578
|
-
|
|
2579
2182
|
_proto.hashCode = function hashCode() {
|
|
2580
2183
|
return this._year ^ this._week << 25;
|
|
2581
2184
|
};
|
|
2582
|
-
|
|
2583
2185
|
_proto.toString = function toString() {
|
|
2584
2186
|
var yearString;
|
|
2585
2187
|
var yearValue = this._year;
|
|
2586
2188
|
var absYear = Math.abs(yearValue);
|
|
2587
|
-
|
|
2588
2189
|
if (absYear < 1000) {
|
|
2589
2190
|
if (yearValue < 0) {
|
|
2590
2191
|
yearString = "-" + ("" + (yearValue - 10000)).slice(-4);
|
|
@@ -2598,10 +2199,8 @@ var YearWeek = function (_Temporal) {
|
|
|
2598
2199
|
yearString = "" + yearValue;
|
|
2599
2200
|
}
|
|
2600
2201
|
}
|
|
2601
|
-
|
|
2602
2202
|
return yearString.concat(this._week < 10 ? '-W0' : '-W').concat(this._week);
|
|
2603
2203
|
};
|
|
2604
|
-
|
|
2605
2204
|
return YearWeek;
|
|
2606
2205
|
}(Temporal);
|
|
2607
2206
|
function _init() {
|
|
@@ -2610,18 +2209,14 @@ function _init() {
|
|
|
2610
2209
|
return YearWeek.from(temporal);
|
|
2611
2210
|
});
|
|
2612
2211
|
}
|
|
2613
|
-
|
|
2614
2212
|
function createTemporalQuery(name, queryFromFunction) {
|
|
2615
2213
|
var ExtendedTemporalQuery = function (_TemporalQuery) {
|
|
2616
2214
|
_inheritsLoose(ExtendedTemporalQuery, _TemporalQuery);
|
|
2617
|
-
|
|
2618
2215
|
function ExtendedTemporalQuery() {
|
|
2619
2216
|
return _TemporalQuery.apply(this, arguments) || this;
|
|
2620
2217
|
}
|
|
2621
|
-
|
|
2622
2218
|
return ExtendedTemporalQuery;
|
|
2623
2219
|
}(TemporalQuery);
|
|
2624
|
-
|
|
2625
2220
|
ExtendedTemporalQuery.prototype.queryFrom = queryFromFunction;
|
|
2626
2221
|
return new ExtendedTemporalQuery(name);
|
|
2627
2222
|
}
|
|
@@ -2631,13 +2226,12 @@ function createTemporalQuery(name, queryFromFunction) {
|
|
|
2631
2226
|
* @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
|
|
2632
2227
|
*/
|
|
2633
2228
|
var isInit = false;
|
|
2634
|
-
|
|
2635
2229
|
function init() {
|
|
2636
2230
|
if (isInit) {
|
|
2637
2231
|
return;
|
|
2638
2232
|
}
|
|
2639
|
-
|
|
2640
2233
|
isInit = true;
|
|
2234
|
+
_init$8();
|
|
2641
2235
|
_init$7();
|
|
2642
2236
|
_init$6();
|
|
2643
2237
|
_init$5();
|
|
@@ -2647,13 +2241,8 @@ function init() {
|
|
|
2647
2241
|
_init$1();
|
|
2648
2242
|
_init();
|
|
2649
2243
|
}
|
|
2650
|
-
|
|
2651
2244
|
init();
|
|
2652
2245
|
|
|
2653
|
-
/*
|
|
2654
|
-
* @copyright (c) 2016, Philipp Thuerwaechter & Pattrick Hueper
|
|
2655
|
-
* @license BSD-3-Clause (see LICENSE.md in the root directory of this source tree)
|
|
2656
|
-
*/
|
|
2657
2246
|
function plug () {}
|
|
2658
2247
|
|
|
2659
2248
|
/*
|
|
@@ -2662,5 +2251,5 @@ function plug () {}
|
|
|
2662
2251
|
*/
|
|
2663
2252
|
use(plug);
|
|
2664
2253
|
|
|
2665
|
-
export { DayOfMonth, DayOfYear, Interval, LocalDateRange, OffsetDate, Quarter, YearQuarter, YearWeek };
|
|
2254
|
+
export { DayOfMonth, DayOfYear, Interval, LocalDateRange, OffsetDate, Quarter, Temporals, YearQuarter, YearWeek };
|
|
2666
2255
|
//# sourceMappingURL=js-joda-extra.esm.js.map
|