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