@js-joda/extra 0.5.1 → 0.7.1

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.
@@ -1,4 +1,4 @@
1
- //! @version @js-joda/extra - 0.5.1
1
+ //! @version @js-joda/extra - 0.7.1
2
2
  //! @copyright (c) 2015-2016, 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)
@@ -115,12 +115,6 @@ __webpack_require__.r(__webpack_exports__);
115
115
  /* harmony import */ var _js_joda_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @js-joda/core */ "@js-joda/core");
116
116
  /* harmony import */ var _js_joda_core__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_js_joda_core__WEBPACK_IMPORTED_MODULE_0__);
117
117
  /* harmony import */ var _assert__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./assert */ "./src/assert.js");
118
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
119
-
120
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
121
-
122
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
123
-
124
118
  /*
125
119
  * @copyright (c) 2016, Philipp Thürwächter & Pattrick Hüper
126
120
  * @copyright (c) 2007-present, Stephen Colebourne & Michael Nascimento Santos
@@ -129,288 +123,257 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
129
123
 
130
124
 
131
125
  var Interval = function () {
132
- function Interval(startInclusive, endExclusive) {
133
- _classCallCheck(this, Interval);
126
+ Interval.of = function of(startInstant, endInstantOrDuration) {
127
+ if (endInstantOrDuration instanceof _js_joda_core__WEBPACK_IMPORTED_MODULE_0__["Duration"]) {
128
+ return Interval.ofInstantDuration(startInstant, endInstantOrDuration);
129
+ } else {
130
+ return Interval.ofInstantInstant(startInstant, endInstantOrDuration);
131
+ }
132
+ };
134
133
 
135
- this._start = startInclusive;
136
- this._end = endExclusive;
137
- }
134
+ Interval.ofInstantInstant = function ofInstantInstant(startInclusive, endExclusive) {
135
+ Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireNonNull"])(startInclusive, 'startInclusive');
136
+ Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireNonNull"])(endExclusive, 'endExclusive');
137
+ Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireInstance"])(startInclusive, _js_joda_core__WEBPACK_IMPORTED_MODULE_0__["Instant"], 'startInclusive');
138
+ Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireInstance"])(endExclusive, _js_joda_core__WEBPACK_IMPORTED_MODULE_0__["Instant"], 'endExclusive');
138
139
 
139
- _createClass(Interval, [{
140
- key: "start",
141
- value: function start() {
142
- return this._start;
143
- }
144
- }, {
145
- key: "end",
146
- value: function end() {
147
- return this._end;
140
+ if (endExclusive.isBefore(startInclusive)) {
141
+ throw new _js_joda_core__WEBPACK_IMPORTED_MODULE_0__["DateTimeException"]('End instant must on or after start instant');
148
142
  }
149
- }, {
150
- key: "isEmpty",
151
- value: function isEmpty() {
152
- return this._start.equals(this._end);
153
- }
154
- }, {
155
- key: "isUnboundedStart",
156
- value: function isUnboundedStart() {
157
- return this._start.equals(_js_joda_core__WEBPACK_IMPORTED_MODULE_0__["Instant"].MIN);
158
- }
159
- }, {
160
- key: "isUnboundedEnd",
161
- value: function isUnboundedEnd() {
162
- return this._end.equals(_js_joda_core__WEBPACK_IMPORTED_MODULE_0__["Instant"].MAX);
163
- }
164
- }, {
165
- key: "withStart",
166
- value: function withStart(start) {
167
- return Interval.of(start, this._end);
168
- }
169
- }, {
170
- key: "withEnd",
171
- value: function withEnd(end) {
172
- return Interval.of(this._start, end);
173
- }
174
- }, {
175
- key: "contains",
176
- value: function contains(instant) {
177
- Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireNonNull"])(instant, 'instant');
178
- Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireInstance"])(instant, _js_joda_core__WEBPACK_IMPORTED_MODULE_0__["Instant"], 'instant');
179
- return this._start.compareTo(instant) <= 0 && (instant.compareTo(this._end) < 0 || this.isUnboundedEnd());
180
- }
181
- }, {
182
- key: "encloses",
183
- value: function encloses(other) {
184
- Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireNonNull"])(other, 'other');
185
- Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireInstance"])(other, Interval, 'other');
186
- return this._start.compareTo(other.start()) <= 0 && other.end().compareTo(this._end) <= 0;
187
- }
188
- }, {
189
- key: "abuts",
190
- value: function abuts(other) {
191
- Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireNonNull"])(other, 'other');
192
- Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireInstance"])(other, Interval, 'other');
193
- return !this._end.equals(other.start()) !== !this._start.equals(other.end());
194
- }
195
- }, {
196
- key: "isConnected",
197
- value: function isConnected(other) {
198
- Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireNonNull"])(other, 'other');
199
- Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireInstance"])(other, Interval, 'other');
200
- return this.equals(other) || this._start.compareTo(other.end()) <= 0 && other.start().compareTo(this._end) <= 0;
143
+
144
+ return new Interval(startInclusive, endExclusive);
145
+ };
146
+
147
+ Interval.ofInstantDuration = function ofInstantDuration(startInclusive, duration) {
148
+ Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireNonNull"])(startInclusive, 'startInclusive');
149
+ Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireNonNull"])(duration, 'duration');
150
+ Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireInstance"])(startInclusive, _js_joda_core__WEBPACK_IMPORTED_MODULE_0__["Instant"], 'startInclusive');
151
+ Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireInstance"])(duration, _js_joda_core__WEBPACK_IMPORTED_MODULE_0__["Duration"], 'duration');
152
+
153
+ if (duration.isNegative()) {
154
+ throw new _js_joda_core__WEBPACK_IMPORTED_MODULE_0__["DateTimeException"]('Duration must not be zero or negative');
201
155
  }
202
- }, {
203
- key: "overlaps",
204
- value: function overlaps(other) {
205
- Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireNonNull"])(other, 'other');
206
- Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireInstance"])(other, Interval, 'other');
207
- return other.equals(this) || this._start.compareTo(other.end()) < 0 && other.start().compareTo(this._end) < 0;
156
+
157
+ return new Interval(startInclusive, startInclusive.plus(duration));
158
+ };
159
+
160
+ Interval.parse = function parse(text) {
161
+ Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireNonNull"])(text, 'text');
162
+
163
+ if (!(typeof text === 'string')) {
164
+ throw new _js_joda_core__WEBPACK_IMPORTED_MODULE_0__["IllegalArgumentException"]("text must be a string, but is " + text.constructor.name);
208
165
  }
209
- }, {
210
- key: "intersection",
211
- value: function intersection(other) {
212
- Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireNonNull"])(other, 'other');
213
- Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireInstance"])(other, Interval, 'other');
214
-
215
- if (this.isConnected(other) === false) {
216
- throw new _js_joda_core__WEBPACK_IMPORTED_MODULE_0__["DateTimeException"]("Intervals do not connect: ".concat(this, " and ").concat(other));
217
- }
218
166
 
219
- var cmpStart = this._start.compareTo(other.start());
167
+ for (var i = 0; i < text.length; i += 1) {
168
+ if (text.charAt(i) === '/') {
169
+ var firstChar = text.charAt(0);
170
+
171
+ if (firstChar === 'P' || firstChar === 'p') {
172
+ var duration = _js_joda_core__WEBPACK_IMPORTED_MODULE_0__["Duration"].parse(text.substring(0, i));
173
+ var end = _js_joda_core__WEBPACK_IMPORTED_MODULE_0__["ZonedDateTime"].parse(text.substring(i + 1, text.length)).toInstant();
174
+ return Interval.of(end.minus(duration), end);
175
+ } else {
176
+ var start = _js_joda_core__WEBPACK_IMPORTED_MODULE_0__["ZonedDateTime"].parse(text.substring(0, i)).toInstant();
177
+
178
+ if (i + 1 < text.length) {
179
+ var c = text.charAt(i + 1);
180
+
181
+ if (c === 'P' || c === 'p') {
182
+ var _duration = _js_joda_core__WEBPACK_IMPORTED_MODULE_0__["Duration"].parse(text.substring(i + 1, text.length));
183
+
184
+ return Interval.of(start, start.plus(_duration));
185
+ }
186
+ }
220
187
 
221
- var cmpEnd = this._end.compareTo(other.end());
188
+ var _end = _js_joda_core__WEBPACK_IMPORTED_MODULE_0__["ZonedDateTime"].parse(text.substring(i + 1, text.length)).toInstant();
222
189
 
223
- if (cmpStart >= 0 && cmpEnd <= 0) {
224
- return this;
225
- } else if (cmpStart <= 0 && cmpEnd >= 0) {
226
- return other;
227
- } else {
228
- var newStart = cmpStart >= 0 ? this._start : other.start();
229
- var newEnd = cmpEnd <= 0 ? this._end : other.end();
230
- return Interval.of(newStart, newEnd);
190
+ return Interval.of(start, _end);
191
+ }
231
192
  }
232
193
  }
233
- }, {
234
- key: "union",
235
- value: function union(other) {
236
- Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireNonNull"])(other, 'other');
237
- Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireInstance"])(other, Interval, 'other');
238
-
239
- if (this.isConnected(other) === false) {
240
- throw new _js_joda_core__WEBPACK_IMPORTED_MODULE_0__["DateTimeException"]("Intervals do not connect: ".concat(this, " and ").concat(other));
241
- }
242
194
 
243
- var cmpStart = this._start.compareTo(other.start());
195
+ throw new _js_joda_core__WEBPACK_IMPORTED_MODULE_0__["DateTimeParseException"]('Interval cannot be parsed, no forward slash found', text, 0);
196
+ };
244
197
 
245
- var cmpEnd = this._end.compareTo(other.end());
198
+ function Interval(startInclusive, endExclusive) {
199
+ this._start = startInclusive;
200
+ this._end = endExclusive;
201
+ }
246
202
 
247
- if (cmpStart >= 0 && cmpEnd <= 0) {
248
- return other;
249
- } else if (cmpStart <= 0 && cmpEnd >= 0) {
250
- return this;
251
- } else {
252
- var newStart = cmpStart >= 0 ? other.start() : this._start;
253
- var newEnd = cmpEnd <= 0 ? other.end() : this._end;
254
- return Interval.of(newStart, newEnd);
255
- }
203
+ var _proto = Interval.prototype;
204
+
205
+ _proto.start = function start() {
206
+ return this._start;
207
+ };
208
+
209
+ _proto.end = function end() {
210
+ return this._end;
211
+ };
212
+
213
+ _proto.isEmpty = function isEmpty() {
214
+ return this._start.equals(this._end);
215
+ };
216
+
217
+ _proto.isUnboundedStart = function isUnboundedStart() {
218
+ return this._start.equals(_js_joda_core__WEBPACK_IMPORTED_MODULE_0__["Instant"].MIN);
219
+ };
220
+
221
+ _proto.isUnboundedEnd = function isUnboundedEnd() {
222
+ return this._end.equals(_js_joda_core__WEBPACK_IMPORTED_MODULE_0__["Instant"].MAX);
223
+ };
224
+
225
+ _proto.withStart = function withStart(start) {
226
+ return Interval.of(start, this._end);
227
+ };
228
+
229
+ _proto.withEnd = function withEnd(end) {
230
+ return Interval.of(this._start, end);
231
+ };
232
+
233
+ _proto.contains = function contains(instant) {
234
+ Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireNonNull"])(instant, 'instant');
235
+ Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireInstance"])(instant, _js_joda_core__WEBPACK_IMPORTED_MODULE_0__["Instant"], 'instant');
236
+ return this._start.compareTo(instant) <= 0 && (instant.compareTo(this._end) < 0 || this.isUnboundedEnd());
237
+ };
238
+
239
+ _proto.encloses = function encloses(other) {
240
+ Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireNonNull"])(other, 'other');
241
+ Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireInstance"])(other, Interval, 'other');
242
+ return this._start.compareTo(other.start()) <= 0 && other.end().compareTo(this._end) <= 0;
243
+ };
244
+
245
+ _proto.abuts = function abuts(other) {
246
+ Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireNonNull"])(other, 'other');
247
+ Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireInstance"])(other, Interval, 'other');
248
+ return !this._end.equals(other.start()) !== !this._start.equals(other.end());
249
+ };
250
+
251
+ _proto.isConnected = function isConnected(other) {
252
+ Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireNonNull"])(other, 'other');
253
+ Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireInstance"])(other, Interval, 'other');
254
+ return this.equals(other) || this._start.compareTo(other.end()) <= 0 && other.start().compareTo(this._end) <= 0;
255
+ };
256
+
257
+ _proto.overlaps = function overlaps(other) {
258
+ Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireNonNull"])(other, 'other');
259
+ Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireInstance"])(other, Interval, 'other');
260
+ return other.equals(this) || this._start.compareTo(other.end()) < 0 && other.start().compareTo(this._end) < 0;
261
+ };
262
+
263
+ _proto.intersection = function intersection(other) {
264
+ Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireNonNull"])(other, 'other');
265
+ Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireInstance"])(other, Interval, 'other');
266
+
267
+ if (this.isConnected(other) === false) {
268
+ throw new _js_joda_core__WEBPACK_IMPORTED_MODULE_0__["DateTimeException"]("Intervals do not connect: " + this + " and " + other);
256
269
  }
257
- }, {
258
- key: "span",
259
- value: function span(other) {
260
- Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireNonNull"])(other, 'other');
261
- Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireInstance"])(other, Interval, 'other');
262
270
 
263
- var cmpStart = this._start.compareTo(other.start());
271
+ var cmpStart = this._start.compareTo(other.start());
264
272
 
265
- var cmpEnd = this._end.compareTo(other.end());
273
+ var cmpEnd = this._end.compareTo(other.end());
266
274
 
267
- var newStart = cmpStart >= 0 ? other.start() : this._start;
268
- var newEnd = cmpEnd <= 0 ? other.end() : this._end;
275
+ if (cmpStart >= 0 && cmpEnd <= 0) {
276
+ return this;
277
+ } else if (cmpStart <= 0 && cmpEnd >= 0) {
278
+ return other;
279
+ } else {
280
+ var newStart = cmpStart >= 0 ? this._start : other.start();
281
+ var newEnd = cmpEnd <= 0 ? this._end : other.end();
269
282
  return Interval.of(newStart, newEnd);
270
283
  }
271
- }, {
272
- key: "isAfter",
273
- value: function isAfter(instantOrInterval) {
274
- if (instantOrInterval instanceof _js_joda_core__WEBPACK_IMPORTED_MODULE_0__["Instant"]) {
275
- return this.isAfterInstant(instantOrInterval);
276
- } else {
277
- return this.isAfterInterval(instantOrInterval);
278
- }
279
- }
280
- }, {
281
- key: "isBefore",
282
- value: function isBefore(instantOrInterval) {
283
- if (instantOrInterval instanceof _js_joda_core__WEBPACK_IMPORTED_MODULE_0__["Instant"]) {
284
- return this.isBeforeInstant(instantOrInterval);
285
- } else {
286
- return this.isBeforeInterval(instantOrInterval);
287
- }
288
- }
289
- }, {
290
- key: "isAfterInstant",
291
- value: function isAfterInstant(instant) {
292
- return this._start.compareTo(instant) > 0;
293
- }
294
- }, {
295
- key: "isBeforeInstant",
296
- value: function isBeforeInstant(instant) {
297
- return this._end.compareTo(instant) <= 0 && this._start.compareTo(instant) < 0;
298
- }
299
- }, {
300
- key: "isAfterInterval",
301
- value: function isAfterInterval(interval) {
302
- return this._start.compareTo(interval.end()) >= 0 && !interval.equals(this);
303
- }
304
- }, {
305
- key: "isBeforeInterval",
306
- value: function isBeforeInterval(interval) {
307
- return this._end.compareTo(interval.start()) <= 0 && !interval.equals(this);
308
- }
309
- }, {
310
- key: "toDuration",
311
- value: function toDuration() {
312
- return _js_joda_core__WEBPACK_IMPORTED_MODULE_0__["Duration"].between(this._start, this._end);
313
- }
314
- }, {
315
- key: "equals",
316
- value: function equals(obj) {
317
- if (this === obj) {
318
- return true;
319
- }
284
+ };
320
285
 
321
- if (obj instanceof Interval) {
322
- return this._start.equals(obj.start()) && this._end.equals(obj.end());
323
- }
286
+ _proto.union = function union(other) {
287
+ Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireNonNull"])(other, 'other');
288
+ Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireInstance"])(other, Interval, 'other');
324
289
 
325
- return false;
326
- }
327
- }, {
328
- key: "hashCode",
329
- value: function hashCode() {
330
- return this._start.hashCode() ^ this._end.hashCode();
290
+ if (this.isConnected(other) === false) {
291
+ throw new _js_joda_core__WEBPACK_IMPORTED_MODULE_0__["DateTimeException"]("Intervals do not connect: " + this + " and " + other);
331
292
  }
332
- }, {
333
- key: "toString",
334
- value: function toString() {
335
- return "".concat(this._start.toString(), "/").concat(this._end.toString());
336
- }
337
- }], [{
338
- key: "of",
339
- value: function of(startInstant, endInstantOrDuration) {
340
- if (endInstantOrDuration instanceof _js_joda_core__WEBPACK_IMPORTED_MODULE_0__["Duration"]) {
341
- return Interval.ofInstantDuration(startInstant, endInstantOrDuration);
342
- } else {
343
- return Interval.ofInstantInstant(startInstant, endInstantOrDuration);
344
- }
293
+
294
+ var cmpStart = this._start.compareTo(other.start());
295
+
296
+ var cmpEnd = this._end.compareTo(other.end());
297
+
298
+ if (cmpStart >= 0 && cmpEnd <= 0) {
299
+ return other;
300
+ } else if (cmpStart <= 0 && cmpEnd >= 0) {
301
+ return this;
302
+ } else {
303
+ var newStart = cmpStart >= 0 ? other.start() : this._start;
304
+ var newEnd = cmpEnd <= 0 ? other.end() : this._end;
305
+ return Interval.of(newStart, newEnd);
345
306
  }
346
- }, {
347
- key: "ofInstantInstant",
348
- value: function ofInstantInstant(startInclusive, endExclusive) {
349
- Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireNonNull"])(startInclusive, 'startInclusive');
350
- Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireNonNull"])(endExclusive, 'endExclusive');
351
- Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireInstance"])(startInclusive, _js_joda_core__WEBPACK_IMPORTED_MODULE_0__["Instant"], 'startInclusive');
352
- Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireInstance"])(endExclusive, _js_joda_core__WEBPACK_IMPORTED_MODULE_0__["Instant"], 'endExclusive');
353
-
354
- if (endExclusive.isBefore(startInclusive)) {
355
- throw new _js_joda_core__WEBPACK_IMPORTED_MODULE_0__["DateTimeException"]('End instant must on or after start instant');
356
- }
307
+ };
308
+
309
+ _proto.span = function span(other) {
310
+ Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireNonNull"])(other, 'other');
311
+ Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireInstance"])(other, Interval, 'other');
312
+
313
+ var cmpStart = this._start.compareTo(other.start());
357
314
 
358
- return new Interval(startInclusive, endExclusive);
315
+ var cmpEnd = this._end.compareTo(other.end());
316
+
317
+ var newStart = cmpStart >= 0 ? other.start() : this._start;
318
+ var newEnd = cmpEnd <= 0 ? other.end() : this._end;
319
+ return Interval.of(newStart, newEnd);
320
+ };
321
+
322
+ _proto.isAfter = function isAfter(instantOrInterval) {
323
+ if (instantOrInterval instanceof _js_joda_core__WEBPACK_IMPORTED_MODULE_0__["Instant"]) {
324
+ return this.isAfterInstant(instantOrInterval);
325
+ } else {
326
+ return this.isAfterInterval(instantOrInterval);
359
327
  }
360
- }, {
361
- key: "ofInstantDuration",
362
- value: function ofInstantDuration(startInclusive, duration) {
363
- Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireNonNull"])(startInclusive, 'startInclusive');
364
- Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireNonNull"])(duration, 'duration');
365
- Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireInstance"])(startInclusive, _js_joda_core__WEBPACK_IMPORTED_MODULE_0__["Instant"], 'startInclusive');
366
- Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireInstance"])(duration, _js_joda_core__WEBPACK_IMPORTED_MODULE_0__["Duration"], 'duration');
367
-
368
- if (duration.isNegative()) {
369
- throw new _js_joda_core__WEBPACK_IMPORTED_MODULE_0__["DateTimeException"]('Duration must not be zero or negative');
370
- }
328
+ };
371
329
 
372
- return new Interval(startInclusive, startInclusive.plus(duration));
330
+ _proto.isBefore = function isBefore(instantOrInterval) {
331
+ if (instantOrInterval instanceof _js_joda_core__WEBPACK_IMPORTED_MODULE_0__["Instant"]) {
332
+ return this.isBeforeInstant(instantOrInterval);
333
+ } else {
334
+ return this.isBeforeInterval(instantOrInterval);
373
335
  }
374
- }, {
375
- key: "parse",
376
- value: function parse(text) {
377
- Object(_assert__WEBPACK_IMPORTED_MODULE_1__["requireNonNull"])(text, 'text');
336
+ };
378
337
 
379
- if (!(typeof text === 'string')) {
380
- throw new _js_joda_core__WEBPACK_IMPORTED_MODULE_0__["IllegalArgumentException"]("text must be a string, but is ".concat(text.constructor.name));
381
- }
338
+ _proto.isAfterInstant = function isAfterInstant(instant) {
339
+ return this._start.compareTo(instant) > 0;
340
+ };
382
341
 
383
- for (var i = 0; i < text.length; i += 1) {
384
- if (text.charAt(i) === '/') {
385
- var firstChar = text.charAt(0);
342
+ _proto.isBeforeInstant = function isBeforeInstant(instant) {
343
+ return this._end.compareTo(instant) <= 0 && this._start.compareTo(instant) < 0;
344
+ };
386
345
 
387
- if (firstChar === 'P' || firstChar === 'p') {
388
- var duration = _js_joda_core__WEBPACK_IMPORTED_MODULE_0__["Duration"].parse(text.substring(0, i));
389
- var end = _js_joda_core__WEBPACK_IMPORTED_MODULE_0__["ZonedDateTime"].parse(text.substring(i + 1, text.length)).toInstant();
390
- return Interval.of(end.minus(duration), end);
391
- } else {
392
- var start = _js_joda_core__WEBPACK_IMPORTED_MODULE_0__["ZonedDateTime"].parse(text.substring(0, i)).toInstant();
346
+ _proto.isAfterInterval = function isAfterInterval(interval) {
347
+ return this._start.compareTo(interval.end()) >= 0 && !interval.equals(this);
348
+ };
393
349
 
394
- if (i + 1 < text.length) {
395
- var c = text.charAt(i + 1);
350
+ _proto.isBeforeInterval = function isBeforeInterval(interval) {
351
+ return this._end.compareTo(interval.start()) <= 0 && !interval.equals(this);
352
+ };
396
353
 
397
- if (c === 'P' || c === 'p') {
398
- var _duration = _js_joda_core__WEBPACK_IMPORTED_MODULE_0__["Duration"].parse(text.substring(i + 1, text.length));
354
+ _proto.toDuration = function toDuration() {
355
+ return _js_joda_core__WEBPACK_IMPORTED_MODULE_0__["Duration"].between(this._start, this._end);
356
+ };
399
357
 
400
- return Interval.of(start, start.plus(_duration));
401
- }
402
- }
358
+ _proto.equals = function equals(obj) {
359
+ if (this === obj) {
360
+ return true;
361
+ }
403
362
 
404
- var _end = _js_joda_core__WEBPACK_IMPORTED_MODULE_0__["ZonedDateTime"].parse(text.substring(i + 1, text.length)).toInstant();
363
+ if (obj instanceof Interval) {
364
+ return this._start.equals(obj.start()) && this._end.equals(obj.end());
365
+ }
405
366
 
406
- return Interval.of(start, _end);
407
- }
408
- }
409
- }
367
+ return false;
368
+ };
410
369
 
411
- throw new _js_joda_core__WEBPACK_IMPORTED_MODULE_0__["DateTimeParseException"]('Interval cannot be parsed, no forward slash found', text, 0);
412
- }
413
- }]);
370
+ _proto.hashCode = function hashCode() {
371
+ return this._start.hashCode() ^ this._end.hashCode();
372
+ };
373
+
374
+ _proto.toString = function toString() {
375
+ return this._start.toString() + "/" + this._end.toString();
376
+ };
414
377
 
415
378
  return Interval;
416
379
  }();
@@ -481,20 +444,20 @@ function assert(assertion, msg, error) {
481
444
  }
482
445
  function requireNonNull(value, parameterName) {
483
446
  if (value == null) {
484
- throw new _js_joda_core__WEBPACK_IMPORTED_MODULE_0__["NullPointerException"]("".concat(parameterName, " must not be null"));
447
+ throw new _js_joda_core__WEBPACK_IMPORTED_MODULE_0__["NullPointerException"](parameterName + " must not be null");
485
448
  }
486
449
 
487
450
  return value;
488
451
  }
489
452
  function requireInstance(value, _class, parameterName) {
490
453
  if (!(value instanceof _class)) {
491
- throw new _js_joda_core__WEBPACK_IMPORTED_MODULE_0__["IllegalArgumentException"]("".concat(parameterName, " must be an instance of ").concat(_class.name ? _class.name : _class).concat(value && value.constructor && value.constructor.name ? ", but is ".concat(value.constructor.name) : ''));
454
+ throw new _js_joda_core__WEBPACK_IMPORTED_MODULE_0__["IllegalArgumentException"](parameterName + " must be an instance of " + (_class.name ? _class.name : _class) + (value && value.constructor && value.constructor.name ? ", but is " + value.constructor.name : ''));
492
455
  }
493
456
 
494
457
  return value;
495
458
  }
496
459
  function abstractMethodFail(methodName) {
497
- throw new TypeError("abstract method \"".concat(methodName, "\" is not implemented"));
460
+ throw new TypeError("abstract method \"" + methodName + "\" is not implemented");
498
461
  }
499
462
 
500
463
  /***/ }),