@js-joda/core 1.12.0 → 3.2.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/src/Year.js CHANGED
@@ -463,24 +463,6 @@ export class Year extends Temporal {
463
463
  }
464
464
 
465
465
  //-----------------------------------------------------------------------
466
- /**
467
- * function overloading for {@link YearMonth.with}
468
- *
469
- * if called with 2 arguments and first argument is an instance of TemporalField, then {@link Year.withFieldValue} is executed,
470
-
471
- * otherwise {@link Year.withAdjuster} is executed,
472
- *
473
- * @param {!(TemporalAdjuster|TemporalField|Number)} adjusterOrFieldOrNumber
474
- * @param {?number} value nullable only of first argument is an instance of TemporalAdjuster
475
- * @returns {Year}
476
- */
477
- with(adjusterOrFieldOrNumber, value) {
478
- if (arguments.length === 2 && adjusterOrFieldOrNumber instanceof TemporalField) {
479
- return this.withFieldValue(adjusterOrFieldOrNumber, value);
480
- } else {
481
- return this.withAdjuster(adjusterOrFieldOrNumber);
482
- }
483
- }
484
466
 
485
467
  /**
486
468
  * Returns an adjusted copy of this year.
@@ -562,25 +544,6 @@ export class Year extends Temporal {
562
544
  return field.adjustInto(this, newValue);
563
545
  }
564
546
 
565
- /**
566
- * function overloading for {@link Year.plus}
567
- *
568
- * if called with 1 arguments, then {@link Year.plusAmount} is executed.
569
- *
570
- * Otherwise {@link Year.plusAmountToAddUnit} is executed.
571
- *
572
- * @param {!(TemporalAmount|number)} amountOrNumber
573
- * @param {?TemporalUnit} unit nullable only if first argument is an instance of TemporalAmount
574
- * @returns {Year}
575
- */
576
- plus(amountOrNumber, unit) {
577
- if (arguments.length === 1) {
578
- return this.plusAmount(amountOrNumber);
579
- } else {
580
- return this.plusAmountToAddUnit(amountOrNumber, unit);
581
- }
582
- }
583
-
584
547
  /**
585
548
  * Returns a copy of this year with the specified period added.
586
549
  *
@@ -610,7 +573,7 @@ export class Year extends Temporal {
610
573
  * @throws DateTimeException if the addition cannot be made
611
574
  * @throws ArithmeticException if numeric overflow occurs
612
575
  */
