@js-joda/core 3.2.0 → 4.2.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.
Files changed (74) hide show
  1. package/CHANGELOG.md +32 -1
  2. package/README.md +43 -36
  3. package/dist/js-joda.d.ts +241 -179
  4. package/dist/js-joda.esm.js +11524 -10214
  5. package/dist/js-joda.js +11524 -10214
  6. package/dist/js-joda.js.map +1 -1
  7. package/dist/js-joda.min.js +2 -2
  8. package/package.json +10 -40
  9. package/src/Clock.js +8 -9
  10. package/src/DayOfWeek.js +14 -14
  11. package/src/Duration.js +15 -15
  12. package/src/Instant.js +40 -74
  13. package/src/LocalDate.js +71 -93
  14. package/src/LocalDateTime.js +25 -68
  15. package/src/LocalTime.js +27 -72
  16. package/src/MathUtil.js +3 -3
  17. package/src/Month.js +13 -13
  18. package/src/MonthDay.js +25 -25
  19. package/src/OffsetDateTime.js +29 -29
  20. package/src/OffsetTime.js +32 -32
  21. package/src/Period.js +12 -12
  22. package/src/StringUtil.js +1 -1
  23. package/src/Year.js +33 -115
  24. package/src/YearMonth.js +31 -113
  25. package/src/ZoneId.js +7 -7
  26. package/src/ZoneIdFactory.js +14 -14
  27. package/src/ZoneOffset.js +23 -23
  28. package/src/ZoneRegion.js +2 -2
  29. package/src/ZonedDateTime.js +31 -74
  30. package/src/_init.js +24 -24
  31. package/src/assert.js +31 -4
  32. package/src/chrono/ChronoLocalDate.js +8 -8
  33. package/src/chrono/ChronoLocalDateTime.js +10 -10
  34. package/src/chrono/ChronoZonedDateTime.js +8 -8
  35. package/src/chrono/IsoChronology.js +13 -13
  36. package/src/convert.js +12 -8
  37. package/src/errors.js +3 -3
  38. package/src/format/DateTimeBuilder.js +17 -17
  39. package/src/format/DateTimeFormatter.js +45 -24
  40. package/src/format/DateTimeFormatterBuilder.js +59 -59
  41. package/src/format/DateTimeParseContext.js +6 -6
  42. package/src/format/DateTimePrintContext.js +3 -3
  43. package/src/format/DecimalStyle.js +1 -1
  44. package/src/format/ResolverStyle.js +1 -1
  45. package/src/format/SignStyle.js +1 -1
  46. package/src/format/TextStyle.js +1 -1
  47. package/src/format/parser/CharLiteralPrinterParser.js +3 -3
  48. package/src/format/parser/FractionPrinterParser.js +10 -10
  49. package/src/format/parser/NumberPrinterParser.js +18 -18
  50. package/src/format/parser/OffsetIdPrinterParser.js +9 -9
  51. package/src/format/parser/PadPrinterParserDecorator.js +3 -3
  52. package/src/format/parser/StringLiteralPrinterParser.js +2 -2
  53. package/src/format/parser/ZoneIdPrinterParser.js +5 -5
  54. package/src/js-joda.js +5 -0
  55. package/src/temporal/ChronoField.js +5 -5
  56. package/src/temporal/ChronoUnit.js +6 -6
  57. package/src/temporal/IsoFields.js +12 -12
  58. package/src/temporal/NativeJsTemporal.js +11 -11
  59. package/src/temporal/Temporal.js +45 -38
  60. package/src/temporal/TemporalAccessor.js +14 -4
  61. package/src/temporal/TemporalAdjuster.js +1 -1
  62. package/src/temporal/TemporalAdjusters.js +6 -6
  63. package/src/temporal/TemporalAmount.js +1 -1
  64. package/src/temporal/TemporalQueriesFactory.js +6 -6
  65. package/src/temporal/TemporalQuery.js +4 -2
  66. package/src/temporal/TemporalUnit.js +1 -1
  67. package/src/temporal/ValueRange.js +15 -15
  68. package/src/use.js +6 -1
  69. package/src/zone/SystemDefaultZoneId.js +2 -2
  70. package/src/zone/SystemDefaultZoneRules.js +3 -3
  71. package/src/zone/ZoneOffsetTransition.js +7 -7
  72. package/src/zone/ZoneRules.js +4 -4
  73. package/src/zone/ZoneRulesProvider.js +2 -2
  74. package/src/temporal/DefaultInterfaceTemporal.js +0 -118
package/src/LocalTime.js CHANGED
@@ -5,22 +5,23 @@
5
5
  */
6
6
 
7
7
 
