@js-joda/extra 0.13.0 → 0.13.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,11 +4,9 @@
4
4
 
5
5
  [![npm version](https://badge.fury.io/js/%40js-joda%2Fextra.svg)](https://badge.fury.io/js/%40js-joda%2Fextra)
6
6
  [![GH Actions Build Status](https://github.com/js-joda/js-joda/actions/workflows/tests.yaml/badge.svg?branch=main)](https://github.com/js-joda/js-joda/actions)
7
- [![Sauce Test Status](https://saucelabs.com/buildstatus/js-joda)](https://saucelabs.com/u/js-joda)
8
7
  [![Coverage Status](https://coveralls.io/repos/js-joda/js-joda/badge.svg?branch=main&service=github)](https://coveralls.io/github/js-joda/js-joda?branch=main)
9
8
  [![Downloads/Month](https://img.shields.io/npm/dm/%40js-joda%2Fextra.svg)](https://img.shields.io/npm/dm/%40js-joda%2Fextra.svg)
10
9
 
11
- [![Sauce Browser Matrix](https://saucelabs.com/browser-matrix/js-joda.svg?branch=main&42)](https://saucelabs.com/u/js-joda)
12
10
 
13
11
  Attempt to port https://github.com/ThreeTen/threeten-extra to https://github.com/js-joda/js-joda as a js-joda plugin.
14
12
 
@@ -1,21 +1,17 @@
1
- //! @version @js-joda/extra - 0.13.0
1
+ //! @version @js-joda/extra - 0.13.2
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
6
  import { NullPointerException, IllegalArgumentException, _, ChronoField, UnsupportedTemporalTypeException, TemporalQueries, IsoChronology, Month, MonthDay, TemporalAccessor, ZoneId, Clock, LocalDate, DateTimeException, TemporalQuery, Year, Duration, Instant, ZonedDateTime, DateTimeParseException, Period, ArithmeticException, TemporalField, TemporalUnit, ChronoUnit, ZoneOffset, OffsetDateTime, Temporal, DateTimeFormatter, IsoFields, IllegalStateException, ParsePosition, TemporalAdjuster, ValueRange, DateTimeFormatterBuilder, SignStyle, DayOfWeek, use } from '@js-joda/core';
7
7
 
8
- function _inheritsLoose(subClass, superClass) {
9
- subClass.prototype = Object.create(superClass.prototype);
10
- subClass.prototype.constructor = subClass;
11
- _setPrototypeOf(subClass, superClass);
8
+ function _inheritsLoose(t, o) {
9
+ t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o);
12
10
  }
13
- function _setPrototypeOf(o, p) {
14
- _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
15
- o.__proto__ = p;
16
- return o;
17
- };
18
- return _setPrototypeOf(o, p);
11
+ function _setPrototypeOf(t, e) {
12
+ return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
13
+ return t.__proto__ = e, t;
14
+ }, _setPrototypeOf(t, e);
19
15
  }
20
16
 
21
17
  /**
@@ -46,6 +42,12 @@ function requireInstance(value, _class, parameterName) {
46
42
 
47
43
  var MathUtil$6 = _.MathUtil;
48
44
  var DayOfMonth = function (_TemporalAccessor) {
45
+ function DayOfMonth(dayOfMonth) {
46
+ var _this;
47
+ _this = _TemporalAccessor.call(this) || this;
48
+ _this._day = MathUtil$6.safeToInt(dayOfMonth);
49
+ return _this;
50
+ }
49
51
  _inheritsLoose(DayOfMonth, _TemporalAccessor);
50
52
  DayOfMonth.now = function now(zoneIdOrClock) {
51
53
  switch (arguments.length) {
@@ -92,12 +94,6 @@ var DayOfMonth = function (_TemporalAccessor) {
92
94
  throw new DateTimeException("Unable to obtain DayOfMonth from TemporalAccessor: " + temporal + " of type " + temporal.constructor.name, ex);
93
95
  }
94
96
  };
95
- function DayOfMonth(dayOfMonth) {
96
- var _this;
97
- _this = _TemporalAccessor.call(this) || this;
98
- _this._day = MathUtil$6.safeToInt(dayOfMonth);
99
- return _this;
100
- }
101
97
  var _proto = DayOfMonth.prototype;
102
98
  _proto.value = function value() {
103
99
  return this._day;
@@ -185,6 +181,12 @@ function _init$8() {
185
181
 
186
182
  var MathUtil$5 = _.MathUtil;
187
183
  var DayOfYear = function (_TemporalAccessor) {
184
+ function DayOfYear(dayOfYear) {
185
+ var _this;
186
+ _this = _TemporalAccessor.call(this) || this;
187
+ _this._day = MathUtil$5.safeToInt(dayOfYear);
188
+ return _this;
189
+ }
188
190
  _inheritsLoose(DayOfYear, _TemporalAccessor);
189
191
  DayOfYear.now = function now(zoneIdOrClock) {
190
192
  switch (arguments.length) {
@@ -232,12 +234,6 @@ var DayOfYear = function (_TemporalAccessor) {
232
234
  throw new DateTimeException("Unable to obtain DayOfYear from TemporalAccessor: " + temporal + " of type " + temporal.constructor.name, ex);
233
235
  }
234
236
  };
235
- function DayOfYear(dayOfYear) {
236
- var _this;
237
- _this = _TemporalAccessor.call(this) || this;
238
- _this._day = MathUtil$5.safeToInt(dayOfYear);
239
- return _this;
240
- }
241
237
  var _proto = DayOfYear.prototype;
242
238
  _proto.value = function value() {
243
239
  return this._day;
@@ -326,6 +322,10 @@ function _init$7() {
326
322
  */
327
323
 
328
324
  var Interval = function () {
325
+ function Interval(startInclusive, endExclusive) {
326
+ this._start = startInclusive;
327
+ this._end = endExclusive;
328
+ }
329
329
  Interval.of = function of(startInstant, endInstantOrDuration) {
330
330
  if (endInstantOrDuration instanceof Duration) {
331
331
  return Interval.ofInstantDuration(startInstant, endInstantOrDuration);
@@ -381,10 +381,6 @@ var Interval = function () {
381
381
  }
382
382
  throw new DateTimeParseException('Interval cannot be parsed, no forward slash found', text, 0);
383
383
  };
384
- function Interval(startInclusive, endExclusive) {
385
- this._start = startInclusive;
386
- this._end = endExclusive;
387
- }
388
384
  var _proto = Interval.prototype;
389
385
  _proto.start = function start() {
390
386
  return this._start;
@@ -536,6 +532,26 @@ function _init$6() {
536
532
  var MINP1 = LocalDate.MIN.plusDays(1);
537
533
  var MAXM1 = LocalDate.MAX.minusDays(1);
538
534
  var LocalDateRange = function () {
535
+ function LocalDateRange(startInclusive, endExclusive) {
536
+ requireNonNull(startInclusive, 'startInclusive');
537
+ requireNonNull(endExclusive, 'endExclusive');
538
+ requireInstance(startInclusive, LocalDate, 'startInclusive');
539
+ requireInstance(endExclusive, LocalDate, 'endExclusive');
540
+ if (endExclusive.isBefore(startInclusive)) {
541
+ throw new DateTimeException('End date must be on or after start date');
542
+ }
543
+ if (startInclusive.equals(MAXM1)) {
544
+ throw new DateTimeException('Range must not start at LocalDate.MAX.minusDays(1)');
545
+ }
546
+ if (endExclusive.equals(MINP1)) {
547
+ throw new DateTimeException('Range must not end at LocalDate.MIN.plusDays(1)');
548
+ }
549
+ if (endExclusive.equals(LocalDate.MIN) || startInclusive.equals(LocalDate.MAX)) {
550
+ throw new DateTimeException('Empty range must not be at LocalDate.MIN or LocalDate.MAX');
551
+ }
552
+ this._start = startInclusive;
553
+ this._end = endExclusive;
554
+ }
539
555
  LocalDateRange.of = function of(startInclusive, endExclusiveOrPeriod) {
540
556
  if (startInclusive instanceof LocalDate && endExclusiveOrPeriod instanceof LocalDate) {
541
557
  return LocalDateRange._ofLocalDateLocalDate(startInclusive, endExclusiveOrPeriod);
@@ -621,26 +637,6 @@ var LocalDateRange = function () {
621
637
  }
622
638
  throw new DateTimeParseException('LocalDateRange cannot be parsed, no forward slash found', text, 0);
623
639
  };
624
- function LocalDateRange(startInclusive, endExclusive) {
625
- requireNonNull(startInclusive, 'startInclusive');
626
- requireNonNull(endExclusive, 'endExclusive');
627
- requireInstance(startInclusive, LocalDate, 'startInclusive');
628
- requireInstance(endExclusive, LocalDate, 'endExclusive');
629
- if (endExclusive.isBefore(startInclusive)) {
630
- throw new DateTimeException('End date must be on or after start date');
631
- }
632
- if (startInclusive.equals(MAXM1)) {
633
- throw new DateTimeException('Range must not start at LocalDate.MAX.minusDays(1)');
634
- }
635
- if (endExclusive.equals(MINP1)) {
636
- throw new DateTimeException('Range must not end at LocalDate.MIN.plusDays(1)');
637
- }
638
- if (endExclusive.equals(LocalDate.MIN) || startInclusive.equals(LocalDate.MAX)) {
639
- throw new DateTimeException('Empty range must not be at LocalDate.MIN or LocalDate.MAX');
640
- }
641
- this._start = startInclusive;
642
- this._end = endExclusive;
643
- }
644
640
  var _proto = LocalDateRange.prototype;
645
641
  _proto.start = function start() {
646
642
  return this._start;
@@ -798,6 +794,13 @@ function _init$5() {
798
794
  var MathUtil$4 = _.MathUtil;
799
795
  var SECONDS_PER_DAY = 86400;
800
796
  var OffsetDate = function (_Temporal) {
797
+ function OffsetDate(date, offset) {
798
+ var _this;
799
+ _this = _Temporal.call(this) || this;
800
+ _this._date = requireNonNull(date, 'date');
801
+ _this._offset = requireNonNull(offset, 'offset');
802
+ return _this;
803
+ }
801
804
  _inheritsLoose(OffsetDate, _Temporal);
802
805
  OffsetDate.now = function now(zoneIdOrClock) {
803
806
  if (arguments.length === 0) {
@@ -866,13 +869,6 @@ var OffsetDate = function (_Temporal) {
866
869
  requireNonNull(formatter, 'formatter');
867
870
  return formatter.parse(text, OffsetDate.FROM);
868
871
  };
869
- function OffsetDate(date, offset) {
870
- var _this;
871
- _this = _Temporal.call(this) || this;
872
- _this._date = requireNonNull(date, 'date');
873
- _this._offset = requireNonNull(offset, 'offset');
874
- return _this;
875
- }
876
872
  var _proto = OffsetDate.prototype;
877
873
  _proto._with = function _with(date, offset) {
878
874
  if (this._date === date && this._offset.equals(offset)) {
@@ -1117,10 +1113,10 @@ function _init$4() {
1117
1113
  }
1118
1114
  function createTemporalQuery$3(name, queryFromFunction) {
1119
1115
  var ExtendedTemporalQuery = function (_TemporalQuery) {
1120
- _inheritsLoose(ExtendedTemporalQuery, _TemporalQuery);
1121
1116
  function ExtendedTemporalQuery() {
1122
1117
  return _TemporalQuery.apply(this, arguments) || this;
1123
1118
  }
1119
+ _inheritsLoose(ExtendedTemporalQuery, _TemporalQuery);
1124
1120
  return ExtendedTemporalQuery;
1125
1121
  }(TemporalQuery);
1126
1122
  ExtendedTemporalQuery.prototype.queryFrom = queryFromFunction;
@@ -1129,6 +1125,13 @@ function createTemporalQuery$3(name, queryFromFunction) {
1129
1125
 
1130
1126
  var MathUtil$3 = _.MathUtil;
1131
1127
  var Quarter = function (_TemporalAccessor) {
1128
+ function Quarter(value, name) {
1129
+ var _this;
1130
+ _this = _TemporalAccessor.call(this) || this;
1131
+ _this._value = MathUtil$3.safeToInt(value);
1132
+ _this._name = name;
1133
+ return _this;
1134
+ }
1132
1135
  _inheritsLoose(Quarter, _TemporalAccessor);
1133
1136
  Quarter.valueOf = function valueOf(name) {
1134
1137
  requireNonNull(name, 'name');
@@ -1181,13 +1184,6 @@ var Quarter = function (_TemporalAccessor) {
1181
1184
  throw new DateTimeException("Unable to obtain Quarter from TemporalAccessor: '" + temporal + "' of type '" + (temporal && temporal.constructor.name) + "'", ex);
1182
1185
  }
1183
1186
  };
1184
- function Quarter(value, name) {
1185
- var _this;
1186
- _this = _TemporalAccessor.call(this) || this;
1187
- _this._value = MathUtil$3.safeToInt(value);
1188
- _this._name = name;
1189
- return _this;
1190
- }
1191
1187
  var _proto = Quarter.prototype;
1192
1188
  _proto.value = function value() {
1193
1189
  return this._value;
@@ -1306,10 +1302,10 @@ function _init$3() {
1306
1302
  }
1307
1303
  function createTemporalQuery$2(name, queryFromFunction) {
1308
1304
  var ExtendedTemporalQuery = function (_TemporalQuery) {
1309
- _inheritsLoose(ExtendedTemporalQuery, _TemporalQuery);
1310
1305
  function ExtendedTemporalQuery() {
1311
1306
  return _TemporalQuery.apply(this, arguments) || this;
1312
1307
  }
1308
+ _inheritsLoose(ExtendedTemporalQuery, _TemporalQuery);
1313
1309
  return ExtendedTemporalQuery;
1314
1310
  }(TemporalQuery);
1315
1311
  ExtendedTemporalQuery.prototype.queryFrom = queryFromFunction;
@@ -1318,6 +1314,7 @@ function createTemporalQuery$2(name, queryFromFunction) {
1318
1314
 
1319
1315
  var MathUtil$2 = _.MathUtil;
1320
1316
  var Temporals = function () {
1317
+ function Temporals() {}
1321
1318
  Temporals.nextWorkingDay = function nextWorkingDay() {
1322
1319
  return Adjuster.NEXT_WORKING;
1323
1320
  };
@@ -1416,16 +1413,15 @@ var Temporals = function () {
1416
1413
  }
1417
1414
  return 3;
1418
1415
  };
1419
- function Temporals() {}
1420
1416
  return Temporals;
1421
1417
  }();
1422
1418
  var Adjuster = {};
1423
1419
  function _init$2() {
1424
1420
  Adjuster.NEXT_WORKING = new (function (_TemporalAdjuster) {
1425
- _inheritsLoose(_class, _TemporalAdjuster);
1426
1421
  function _class() {
1427
1422
  return _TemporalAdjuster.apply(this, arguments) || this;
1428
1423
  }
1424
+ _inheritsLoose(_class, _TemporalAdjuster);
1429
1425
  var _proto = _class.prototype;
1430
1426
  _proto.adjustInto = function adjustInto(temporal) {
1431
1427
  var dow = temporal.get(ChronoField.DAY_OF_WEEK);
@@ -1441,10 +1437,10 @@ function _init$2() {
1441
1437
  return _class;
1442
1438
  }(TemporalAdjuster))();
1443
1439
  Adjuster.PREVIOUS_WORKING = new (function (_TemporalAdjuster2) {
1444
- _inheritsLoose(_class2, _TemporalAdjuster2);
1445
1440
  function _class2() {
1446
1441
  return _TemporalAdjuster2.apply(this, arguments) || this;
1447
1442
  }
1443
+ _inheritsLoose(_class2, _TemporalAdjuster2);
1448
1444
  var _proto2 = _class2.prototype;
1449
1445
  _proto2.adjustInto = function adjustInto(temporal) {
1450
1446
  var dow = temporal.get(ChronoField.DAY_OF_WEEK);
@@ -1460,10 +1456,10 @@ function _init$2() {
1460
1456
  return _class2;
1461
1457
  }(TemporalAdjuster))();
1462
1458
  Adjuster.NEXT_WORKING_OR_SAME = new (function (_TemporalAdjuster3) {
1463
- _inheritsLoose(_class3, _TemporalAdjuster3);
1464
1459
  function _class3() {
1465
1460
  return _TemporalAdjuster3.apply(this, arguments) || this;
1466
1461
  }
1462
+ _inheritsLoose(_class3, _TemporalAdjuster3);
1467
1463
  var _proto3 = _class3.prototype;
1468
1464
  _proto3.adjustInto = function adjustInto(temporal) {
1469
1465
  var dow = temporal.get(ChronoField.DAY_OF_WEEK);
@@ -1479,10 +1475,10 @@ function _init$2() {
1479
1475
  return _class3;
1480
1476
  }(TemporalAdjuster))();
1481
1477
  Adjuster.PREVIOUS_WORKING_OR_SAME = new (function (_TemporalAdjuster4) {
1482
- _inheritsLoose(_class4, _TemporalAdjuster4);
1483
1478
  function _class4() {
1484
1479
  return _TemporalAdjuster4.apply(this, arguments) || this;
1485
1480
  }
1481
+ _inheritsLoose(_class4, _TemporalAdjuster4);
1486
1482
  var _proto4 = _class4.prototype;
1487
1483
  _proto4.adjustInto = function adjustInto(temporal) {
1488
1484
  var dow = temporal.get(ChronoField.DAY_OF_WEEK);
@@ -1501,6 +1497,13 @@ function _init$2() {
1501
1497
 
1502
1498
  var MathUtil$1 = _.MathUtil;
1503
1499
  var YearQuarter = function (_Temporal) {
1500
+ function YearQuarter(year, quarter) {
1501
+ var _this;
1502
+ _this = _Temporal.call(this) || this;
1503
+ _this._year = MathUtil$1.safeToInt(year);
1504
+ _this._quarter = requireInstance(quarter, Quarter, 'Quarter');
1505
+ return _this;
1506
+ }
1504
1507
  _inheritsLoose(YearQuarter, _Temporal);
1505
1508
  YearQuarter.now = function now(zoneIdOrClock) {
1506
1509
  if (arguments.length === 0) {
@@ -1574,13 +1577,6 @@ var YearQuarter = function (_Temporal) {
1574
1577
  requireInstance(formatter, DateTimeFormatter, 'formatter');
1575
1578
  return formatter.parse(text, YearQuarter.FROM);
1576
1579
  };
1577
- function YearQuarter(year, quarter) {
1578
- var _this;
1579
- _this = _Temporal.call(this) || this;
1580
- _this._year = MathUtil$1.safeToInt(year);
1581
- _this._quarter = requireInstance(quarter, Quarter, 'Quarter');
1582
- return _this;
1583
- }
1584
1580
  var _proto = YearQuarter.prototype;
1585
1581
  _proto._with = function _with(newYear, newQuarter) {
1586
1582
  if (this._year === newYear && this._quarter === newQuarter) {
@@ -1868,10 +1864,10 @@ function _init$1() {
1868
1864
  }
1869
1865
  function createTemporalQuery$1(name, queryFromFunction) {
1870
1866
  var ExtendedTemporalQuery = function (_TemporalQuery) {
1871
- _inheritsLoose(ExtendedTemporalQuery, _TemporalQuery);
1872
1867
  function ExtendedTemporalQuery() {
1873
1868
  return _TemporalQuery.apply(this, arguments) || this;
1874
1869
  }
1870
+ _inheritsLoose(ExtendedTemporalQuery, _TemporalQuery);
1875
1871
  return ExtendedTemporalQuery;
1876
1872
  }(TemporalQuery);
1877
1873
  ExtendedTemporalQuery.prototype.queryFrom = queryFromFunction;
@@ -1880,6 +1876,13 @@ function createTemporalQuery$1(name, queryFromFunction) {
1880
1876
 
1881
1877
  var MathUtil = _.MathUtil;
1882
1878
  var YearWeek = function (_Temporal) {
1879
+ function YearWeek(weekBasedYear, week) {
1880
+ var _this;
1881
+ _this = _Temporal.call(this) || this;
1882
+ _this._year = weekBasedYear;
1883
+ _this._week = week;
1884
+ return _this;
1885
+ }
1883
1886
  _inheritsLoose(YearWeek, _Temporal);
1884
1887
  YearWeek.now = function now(zoneIdOrClock) {
1885
1888
  switch (arguments.length) {
@@ -1958,13 +1961,6 @@ var YearWeek = function (_Temporal) {
1958
1961
  assert(formatter != null, 'formatter', NullPointerException);
1959
1962
  return formatter.parse(text, YearWeek.FROM);
1960
1963
  };
1961
- function YearWeek(weekBasedYear, week) {
1962
- var _this;
1963
- _this = _Temporal.call(this) || this;
1964
- _this._year = weekBasedYear;
1965
- _this._week = week;
1966
- return _this;
1967
- }
1968
1964
  var _proto = YearWeek.prototype;
1969
1965
  _proto.isSupported = function isSupported(fieldOrUnit) {
1970
1966
  if (fieldOrUnit instanceof TemporalField) {
@@ -2213,10 +2209,10 @@ function _init() {
2213
2209
  }
2214
2210
  function createTemporalQuery(name, queryFromFunction) {
2215
2211
  var ExtendedTemporalQuery = function (_TemporalQuery) {
2216
- _inheritsLoose(ExtendedTemporalQuery, _TemporalQuery);
2217
2212
  function ExtendedTemporalQuery() {
2218
2213
  return _TemporalQuery.apply(this, arguments) || this;
2219
2214
  }
2215
+ _inheritsLoose(ExtendedTemporalQuery, _TemporalQuery);
2220
2216
  return ExtendedTemporalQuery;
2221
2217
  }(TemporalQuery);
2222
2218
  ExtendedTemporalQuery.prototype.queryFrom = queryFromFunction;