613
- plusAmountToAddUnit(amountToAdd, unit) {
576
+ plusAmountUnit(amountToAdd, unit) {
614
577
  requireNonNull(amountToAdd, 'amountToAdd');
615
578
  requireNonNull(unit, 'unit');
616
579
  requireInstance(unit, TemporalUnit, 'unit');
@@ -644,24 +607,6 @@ export class Year extends Temporal {
644
607
  }
645
608
 
646
609
  //-----------------------------------------------------------------------
647
- /**
648
- * function overloading for {@link Year.minus}
649
- *
650
- * if called with 1 argument, then {@link Year.minusAmount} is executed.
651
- *
652
- * Otherwise {@link Year.minusAmountToSubtractUnit} is executed.
653
- *
654
- * @param {!(TemporalAmount|number)} amountOrNumber
655
- * @param {?TemporalUnit} unit
656
- * @returns {Year}
657
- */
658
- minus(amountOrNumber, unit) {
659
- if (arguments.length === 1) {
660
- return this.minusAmount(amountOrNumber);
661
- } else {
662
- return this.minusAmountToSubtractUnit(amountOrNumber, unit);
663
- }
664
- }
665
610
 
666
611
  /**
667
612
  * Returns a copy of this year with the specified period subtracted.
@@ -692,7 +637,7 @@ export class Year extends Temporal {
692
637
  * @throws DateTimeException if the subtraction cannot be made
693
638
  * @throws ArithmeticException if numeric overflow occurs
694
639
  */
695
- minusAmountToSubtractUnit(amountToSubtract, unit) {
640
+ minusAmountUnit(amountToSubtract, unit) {
696
641
  requireNonNull(amountToSubtract, 'amountToSubtract');
697
642
  requireNonNull(unit, 'unit');
698
643
  requireInstance(unit, TemporalUnit, 'unit');
@@ -980,6 +925,77 @@ export class Year extends Temporal {
980
925
  toJSON() {
981
926
  return this.toString();
982
927
  }
928
+
929
+ /**
930
+ * Calculates the amount of time until another temporal in terms of the specified unit.
931
+ * This calculates the amount of time between two temporal objects in terms of a single {@link TemporalUnit}. The start and end points are this and the specified temporal. The end point is converted to be of the same type as the start point if different. The result will be negative if the end is before the start. For example, the amount in hours between two temporal objects can be calculated using `startTime.until(endTime, HOURS)`.
932
+ *
933
+ * The calculation returns a whole number, representing the number of complete units between the two temporals. For example, the amount in hours between the times 11:30 and 13:29 will only be one hour as it is one minute short of two hours.
934
+ *
935
+ * There are two equivalent ways of using this method. The first is to invoke this method directly. The second is to use `TemporalUnit.between(Temporal, Temporal)`:
936
+ *
937
+ * <pre>
938
+ * // these two lines are equivalent
939
+ * temporal = start.until(end, unit);
940
+ * temporal = unit.between(start, end);
941
+ * </pre>
942
+ *
943
+ * The choice should be made based on which makes the code more readable.
944
+ * For example, this method allows the number of days between two dates to be calculated:
945
+ *
946
+ * <pre>
947
+ * daysBetween = start.until(end, DAYS);
948
+ * // or alternatively
949
+ * daysBetween = DAYS.between(start, end);
950
+ * </pre>
951
+ *
952
+ * ### Implementation Requirements:
953
+ * Implementations must begin by checking to ensure that the input temporal object is of the same observable type as the implementation. They must then perform the calculation for all instances of {@link ChronoUnit}. An {@link UnsupportedTemporalTypeException} must be thrown for {@link ChronoUnit} instances that are unsupported.
954
+ * If the unit is not a {@link ChronoUnit}, then the result of this method is obtained by invoking `TemporalUnit.between(Temporal, Temporal)` passing this as the first argument and the converted input temporal as the second argument.
955
+ *
956
+ * In summary, implementations must behave in a manner equivalent to this pseudo-code:
957
+ *
958
+ * <pre>
959
+ * // convert the end temporal to the same type as this class
960
+ * if (unit instanceof ChronoUnit) {
961
+ * // if unit is supported, then calculate and return result
962
+ * // else throw UnsupportedTemporalTypeException for unsupported units
963
+ * }
964
+ * return unit.between(this, convertedEndTemporal);
965
+ * </pre>
966
+ *
967
+ * Note that the unit's between method must only be invoked if the two temporal objects have exactly the same type evaluated by `getClass()`.
968
+ *
969
+ * Implementations must ensure that no observable state is altered when this read-only method is invoked.
970
+ *
971
+ * @param {Temporal} endExclusive - the end temporal, exclusive, converted to be of the same type as this object, not null
972
+ * @param {TemporalUnit} unit - the unit to measure the amount in, not null
973
+ * @return {number} the amount of time between this temporal object and the specified one in terms of the unit; positive if the specified object is later than this one, negative if it is earlier than this one
974
+ * @throws DateTimeException - if the amount cannot be calculated, or the end temporal cannot be converted to the same type as this temporal
975
+ * @throws UnsupportedTemporalTypeException - if the unit is not supported
976
+ * @throws ArithmeticException - if numeric overflow occurs
977
+ */
978
+ until(endExclusive, unit) {
979
+ const end = Year.from(endExclusive);
980
+
981
+ if (unit instanceof ChronoUnit) {
982
+ const yearsUntil = end.value() - this.value();
983
+ switch (unit) {
984
+ case ChronoUnit.YEARS:
985
+ return yearsUntil;
986
+ case ChronoUnit.DECADES:
987
+ return MathUtil.intDiv(yearsUntil, 10);
988
+ case ChronoUnit.CENTURIES:
989
+ return MathUtil.intDiv(yearsUntil, 100);
990
+ case ChronoUnit.MILLENNIA:
991
+ return MathUtil.intDiv(yearsUntil, 1000);
992
+ case ChronoUnit.ERAS:
993
+ return end.getLong(ChronoField.ERA) - this.getLong(ChronoField.ERA);
994
+ }
995
+ throw new UnsupportedTemporalTypeException('Unsupported unit: ' + unit);
996
+ }
997
+ return unit.between(this, end);
998
+ }
983
999
  }
984
1000
 
985
1001
  let PARSER;
package/src/YearMonth.js CHANGED
@@ -408,7 +408,7 @@ export class YearMonth extends Temporal {
408
408
  * @throws DateTimeException if a value for the field cannot be obtained
409
409
  * @throws ArithmeticException if numeric overflow occurs
410
410
  */
411
- getLong( field) {
411
+ getLong(field) {
412
412
  requireNonNull(field, 'field');
413
413
  requireInstance(field, TemporalField, 'field');
414
414
  if (field instanceof ChronoField) {
@@ -532,40 +532,18 @@ export class YearMonth extends Temporal {
532
532
  * function overloading for {@link YearMonth.with}
533
533
  *
534
534
  * if called with 1 argument, then {@link YearMonth.withAdjuster} is executed,
535
+ * otherwise {@link YearMonth.withFieldValue} is executed.
535
536
  *
536
- * if called with 2 arguments and first argument is an instance of TemporalField, then {@link YearMonth.withFieldValue} is executed,
537
- *
538
- * otherwise {@link YearMonth.withYearMonth} is executed
539
- *
540
- * @param {!(TemporalAdjuster|TemporalField|Number)} adjusterOrFieldOrNumber
537
+ * @param {!(TemporalAdjuster|TemporalField)} adjusterOrField
541
538
  * @param {?number} value nullable only of first argument is an instance of TemporalAdjuster
542
539
  * @returns {YearMonth}
543
540
  */
544
- with(adjusterOrFieldOrNumber, value) {
541
+ with(adjusterOrField, value) {
545
542
  if (arguments.length === 1) {
546
- return this.withAdjuster(adjusterOrFieldOrNumber);
547
- } else if (arguments.length === 2 && adjusterOrFieldOrNumber instanceof TemporalField){
548
- return this.withFieldValue(adjusterOrFieldOrNumber, value);
543
+ return this.withAdjuster(adjusterOrField);
549
544
  } else {
550
- return this.withYearMonth(adjusterOrFieldOrNumber, value);
551
- }
552
- }
553
-
554
- /**
555
- * Returns a copy of this year-month with the new year and month, checking
556
- * to see if a new object is in fact required.
557
- *
558
- * @param {number} newYear the year to represent, validated from MIN_YEAR to MAX_YEAR
559
- * @param {number} newMonth the month-of-year to represent, validated not null
560
- * @return the year-month, not null
561
- */
562
- withYearMonth(newYear, newMonth) {
563
- requireNonNull(newYear);
564
- requireNonNull(newMonth);
565
- if (this._year === newYear && this._month === newMonth) {
566
- return this;
545
+ return this.withFieldValue(adjusterOrField, value);
567
546
  }
568
- return new YearMonth(newYear, newMonth);
569
547
  }
570
548
 
571
549
  /**
@@ -671,7 +649,7 @@ export class YearMonth extends Temporal {
671
649
  */
672
650
  withYear(year) {
673
651
  ChronoField.YEAR.checkValidValue(year);
674
- return this.withYearMonth(year, this._month);
652
+ return new YearMonth(year, this._month);
675
653
  }
676
654
 
677
655
  /**
@@ -685,28 +663,10 @@ export class YearMonth extends Temporal {
685
663
  */
686
664
  withMonth(month) {
687
665
  ChronoField.MONTH_OF_YEAR.checkValidValue(month);
688
- return this.withYearMonth(this._year, month);
666
+ return new YearMonth(this._year, month);
689
667
  }
690
668
 
691
669
  //-----------------------------------------------------------------------
692
- /**
693
- * function overloading for {@link YearMonth.plus}
694
- *
695
- * if called with 1 arguments, then {@link YearMonth.plusAmount} is executed.
696
- *
697
- * Otherwise {@link YearMonth.plusAmountUnit} is executed.
698
- *
699
- * @param {!(TemporalAmount|number)} amountOrNumber
700
- * @param {?TemporalUnit} unit nullable only if first argument is an instance of TemporalAmount
701
- * @returns {YearMonth}
702
- */
703
- plus(amountOrNumber, unit) {
704
- if (arguments.length === 1) {
705
- return this.plusAmount(amountOrNumber);
706
- } else {
707
- return this.plusAmountUnit(amountOrNumber, unit);
708
- }
709
- }
710
670
 
711
671
  /**
712
672
  * Returns a copy of this year-month with the specified period added.
@@ -768,7 +728,7 @@ export class YearMonth extends Temporal {
768
728
  return this;
769
729
  }
770
730
  const newYear = ChronoField.YEAR.checkValidIntValue(this._year + yearsToAdd); // safe overflow
771
- return this.withYearMonth(newYear, this._month);
731
+ return this.withYear(newYear);
772
732
  }
773
733
 
774
734
  /**
@@ -788,28 +748,10 @@ export class YearMonth extends Temporal {
788
748
  const calcMonths = monthCount + monthsToAdd;
789
749
  const newYear = ChronoField.YEAR.checkValidIntValue(MathUtil.floorDiv(calcMonths, 12));
790
750
  const newMonth = MathUtil.floorMod(calcMonths, 12) + 1;
791
- return this.withYearMonth(newYear, newMonth);
751
+ return new YearMonth(newYear, newMonth);
792
752
  }
793
753
 
794
754
  //-----------------------------------------------------------------------
795
- /**
796
- * function overloading for {@link YearMonth.minus}
797
- *
798
- * if called with 1 arguments, then {@link YearMonth.minusAmount} is executed.
799
- *
800
- * Otherwise {@link YearMonth.minusAmountUnit} is executed.
801
- *
802
- * @param {!(TemporalAmount|number)} amountOrNumber
803
- * @param {?TemporalUnit} unit
804
- * @returns {YearMonth}
805
- */
806
- minus(amountOrNumber, unit) {
807
- if (arguments.length === 1) {
808
- return this.minusAmount(amountOrNumber);
809
- } else {
810
- return this.minusAmountUnit(amountOrNumber, unit);
811
- }
812
- }
813
755
 
814
756
  /**
815
757
  * Returns a copy of this year-month with the specified period subtracted.
@@ -13,6 +13,7 @@ import {Instant} from './Instant';
13
13
  import {LocalDate} from './LocalDate';
14
14
  import {LocalDateTime} from './LocalDateTime';
15
15
  import {LocalTime} from './LocalTime';
16
+ import {OffsetDateTime} from './OffsetDateTime';
16
17
  import {ZoneId} from './ZoneId';
17
18
  import {ZoneOffset} from './ZoneOffset';
18
19
 
@@ -975,19 +976,6 @@ export class ZonedDateTime extends ChronoZonedDateTime {
975
976
  }
976
977
 
977
978
  //-----------------------------------------------------------------------
978
- /**
979
- * function overloading for {@link ZonedDateTime.with}
980
- *
981
- * if called with 1 argument {@link ZonedDateTime.withTemporalAdjuster} is applied
982
- * otherwise {@link ZonedDateTime.with2}
983
- */
984
- with(){
985
- if(arguments.length === 1){
986
- return this.withTemporalAdjuster.apply(this, arguments);
987
- } else {
988
- return this.with2.apply(this, arguments);
989
- }
990
- }
991
979
 
992
980
  /**
993
981
  * Returns an adjusted copy of this date-time.
@@ -1041,7 +1029,7 @@ export class ZonedDateTime extends ChronoZonedDateTime {
1041
1029
  * @throws DateTimeException if the adjustment cannot be made
1042
1030
  * @throws ArithmeticException if numeric overflow occurs
1043
1031
  */
1044
- withTemporalAdjuster(adjuster) {
1032
+ withAdjuster(adjuster) {
1045
1033
  // optimizations
1046
1034
  if (adjuster instanceof LocalDate) {
1047
1035
  return this._resolveLocal(LocalDateTime.of(adjuster, this._dateTime.toLocalTime()));
@@ -1110,7 +1098,7 @@ export class ZonedDateTime extends ChronoZonedDateTime {
1110
1098
  * @throws UnsupportedTemporalTypeException if the field is not supported
1111
1099
  * @throws ArithmeticException if numeric overflow occurs
1112
1100
  */
1113
- with2(field, newValue) {
1101
+ withFieldValue(field, newValue) {
1114
1102
  if (field instanceof ChronoField) {
1115
1103
  switch (field) {
1116
1104
  case ChronoField.INSTANT_SECONDS: return ZonedDateTime._create(newValue, this.nano(), this._zone);
@@ -1336,19 +1324,6 @@ export class ZonedDateTime extends ChronoZonedDateTime {
1336
1324
  }
1337
1325
 
1338
1326
  //-----------------------------------------------------------------------
1339
- /**
1340
- * function overloading for {@link ZonedDateTime.plus}
1341
- *
1342
- * if called with 1 argument {@link ZonedDateTime.plusTemporalAmount} is applied,
1343
- * otherwise {@link ZonedDateTime.plus2}
1344
- */
1345
- plus(){
1346
- if(arguments.length === 1){
1347
- return this.plusTemporalAmount.apply(this, arguments);
1348
- } else {
1349
- return this.plus2.apply(this, arguments);
1350
- }
1351
- }
1352
1327
 
1353
1328
  /**
1354
1329
  * Returns a copy of this date-time with the specified period added.
@@ -1366,7 +1341,7 @@ export class ZonedDateTime extends ChronoZonedDateTime {
1366
1341
  * @throws DateTimeException if the addition cannot be made
1367
1342
  * @throws ArithmeticException if numeric overflow occurs
1368
1343
  */
1369
- plusTemporalAmount(amount) {
1344
+ plusAmount(amount) {
1370
1345
  requireNonNull(amount);
1371
1346
  return amount.addTo(this);
1372
1347
  }
@@ -1400,7 +1375,7 @@ export class ZonedDateTime extends ChronoZonedDateTime {
1400
1375
  * @return {ZonedDateTime} a {@link ZonedDateTime} based on this date-time with the specified period added, not null
1401
1376
  * @throws DateTimeException if the unit cannot be added to this type
1402
1377
  */
1403
- plus2(amountToAdd, unit) {
1378
+ plusAmountUnit(amountToAdd, unit) {
1404
1379
  if (unit instanceof ChronoUnit) {
1405
1380
  if (unit.isDateBased()) {
1406
1381
  return this._resolveLocal(this._dateTime.plus(amountToAdd, unit));
@@ -1580,19 +1555,6 @@ export class ZonedDateTime extends ChronoZonedDateTime {
1580
1555
  }
1581
1556
 
1582
1557
  //-----------------------------------------------------------------------
1583
- /**
1584
- * function overloading for {@link ZonedDateTime.minus}
1585
- *
1586
- * if called with 1 argument {@link ZonedDateTime.minusTemporalAmount} is applied,
1587
- * otherwise {@link ZonedDateTime.minus2}
1588
- */
1589
- minus(){
1590
- if(arguments.length === 1){
1591
- return this.minusTemporalAmount.apply(this, arguments);
1592
- } else {
1593
- return this.minus2.apply(this, arguments);
1594
- }
1595
- }
1596
1558
 
1597
1559
  /**
1598
1560
  * Returns a copy of this date-time with the specified period subtracted.
@@ -1610,7 +1572,7 @@ export class ZonedDateTime extends ChronoZonedDateTime {
1610
1572
  * @throws DateTimeException if the subtraction cannot be made
1611
1573
  * @throws ArithmeticException if numeric overflow occurs
1612
1574
  */
1613
- minusTemporalAmount(amount) {
1575
+ minusAmount(amount) {
1614
1576
  requireNonNull(amount, 'amount');
1615
1577
  return amount.subtractFrom(this);
1616
1578
  }
@@ -1644,8 +1606,8 @@ export class ZonedDateTime extends ChronoZonedDateTime {
1644
1606
  * @return {ZonedDateTime} a {@link ZonedDateTime} based on this date-time with the specified period subtracted, not null
1645
1607
  * @throws DateTimeException if the unit cannot be added to this type
1646
1608
  */
1647
- minus2(amountToSubtract, unit) {
1648
- return this.plus2(-1 * amountToSubtract, unit);
1609
+ minusAmountUnit(amountToSubtract, unit) {
1610
+ return this.plusAmountUnit(-1 * amountToSubtract, unit);
1649
1611
  }
1650
1612
 
1651
1613
  //-----------------------------------------------------------------------
@@ -1963,12 +1925,9 @@ export class ZonedDateTime extends ChronoZonedDateTime {
1963
1925
  *
1964
1926
  * @return {OffsetDateTime} an offset date-time representing the same local date-time and offset, not null
1965
1927
  */
1966
- /**
1967
- * we will not support OffsetDateTime in the near future
1968
- toOffsetDateTime() {
1969
- return OffsetDateTime.of(this._dateTime, this._offset);
1970
- }
1971
- */
1928
+ toOffsetDateTime() {
1929
+ return OffsetDateTime.of(this._dateTime, this._offset);
1930
+ }
1972
1931
 
1973
1932
  //-----------------------------------------------------------------------
1974
1933
  /**
package/src/_init.js CHANGED
@@ -12,6 +12,8 @@ import {_init as LocalTimeInit} from './LocalTime';
12
12
  import {_init as LocalDateTimeInit} from './LocalDateTime';
13
13
  import {_init as MonthInit} from './Month';
14
14
  import {_init as MonthDayInit} from './MonthDay';
15
+ import {_init as OffsetDateTimeInit} from './OffsetDateTime';
16
+ import {_init as OffsetTimeInit} from './OffsetTime';
15
17
  import {_init as PeriodInit} from './Period';
16
18
  import {_init as YearInit} from './Year';
17
19
  import {_init as YearConstantsInit} from './YearConstants';
@@ -59,6 +61,8 @@ function init() {
59
61
  IsoChronologyInit();
60
62
  DateTimeFormatterInit();
61
63
  DateTimeFormatterBuilderInit();
64
+ OffsetDateTimeInit();
65
+ OffsetTimeInit();
62
66
  }
63
67
 
64
68
  init();
@@ -10,7 +10,7 @@ import {ChronoField} from '../temporal/ChronoField';
10
10
  import {ChronoUnit} from '../temporal/ChronoUnit';
11
11
  import {DateTimeFormatter} from '../format/DateTimeFormatter';
12
12
  import {TemporalQueries} from '../temporal/TemporalQueries';
13
- import {Temporal} from '../temporal/Temporal';
13
+ import {DefaultInterfaceTemporal} from '../temporal/DefaultInterfaceTemporal';
14
14
 
15
15
  import {LocalDate} from '../LocalDate';
16
16
 
@@ -180,7 +180,7 @@ import {LocalDate} from '../LocalDate';
180
180
  * In JDK 8, this is an interface with default methods.
181
181
  * Since there are no default methods in JDK 7, an abstract class is used.
182
182
  */
183
- export class ChronoLocalDate extends Temporal {
183
+ export class ChronoLocalDate extends DefaultInterfaceTemporal {
184
184
 
185
185
  isSupported(fieldOrUnit) {
186
186
  if (fieldOrUnit instanceof ChronoField) {
@@ -12,7 +12,7 @@ import {Instant} from '../Instant';
12
12
  import {ZoneOffset} from '../ZoneOffset';
13
13
  import {ChronoUnit} from '../temporal/ChronoUnit';
14
14
  import {ChronoField} from '../temporal/ChronoField';
15
- import {Temporal} from '../temporal/Temporal';
15
+ import {DefaultInterfaceTemporal} from '../temporal/DefaultInterfaceTemporal';
16
16
  import {TemporalQueries} from '../temporal/TemporalQueries';
17
17
 
18
18
  /**
@@ -49,7 +49,7 @@ import {TemporalQueries} from '../temporal/TemporalQueries';
49
49
  *
50
50
  * @param D the date type
51
51
  */
52
- export class ChronoLocalDateTime extends Temporal {
52
+ export class ChronoLocalDateTime extends DefaultInterfaceTemporal {
53
53
  /* <D extends ChronoLocalDate>
54
54
  extends DefaultInterfaceTemporal
55
55
  implements Temporal, TemporalAdjuster, Comparable<ChronoLocalDateTime<?>> */
@@ -10,10 +10,10 @@ import {LocalDate} from '../LocalDate';
10
10
  import {MathUtil} from '../MathUtil';
11
11
 
12
12
  import {ChronoUnit} from '../temporal/ChronoUnit';
13
- import {Temporal} from '../temporal/Temporal';
13
+ import {DefaultInterfaceTemporal} from '../temporal/DefaultInterfaceTemporal';
14
14
  import {TemporalQueries} from '../temporal/TemporalQueries';
15
15
 
16
- export class ChronoZonedDateTime extends Temporal {
16
+ export class ChronoZonedDateTime extends DefaultInterfaceTemporal {
17
17
  query(query) {
18
18
  if (query === TemporalQueries.zoneId() || query === TemporalQueries.zone()) {
19
19
  return this.zone();
package/src/errors.js CHANGED
@@ -4,8 +4,8 @@
4
4
  */
5
5
 
6
6
  function createErrorType(name, init, superErrorClass = Error) {
7
- function E(message) {
8
- if (!Error.captureStackTrace){
7
+ function JsJodaException(message) {
8
+ if (!Error.captureStackTrace) {
9
9
  this.stack = (new Error()).stack;
10
10
  } else {
11
11
  Error.captureStackTrace(this, this.constructor);
@@ -16,10 +16,10 @@ function createErrorType(name, init, superErrorClass = Error) {
16
16
  return `${this.name}: ${this.message}`;
17
17
  };
18
18
  }
19
- E.prototype = new superErrorClass();
20
- E.prototype.name = name;
21
- E.prototype.constructor = E;
22
- return E;
19
+ JsJodaException.prototype = Object.create(superErrorClass.prototype);
20
+ JsJodaException.prototype.name = name;
21
+ JsJodaException.prototype.constructor = JsJodaException;
22
+ return JsJodaException;
23
23
  }
24
24
 
25
25
  export const DateTimeException = createErrorType('DateTimeException', messageWithCause);
@@ -14,7 +14,7 @@ import {ResolverStyle} from './ResolverStyle';
14
14
  import {IsoChronology} from '../chrono/IsoChronology';
15
15
  import {ChronoLocalDate} from '../chrono/ChronoLocalDate';
16
16
  import {ChronoField} from '../temporal/ChronoField';
17
- import {Temporal} from '../temporal/Temporal';
17
+ import {TemporalAccessor} from '../temporal/TemporalAccessor';
18
18
  import {TemporalQueries} from '../temporal/TemporalQueries';
19
19
 
20
20
  import {LocalTime} from '../LocalTime';
@@ -36,7 +36,7 @@ import {ZoneOffset} from '../ZoneOffset';
36
36
  *
37
37
  * @private
38
38
  */
39
- export class DateTimeBuilder extends Temporal {
39
+ export class DateTimeBuilder extends TemporalAccessor {
40
40
 
41
41
  /**
42
42
  * Creates a new instance of the builder with a single field-value.
@@ -704,9 +704,9 @@ export function _init() {
704
704
  .toFormatter(ResolverStyle.STRICT);
705
705
 
706
706
  // TODO:
707
- // ISO_DATE - https://docs.oracle.com/javase/10/docs/api/java/time/format/DateTimeFormatter.html#ISO_DATE
708
- // ISO_TIME - https://docs.oracle.com/javase/10/docs/api/java/time/format/DateTimeFormatter.html#ISO_TIME
709
- // ISO_DATE_TIME - https://docs.oracle.com/javase/10/docs/api/java/time/format/DateTimeFormatter.html#ISO_DATE_TIME
707
+ // ISO_DATE - https://www.threeten.org/threetenbp/apidocs/org/threeten/bp/format/DateTimeFormatter.html#ISO_DATE
708
+ // ISO_TIME - https://www.threeten.org/threetenbp/apidocs/org/threeten/bp/format/DateTimeFormatter.html#ISO_TIME
709
+ // ISO_DATE_TIME - https://www.threeten.org/threetenbp/apidocs/org/threeten/bp/format/DateTimeFormatter.html#ISO_DATE_TIME
710
710
 
711
711
  DateTimeFormatter.PARSED_EXCESS_DAYS = createTemporalQuery('PARSED_EXCESS_DAYS', (temporal) => {
712
712
  if (temporal instanceof DateTimeBuilder) {
package/src/js-joda.js CHANGED
@@ -22,6 +22,8 @@ import { LocalTime } from './LocalTime';
22
22
  import { LocalDateTime } from './LocalDateTime';
23
23
  import { Month } from './Month';
24
24
  import { MonthDay } from './MonthDay';
25
+ import { OffsetDateTime } from './OffsetDateTime';
26
+ import { OffsetTime } from './OffsetTime';
25
27
  import { Period } from './Period';
26
28
  import { Year } from './Year';
27
29
  import { YearConstants } from './YearConstants';
@@ -105,6 +107,8 @@ const jsJodaExports = {
105
107
  LocalDate,
106
108
  LocalTime,
107
109
  LocalDateTime,
110
+ OffsetTime,
111
+ OffsetDateTime,
108
112
  Month,
109
113
  MonthDay,
110
114
  Period,
@@ -167,6 +171,8 @@ export {
167
171
  LocalDateTime,
168
172
  Month,
169
173
  MonthDay,
174
+ OffsetTime,
175
+ OffsetDateTime,
170
176
  Period,
171
177
  Year,
172
178
  YearConstants,