8
- import {MathUtil} from './MathUtil';
9
- import {assert, requireNonNull, requireInstance} from './assert';
10
- import {DateTimeException, UnsupportedTemporalTypeException, IllegalArgumentException} from './errors';
8
+ import { MathUtil } from './MathUtil';
9
+ import { requireNonNull, requireInstance } from './assert';
10
+ import { DateTimeException, UnsupportedTemporalTypeException } from './errors';
11
11
 
12
- import {Clock} from './Clock';
13
- import {LocalDateTime} from './LocalDateTime';
14
- import {ZoneId} from './ZoneId';
12
+ import { Clock } from './Clock';
13
+ import { LocalDateTime } from './LocalDateTime';
14
+ import { ZoneId } from './ZoneId';
15
+ import { OffsetTime } from './OffsetTime';
15
16
 
16
- import {DateTimeFormatter} from './format/DateTimeFormatter';
17
+ import { DateTimeFormatter } from './format/DateTimeFormatter';
17
18
 
18
- import {ChronoField} from './temporal/ChronoField';
19
- import {ChronoUnit} from './temporal/ChronoUnit';
20
- import {Temporal} from './temporal/Temporal';
21
- import {TemporalField} from './temporal/TemporalField';
22
- import {TemporalQueries} from './temporal/TemporalQueries';
23
- import {createTemporalQuery} from './temporal/TemporalQuery';
19
+ import { ChronoField } from './temporal/ChronoField';
20
+ import { ChronoUnit } from './temporal/ChronoUnit';
21
+ import { Temporal } from './temporal/Temporal';
22
+ import { TemporalField } from './temporal/TemporalField';
23
+ import { TemporalQueries } from './temporal/TemporalQueries';
24
+ import { createTemporalQuery } from './temporal/TemporalQuery';
24
25
 
25
26
  /**
26
27
  * A time without time-zone in the ISO-8601 calendar system,
@@ -460,7 +461,7 @@ export class LocalTime extends Temporal /** implements Temporal, TemporalAdjuste
460
461
  case ChronoField.CLOCK_HOUR_OF_DAY: return (this._hour === 0 ? 24 : this._hour);
461
462
  case ChronoField.AMPM_OF_DAY: return MathUtil.intDiv(this._hour, 12);
462
463
  }
463
- throw new UnsupportedTemporalTypeException('Unsupported field: ' + field);
464
+ throw new UnsupportedTemporalTypeException(`Unsupported field: ${field}`);
464
465
  }
465
466
 
466
467
  //-----------------------------------------------------------------------
@@ -521,14 +522,13 @@ export class LocalTime extends Temporal /** implements Temporal, TemporalAdjuste
521
522
  * @throws {DateTimeException} if the adjustment cannot be made
522
523
  * @throws {ArithmeticException} if numeric overflow occurs
523
524
  */
524
- withAdjuster(adjuster) {
525
+ _withAdjuster(adjuster) {
525
526
  requireNonNull(adjuster, 'adjuster');
526
527
  // optimizations
527
528
  if (adjuster instanceof LocalTime) {
528
529
  return adjuster;
529
530
  }
530
- assert(typeof adjuster.adjustInto === 'function', 'adjuster', IllegalArgumentException);
531
- return adjuster.adjustInto(this);
531
+ return super._withAdjuster(adjuster);
532
532
  }
533
533
 
534
534
  /**
@@ -611,7 +611,7 @@ export class LocalTime extends Temporal /** implements Temporal, TemporalAdjuste
611
611
  * @throws {DateTimeException} if the field cannot be set
612
612
  * @throws {ArithmeticException} if numeric overflow occurs
613
613
  */
614
- withFieldValue(field, newValue) {
614
+ _withField(field, newValue) {
615
615
  requireNonNull(field, 'field');
616
616
  requireInstance(field, TemporalField, 'field');
617
617
  if (field instanceof ChronoField) {
@@ -633,7 +633,7 @@ export class LocalTime extends Temporal /** implements Temporal, TemporalAdjuste
633
633
  case ChronoField.CLOCK_HOUR_OF_DAY: return this.withHour((newValue === 24 ? 0 : newValue));
634
634
  case ChronoField.AMPM_OF_DAY: return this.plusHours((newValue - MathUtil.intDiv(this._hour, 12)) * 12);
635
635
  }
636
- throw new UnsupportedTemporalTypeException('Unsupported field: ' + field);
636
+ throw new UnsupportedTemporalTypeException(`Unsupported field: ${field}`);
637
637
  }
638
638
  return field.adjustInto(this, newValue);
639
639
  }
@@ -742,27 +742,6 @@ export class LocalTime extends Temporal /** implements Temporal, TemporalAdjuste
742
742
 
743
743
  //-----------------------------------------------------------------------
744
744
 
745
- /**
746
- * Returns a copy of this date with the specified period added.
747
- *
748
- * This method returns a new time based on this time with the specified period added.
749
- * The amount is typically {@link Period} but may be any other type implementing
750
- * the {@link TemporalAmount} interface.
751
- * The calculation is delegated to the specified adjuster, which typically calls
752
- * back to {@link plus}.
753
- *
754
- * This instance is immutable and unaffected by this method call.
755
- *
756
- * @param {TemporalAmount} amount - the amount to add, not null
757
- * @return {LocalTime} a {@link LocalTime} based on this time with the addition made, not null
758
- * @throws {DateTimeException} if the addition cannot be made
759
- * @throws {ArithmeticException} if numeric overflow occurs
760
- */
761
- plusAmount(amount) {
762
- requireNonNull(amount, 'amount');
763
- return amount.addTo(this);
764
- }
765
-
766
745
  /**
767
746
  * Returns a copy of this time with the specified period added.
768
747
  *
@@ -778,7 +757,7 @@ export class LocalTime extends Temporal /** implements Temporal, TemporalAdjuste
778
757
  * @return {LocalTime} a {@link LocalTime} based on this time with the specified period added, not null
779
758
  * @throws {DateTimeException} if the unit cannot be added to this type
780
759
  */
781
- plusAmountUnit(amountToAdd, unit) {
760
+ _plusUnit(amountToAdd, unit) {
782
761
  requireNonNull(unit, 'unit');
783
762
  if (unit instanceof ChronoUnit) {
784
763
  switch (unit) {
@@ -790,7 +769,7 @@ export class LocalTime extends Temporal /** implements Temporal, TemporalAdjuste
790
769
  case ChronoUnit.HOURS: return this.plusHours(amountToAdd);
791
770
  case ChronoUnit.HALF_DAYS: return this.plusHours(MathUtil.intMod(amountToAdd, 2) * 12);
792
771
  }
793
- throw new UnsupportedTemporalTypeException('Unsupported unit: ' + unit);
772
+ throw new UnsupportedTemporalTypeException(`Unsupported unit: ${unit}`);
794
773
  }
795
774
  return unit.addTo(this, amountToAdd);
796
775
  }
@@ -897,28 +876,6 @@ export class LocalTime extends Temporal /** implements Temporal, TemporalAdjuste
897
876
 
898
877
  //-----------------------------------------------------------------------
899
878
 
900
- /**
901
- * Returns a copy of this time with the specified period subtracted.
902
- *
903
- * This method returns a new time based on this time with the specified period subtracted.
904
- * The amount is typically {@link Period} but may be any other type implementing
905
- * the {@link TemporalAmount} interface.
906
- * The calculation is delegated to the specified adjuster, which typically calls
907
- * back to {@link minus}.
908
- *
909
- * This instance is immutable and unaffected by this method call.
910
- *
911
- * @param {TemporalAmount} amount - the amount to subtract, not null
912
- * @return {LocalTime} a {@link LocalTime} based on this time with the subtraction made, not null
913
- * @throws {DateTimeException} if the subtraction cannot be made
914
- * @throws {ArithmeticException} if numeric overflow occurs
915
- */
916
-
917
- minusAmount(amount) {
918
- requireNonNull(amount, 'amount');
919
- return amount.subtractFrom(this);
920
- }
921
-
922
879
  /**
923
880
  * Returns a copy of this time with the specified period subtracted.
924
881
  *
@@ -934,9 +891,9 @@ export class LocalTime extends Temporal /** implements Temporal, TemporalAdjuste
934
891
  * @return {LocalTime} a {@link LocalTime} based on this time with the specified period subtracted, not null
935
892
  * @throws {DateTimeException} if the unit cannot be added to this type
936
893
  */
937
- minusAmountUnit(amountToSubtract, unit) {
894
+ _minusUnit(amountToSubtract, unit) {
938
895
  requireNonNull(unit, 'unit');
939
- return this.plusAmountUnit(-1 * amountToSubtract, unit);
896
+ return this._plusUnit(-1 * amountToSubtract, unit);
940
897
  }
941
898
 
942
899
  //-----------------------------------------------------------------------
@@ -1120,7 +1077,7 @@ export class LocalTime extends Temporal /** implements Temporal, TemporalAdjuste
1120
1077
  case ChronoUnit.HOURS: return MathUtil.intDiv(nanosUntil, LocalTime.NANOS_PER_HOUR);
1121
1078
  case ChronoUnit.HALF_DAYS: return MathUtil.intDiv(nanosUntil, (12 * LocalTime.NANOS_PER_HOUR));
1122
1079
  }
1123
- throw new UnsupportedTemporalTypeException('Unsupported unit: ' + unit);
1080
+ throw new UnsupportedTemporalTypeException(`Unsupported unit: ${unit}`);
1124
1081
  }
1125
1082
  return unit.between(this, end);
1126
1083
  }
@@ -1148,11 +1105,9 @@ export class LocalTime extends Temporal /** implements Temporal, TemporalAdjuste
1148
1105
  * @param {OffsetTime} offset - the offset to combine with, not null
1149
1106
  * @return {OffsetTime} the offset time formed from this time and the specified offset, not null
1150
1107
  */
1151
- /*
1152
1108
  atOffset(offset) {
1153
1109
  return OffsetTime.of(this, offset);
1154
1110
  }
1155
- */
1156
1111
 
1157
1112
  //-----------------------------------------------------------------------
1158
1113
  /**
@@ -1300,11 +1255,11 @@ export class LocalTime extends Temporal /** implements Temporal, TemporalAdjuste
1300
1255
  if (nanoValue > 0) {
1301
1256
  buf += '.';
1302
1257
  if(MathUtil.intMod(nanoValue, 1000000) === 0) {
1303
- buf += ('' + (MathUtil.intDiv(nanoValue, 1000000) + 1000)).substring(1);
1258
+ buf += (`${MathUtil.intDiv(nanoValue, 1000000) + 1000}`).substring(1);
1304
1259
  } else if (MathUtil.intMod(nanoValue, 1000) === 0) {
1305
- buf += ('' + (MathUtil.intDiv(nanoValue, 1000) + 1000000)).substring(1);
1260
+ buf += (`${MathUtil.intDiv(nanoValue, 1000) + 1000000}`).substring(1);
1306
1261
  } else {
1307
- buf += ('' + (nanoValue + 1000000000)).substring(1);
1262
+ buf += (`${nanoValue + 1000000000}`).substring(1);
1308
1263
  }
1309
1264
  }
1310
1265
  }
package/src/MathUtil.js CHANGED
@@ -3,7 +3,7 @@
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 {ArithmeticException} from './errors';
6
+ import { ArithmeticException } from './errors';
7
7
 
8
8
  export const MAX_SAFE_INTEGER = 9007199254740991;
9
9
  export const MIN_SAFE_INTEGER = -9007199254740991;
@@ -132,7 +132,7 @@ export class MathUtil {
132
132
  }
133
133
  const r = MathUtil.safeToInt(x * y);
134
134
  if (r / y !== x || (x === MIN_SAFE_INTEGER && y === -1) || (y === MIN_SAFE_INTEGER && x === -1)) {
135
- throw new ArithmeticException('Multiplication overflows: ' + x + ' * ' + y);
135
+ throw new ArithmeticException(`Multiplication overflows: ${x} * ${y}`);
136
136
  }
137
137
  return r;
138
138
  }
@@ -172,7 +172,7 @@ export class MathUtil {
172
172
  throw new ArithmeticException(`Invalid value: '${value}' is a float`);
173
173
  }
174
174
  if (value > MAX_SAFE_INTEGER || value < MIN_SAFE_INTEGER) {
175
- throw new ArithmeticException('Calculation overflows an int: ' + value);
175
+ throw new ArithmeticException(`Calculation overflows an int: ${value}`);
176
176
  }
177
177
  }
178
178
 
package/src/Month.js CHANGED
@@ -4,15 +4,15 @@
4
4
  * @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
5
5
  */
6
6
 
7
- import {assert, requireNonNull, requireInstance} from './assert';
8
- import {MathUtil} from './MathUtil';
7
+ import { assert, requireNonNull, requireInstance } from './assert';
8
+ import { MathUtil } from './MathUtil';
9
9
 
10
- import {ChronoField} from './temporal/ChronoField';
11
- import {ChronoUnit} from './temporal/ChronoUnit';
12
- import {DateTimeException, IllegalArgumentException, UnsupportedTemporalTypeException} from './errors';
13
- import {IsoChronology} from './chrono/IsoChronology';
14
- import {TemporalAccessor} from './temporal/TemporalAccessor';
15
- import {TemporalQueries} from './temporal/TemporalQueries';
10
+ import { ChronoField } from './temporal/ChronoField';
11
+ import { ChronoUnit } from './temporal/ChronoUnit';
12
+ import { DateTimeException, IllegalArgumentException, UnsupportedTemporalTypeException } from './errors';
13
+ import { IsoChronology } from './chrono/IsoChronology';
14
+ import { TemporalAccessor } from './temporal/TemporalAccessor';
15
+ import { TemporalQueries } from './temporal/TemporalQueries';
16
16
 
17
17
  /**
18
18
  * A month-of-year, such as 'July'.
@@ -179,7 +179,7 @@ export class Month extends TemporalAccessor {
179
179
  if (field === ChronoField.MONTH_OF_YEAR) {
180
180
  return this.value();
181
181
  } else if (field instanceof ChronoField) {
182
- throw new UnsupportedTemporalTypeException('Unsupported field: ' + field);
182
+ throw new UnsupportedTemporalTypeException(`Unsupported field: ${field}`);
183
183
  }
184
184
  return field.getFrom(this);
185
185
  }
@@ -425,7 +425,7 @@ export class Month extends TemporalAccessor {
425
425
  case Month.DECEMBER:
426
426
  return 'DECEMBER';
427
427
  default:
428
- return 'unknown Month, value: ' + this.value();
428
+ return `unknown Month, value: ${this.value()}`;
429
429
  }
430
430
  }
431
431
 
@@ -537,7 +537,7 @@ export class Month extends TemporalAccessor {
537
537
  **/
538
538
  static of(month) {
539
539
  if (month < 1 || month > 12) {
540
- assert(false, 'Invalid value for MonthOfYear: ' + month, DateTimeException);
540
+ assert(false, `Invalid value for MonthOfYear: ${month}`, DateTimeException);
541
541
  }
542
542
  return MONTHS[month-1];
543
543
  }
@@ -571,8 +571,8 @@ export class Month extends TemporalAccessor {
571
571
  }*/
572
572
  return Month.of(temporal.get(ChronoField.MONTH_OF_YEAR));
573
573
  } catch (ex) {
574
- throw new DateTimeException('Unable to obtain Month from TemporalAccessor: ' +
575
- temporal + ' of type ' + (temporal && temporal.constructor != null ? temporal.constructor.name : ''), ex);
574
+ throw new DateTimeException(`Unable to obtain Month from TemporalAccessor: ${
575
+ temporal} of type ${temporal && temporal.constructor != null ? temporal.constructor.name : ''}`, ex);
576
576
  }
577
577
  }
578
578
  }
package/src/MonthDay.js CHANGED
@@ -3,23 +3,23 @@
3
3
  * @license BSD-3-Clause (see LICENSE.md in the root directory of this source tree)
4
4
  */
5
5
 
6
- import {requireNonNull, requireInstance} from './assert';
7
- import {DateTimeException, UnsupportedTemporalTypeException} from './errors';
8
- import {MathUtil} from './MathUtil';
9
-
10
- import {ChronoField} from './temporal/ChronoField';
11
- import {Clock} from './Clock';
12
- import {DateTimeFormatter} from './format/DateTimeFormatter';
13
- import {DateTimeFormatterBuilder} from './format/DateTimeFormatterBuilder';
14
- import {IsoChronology} from './chrono/IsoChronology';
15
- import {LocalDate} from './LocalDate';
16
- import {Month} from './Month';
17
- import {TemporalAccessor} from './temporal/TemporalAccessor';
18
- import {TemporalQuery, createTemporalQuery} from './temporal/TemporalQuery';
19
- import {TemporalQueries} from './temporal/TemporalQueries';
20
- import {ValueRange} from './temporal/ValueRange';
21
- import {Year} from './Year';
22
- import {ZoneId} from './ZoneId';
6
+ import { requireNonNull, requireInstance } from './assert';
7
+ import { DateTimeException, UnsupportedTemporalTypeException } from './errors';
8
+ import { MathUtil } from './MathUtil';
9
+
10
+ import { ChronoField } from './temporal/ChronoField';
11
+ import { Clock } from './Clock';
12
+ import { DateTimeFormatter } from './format/DateTimeFormatter';
13
+ import { DateTimeFormatterBuilder } from './format/DateTimeFormatterBuilder';
14
+ import { IsoChronology } from './chrono/IsoChronology';
15
+ import { LocalDate } from './LocalDate';
16
+ import { Month } from './Month';
17
+ import { TemporalAccessor } from './temporal/TemporalAccessor';
18
+ import { TemporalQuery, createTemporalQuery } from './temporal/TemporalQuery';
19
+ import { TemporalQueries } from './temporal/TemporalQueries';
20
+ import { ValueRange } from './temporal/ValueRange';
21
+ import { Year } from './Year';
22
+ import { ZoneId } from './ZoneId';
23
23
 
24
24
  /**
25
25
  * A month-day in the ISO-8601 calendar system, such as `--12-03`.
@@ -159,8 +159,8 @@ export class MonthDay extends TemporalAccessor {
159
159
  requireNonNull(month, 'month');
160
160
  ChronoField.DAY_OF_MONTH.checkValidValue(dayOfMonth);
161
161
  if (dayOfMonth > month.maxLength()) {
162
- throw new DateTimeException('Illegal value for DayOfMonth field, value ' + dayOfMonth +
163
- ' is not valid for month ' + month.toString());
162
+ throw new DateTimeException(`Illegal value for DayOfMonth field, value ${dayOfMonth
163
+ } is not valid for month ${month.toString()}`);
164
164
  }
165
165
  return new MonthDay(month.value(), dayOfMonth);
166
166
  }
@@ -217,8 +217,8 @@ export class MonthDay extends TemporalAccessor {
217
217
  }*/
218
218
  return MonthDay.of(temporal.get(ChronoField.MONTH_OF_YEAR), temporal.get(ChronoField.DAY_OF_MONTH));
219
219
  } catch (ex) {
220
- throw new DateTimeException('Unable to obtain MonthDay from TemporalAccessor: ' +
221
- temporal + ', type ' + (temporal && temporal.constructor != null ? temporal.constructor.name : ''));
220
+ throw new DateTimeException(`Unable to obtain MonthDay from TemporalAccessor: ${
221
+ temporal}, type ${temporal && temporal.constructor != null ? temporal.constructor.name : ''}`);
222
222
  }
223
223
  }
224
224
  //-----------------------------------------------------------------------
@@ -448,7 +448,7 @@ export class MonthDay extends TemporalAccessor {
448
448
  case ChronoField.DAY_OF_MONTH: return this._day;
449
449
  case ChronoField.MONTH_OF_YEAR: return this._month;
450
450
  }
451
- throw new UnsupportedTemporalTypeException('Unsupported field: ' + field);
451
+ throw new UnsupportedTemporalTypeException(`Unsupported field: ${field}`);
452
452
  }
453
453
  return field.getFrom(this);
454
454
  }
@@ -681,9 +681,9 @@ export class MonthDay extends TemporalAccessor {
681
681
  * @return {String} a string representation of this month-day, not null
682
682
  */
683
683
  toString() {
684
- return '--'
685
- + (this._month < 10 ? '0' : '') + this._month
686
- + (this._day < 10 ? '-0' : '-') + this._day;
684
+ return `--${
685
+ this._month < 10 ? '0' : ''}${this._month
686
+ }${this._day < 10 ? '-0' : '-'}${this._day}`;
687
687
  }
688
688
 
689
689
  /**
@@ -4,32 +4,32 @@
4
4
  * @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
5
5
  */
6
6
 
7
- import {ChronoField} from './temporal/ChronoField';
8
- import {ChronoUnit} from './temporal/ChronoUnit';
9
- import {Clock} from './Clock';
10
- import {DateTimeFormatter} from './format/DateTimeFormatter';
11
- import {DefaultInterfaceTemporal} from './temporal/DefaultInterfaceTemporal';
12
- import {Instant} from './Instant';
13
- import {IsoChronology} from './chrono/IsoChronology';
14
- import {LocalDateTime} from './LocalDateTime';
15
- import {LocalDate} from './LocalDate';
16
- import {LocalTime} from './LocalTime';
17
- import {MathUtil} from './MathUtil';
18
- import {OffsetTime} from './OffsetTime';
19
- import {TemporalQueries} from './temporal/TemporalQueries';
20
- import {ZonedDateTime} from './ZonedDateTime';
21
- import {ZoneId} from './ZoneId';
22
- import {ZoneOffset} from './ZoneOffset';
23
- import {DateTimeException, IllegalArgumentException} from './errors';
24
-
25
- import {createTemporalQuery} from './temporal/TemporalQuery';
26
- import {requireInstance, requireNonNull} from './assert';
7
+ import { ChronoField } from './temporal/ChronoField';
8
+ import { ChronoUnit } from './temporal/ChronoUnit';
9
+ import { Temporal } from './temporal/Temporal';
10
+ import { Clock } from './Clock';
11
+ import { DateTimeFormatter } from './format/DateTimeFormatter';
12
+ import { Instant } from './Instant';
13
+ import { IsoChronology } from './chrono/IsoChronology';
14
+ import { LocalDateTime } from './LocalDateTime';
15
+ import { LocalDate } from './LocalDate';
16
+ import { LocalTime } from './LocalTime';
17
+ import { MathUtil } from './MathUtil';
18
+ import { OffsetTime } from './OffsetTime';
19
+ import { TemporalQueries } from './temporal/TemporalQueries';
20
+ import { ZonedDateTime } from './ZonedDateTime';
21
+ import { ZoneId } from './ZoneId';
22
+ import { ZoneOffset } from './ZoneOffset';
23
+ import { DateTimeException, IllegalArgumentException } from './errors';
24
+
25
+ import { createTemporalQuery } from './temporal/TemporalQuery';
26
+ import { requireInstance, requireNonNull } from './assert';
27
27
 
28
28
  /**
29
29
  * A date-time with an offset from UTC/Greenwich in the ISO-8601 calendar system,
30
30
  * such as 2007-12-23T10:15:30+01:00.
31
31
  */
32
- export class OffsetDateTime extends DefaultInterfaceTemporal {
32
+ export class OffsetDateTime extends Temporal {
33
33
  /**
34
34
  * @param {TemporaroAccessor} temporal
35
35
  * @return {OffsetDateTime}
@@ -169,7 +169,7 @@ export class OffsetDateTime extends DefaultInterfaceTemporal {
169
169
  }
170
170
 
171
171
  /**
172
- * @param {ZoneId}zone
172
+ * @param {ZoneId} zone
173
173
  * @return {ZonedDateTime}
174
174
  */
175
175
  atZoneSameInstant(zone) {
@@ -205,7 +205,7 @@ export class OffsetDateTime extends DefaultInterfaceTemporal {
205
205
  get(field) {
206
206
  if (field instanceof ChronoField) {
207
207
  switch (field) {
208
- case ChronoField.INSTANT_SECONDS: throw new DateTimeException('Field too large for an int: ' + field);
208
+ case ChronoField.INSTANT_SECONDS: throw new DateTimeException(`Field too large for an int: ${field}`);
209
209
  case ChronoField.OFFSET_SECONDS: return this.offset().totalSeconds();
210
210
  }
211
211
  return this._dateTime.get(field);
@@ -373,7 +373,7 @@ export class OffsetDateTime extends DefaultInterfaceTemporal {
373
373
  return field.rangeRefinedBy(this);
374
374
  }
375
375
 
376
- withAdjuster(adjuster) {
376
+ _withAdjuster(adjuster) {
377
377
  requireNonNull(adjuster);
378
378
  // optimizations
379
379
  if (adjuster instanceof LocalDate || adjuster instanceof LocalTime || adjuster instanceof LocalDateTime) {
@@ -388,7 +388,7 @@ export class OffsetDateTime extends DefaultInterfaceTemporal {
388
388
  return adjuster.adjustInto(this);
389
389
  }
390
390
 
391
- withFieldValue(field, newValue) {
391
+ _withField(field, newValue) {
392
392
  requireNonNull(field);
393
393
  if (field instanceof ChronoField) {
394
394
  const f = field;
@@ -505,12 +505,12 @@ export class OffsetDateTime extends DefaultInterfaceTemporal {
505
505
  return this._withDateTimeOffset(this._dateTime.truncatedTo(unit), this._offset);
506
506
  }
507
507
 
508
- plusAmount(amount) {
508
+ _plusAmount(amount) {
509
509
  requireNonNull(amount, 'amount');
510
510
  return amount.addTo(this);
511
511
  }
512
512
 
513
- plusAmountUnit(amountToAdd, unit) {
513
+ _plusUnit(amountToAdd, unit) {
514
514
  if (unit instanceof ChronoUnit) {
515
515
  return this._withDateTimeOffset(this._dateTime.plus(amountToAdd, unit), this._offset);
516
516
  }
@@ -581,12 +581,12 @@ export class OffsetDateTime extends DefaultInterfaceTemporal {
581
581
  return this._withDateTimeOffset(this._dateTime.plusNanos(nanos), this._offset);
582
582
  }
583
583
 
584
- minusAmount(amount) {
584
+ _minusAmount(amount) {
585
585
  requireNonNull(amount);
586
586
  return amount.subtractFrom(this);
587
587
  }
588
588
 
589
- minusAmountUnit(amountToSubtract, unit) {
589
+ _minusUnit(amountToSubtract, unit) {
590
590
  return this.plus(-1 * amountToSubtract, unit);
591
591
  }
592
592
 
package/src/OffsetTime.js CHANGED
@@ -4,26 +4,26 @@
4
4
  * @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
5
5
  */
6
6
 
7
- import {ChronoField} from './temporal/ChronoField';
8
- import {ChronoUnit} from './temporal/ChronoUnit';
9
- import {Clock} from './Clock';
10
- import {DateTimeException, UnsupportedTemporalTypeException} from './errors';
11
- import {DateTimeFormatter} from './format/DateTimeFormatter';
12
- import {DefaultInterfaceTemporal} from './temporal/DefaultInterfaceTemporal';
13
- import {Instant, LocalTime} from './js-joda';
14
- import {MathUtil} from './MathUtil';
15
- import {OffsetDateTime} from './OffsetDateTime';
16
- import {TemporalQueries} from './temporal/TemporalQueries';
17
- import {ZoneId} from './ZoneId';
18
- import {ZoneOffset} from './ZoneOffset';
19
-
20
- import {createTemporalQuery} from './temporal/TemporalQuery';
21
- import {requireInstance, requireNonNull} from './assert';
7
+ import { ChronoField } from './temporal/ChronoField';
8
+ import { ChronoUnit } from './temporal/ChronoUnit';
9
+ import { Temporal } from './temporal/Temporal';
10
+ import { Clock } from './Clock';
11
+ import { DateTimeException, UnsupportedTemporalTypeException } from './errors';
12
+ import { DateTimeFormatter } from './format/DateTimeFormatter';
13
+ import { Instant, LocalTime } from './js-joda';
14
+ import { MathUtil } from './MathUtil';
15
+ import { OffsetDateTime } from './OffsetDateTime';
16
+ import { TemporalQueries } from './temporal/TemporalQueries';
17
+ import { ZoneId } from './ZoneId';
18
+ import { ZoneOffset } from './ZoneOffset';
19
+
20
+ import { createTemporalQuery } from './temporal/TemporalQuery';
21
+ import { requireInstance, requireNonNull } from './assert';
22
22
 
23
23
  /**
24
24
  * A time with an offset from UTC/Greenwich in the ISO-8601 calendar system, such as 10:15:30+01:00.
25
25
  */
26
- export class OffsetTime extends DefaultInterfaceTemporal {
26
+ export class OffsetTime extends Temporal {
27
27
  /**
28
28
  * @param {!TemporalAccessor} temporal
29
29
  * @return {OffsetTime}
@@ -80,11 +80,11 @@ export class OffsetTime extends DefaultInterfaceTemporal {
80
80
  }
81
81
 
82
82
  /**
83
- * @param {int}hour
84
- * @param {int}minute
85
- * @param {int}second
86
- * @param {int}nanoOfSecond
87
- * @param {ZoneOffset}offset
83
+ * @param {int} hour
84
+ * @param {int} minute
85
+ * @param {int} second
86
+ * @param {int} nanoOfSecond
87
+ * @param {ZoneOffset} offset
88
88
  * @return {OffsetTime}
89
89
  */
90
90
  static ofNumbers(hour, minute, second, nanoOfSecond, offset) {
@@ -93,8 +93,8 @@ export class OffsetTime extends DefaultInterfaceTemporal {
93
93
  }
94
94
 
95
95
  /**
96
- * @param {LocalTime}time
97
- * @param {ZoneOffset}offset
96
+ * @param {LocalTime} time
97
+ * @param {ZoneOffset} offset
98
98
  * @return {OffsetTime}
99
99
  */
100
100
  static ofTimeAndOffset(time, offset) {
@@ -318,16 +318,16 @@ export class OffsetTime extends DefaultInterfaceTemporal {
318
318
  return this._withLocalTimeOffset(this._time.minusNanos(nanos), this._offset);
319
319
  }
320
320
 
321
- minusAmount(amount) {
321
+ _minusAmount(amount) {
322
322
  requireNonNull(amount);
323
323
  return amount.subtractFrom(this);
324
324
  }
325
325
 
326
- minusAmountUnit(amountToSubtract, unit) {
326
+ _minusUnit(amountToSubtract, unit) {
327
327
  return this.plus(-1 * amountToSubtract, unit);
328
328
  }
329
329
 
330
- plusAmount(amount) {
330
+ _plusAmount(amount) {
331
331
  requireNonNull(amount);
332
332
  return amount.addTo(this);
333
333
  }
@@ -338,7 +338,7 @@ export class OffsetTime extends DefaultInterfaceTemporal {
338
338
  * @param unit
339
339
  * @return {Temporal}
340
340
  */
341
- plusAmountUnit(amountToAdd, unit) {
341
+ _plusUnit(amountToAdd, unit) {
342
342
  if (unit instanceof ChronoUnit) {
343
343
  return this._withLocalTimeOffset(this._time.plus(amountToAdd, unit), this._offset);
344
344
  }
@@ -450,7 +450,7 @@ export class OffsetTime extends DefaultInterfaceTemporal {
450
450
  case ChronoUnit.HOURS: return Math.floor(nanosUntil / LocalTime.NANOS_PER_HOUR);
451
451
  case ChronoUnit.HALF_DAYS: return Math.floor(nanosUntil / (12 * LocalTime.NANOS_PER_HOUR));
452
452
  }
453
- throw new UnsupportedTemporalTypeException('Unsupported unit: ' + unit);
453
+ throw new UnsupportedTemporalTypeException(`Unsupported unit: ${unit}`);
454
454
  }
455
455
  return unit.between(this, end);
456
456
  }
@@ -515,7 +515,7 @@ export class OffsetTime extends DefaultInterfaceTemporal {
515
515
  return nod - offsetNanos;
516
516
  }
517
517
 
518
- withAdjuster(adjuster) {
518
+ _withAdjuster(adjuster) {
519
519
  requireNonNull(adjuster, 'adjuster');
520
520
  // optimizations
521
521
  if (adjuster instanceof LocalTime) {
@@ -528,7 +528,7 @@ export class OffsetTime extends DefaultInterfaceTemporal {
528
528
  return adjuster.adjustInto(this);
529
529
  }
530
530
 
531
- withFieldValue(field, newValue) {
531
+ _withField(field, newValue) {
532
532
  requireNonNull(field, 'field');
533
533
  if (field instanceof ChronoField) {
534
534
  if (field === ChronoField.OFFSET_SECONDS) {
@@ -541,8 +541,8 @@ export class OffsetTime extends DefaultInterfaceTemporal {
541
541
 
542
542
  /**
543
543
  * @private
544
- * @param {LocalTime}time
545
- * @param {ZoneOffset}offset
544
+ * @param {LocalTime} time
545
+ * @param {ZoneOffset} offset
546
546
  * @return {OffsetTime}
547
547
  */
548
548
  _withLocalTimeOffset(time, offset) {