@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
@@ -4,9 +4,9 @@
4
4
  * @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
5
5
  */
6
6
 
7
- import {requireNonNull} from '../../assert';
8
- import {IllegalArgumentException} from '../../errors';
9
- import {MathUtil} from '../../MathUtil';
7
+ import { requireNonNull } from '../../assert';
8
+ import { IllegalArgumentException } from '../../errors';
9
+ import { MathUtil } from '../../MathUtil';
10
10
 
11
11
  /**
12
12
  * TODO optimize FractionPrinterParser, fix documentation
@@ -27,17 +27,17 @@ export class FractionPrinterParser {
27
27
  constructor(field, minWidth, maxWidth, decimalPoint) {
28
28
  requireNonNull(field, 'field');
29
29
  if (field.range().isFixed() === false) {
30
- throw new IllegalArgumentException('Field must have a fixed set of values: ' + field);
30
+ throw new IllegalArgumentException(`Field must have a fixed set of values: ${field}`);
31
31
  }
32
32
  if (minWidth < 0 || minWidth > 9) {
33
- throw new IllegalArgumentException('Minimum width must be from 0 to 9 inclusive but was ' + minWidth);
33
+ throw new IllegalArgumentException(`Minimum width must be from 0 to 9 inclusive but was ${minWidth}`);
34
34
  }
35
35
  if (maxWidth < 1 || maxWidth > 9) {
36
- throw new IllegalArgumentException('Maximum width must be from 1 to 9 inclusive but was ' + maxWidth);
36
+ throw new IllegalArgumentException(`Maximum width must be from 1 to 9 inclusive but was ${maxWidth}`);
37
37
  }
38
38
  if (maxWidth < minWidth) {
39
- throw new IllegalArgumentException('Maximum width must exceed or equal the minimum width but ' +
40
- maxWidth + ' < ' + minWidth);
39
+ throw new IllegalArgumentException(`Maximum width must exceed or equal the minimum width but ${
40
+ maxWidth} < ${minWidth}`);
41
41
  }
42
42
  this.field = field;
43
43
  this.minWidth = minWidth;
@@ -132,7 +132,7 @@ export class FractionPrinterParser {
132
132
  const _range = range.maximum() - _min + 1;
133
133
  const _value = value - _min;
134
134
  const _scaled = MathUtil.intDiv((_value * 1000000000), _range);
135
- let fraction = '' + _scaled;
135
+ let fraction = `${_scaled}`;
136
136
  while(fraction.length < 9){
137
137
  fraction = zeroDigit + fraction;
138
138
  }
@@ -156,7 +156,7 @@ export class FractionPrinterParser {
156
156
 
157
157
  toString() {
158
158
  const decimal = (this.decimalPoint ? ',DecimalPoint' : '');
159
- return 'Fraction(' + this.field + ',' + this.minWidth + ',' + this.maxWidth + decimal + ')';
159
+ return `Fraction(${this.field},${this.minWidth},${this.maxWidth}${decimal})`;
160
160
  }
161
161
  }
162
162
 
@@ -4,13 +4,13 @@
4
4
  * @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
5
5
  */
6
6
 
7
- import {assert} from '../../assert';
8
- import {ArithmeticException, DateTimeException, IllegalArgumentException} from '../../errors';
9
- import {MathUtil} from '../../MathUtil';
7
+ import { assert } from '../../assert';
8
+ import { ArithmeticException, DateTimeException, IllegalArgumentException } from '../../errors';
9
+ import { MathUtil } from '../../MathUtil';
10
10
 
11
- import {IsoChronology} from '../../chrono/IsoChronology';
11
+ import { IsoChronology } from '../../chrono/IsoChronology';
12
12
 
13
- import {SignStyle} from '../SignStyle';
13
+ import { SignStyle } from '../SignStyle';
14
14
 
15
15
 
16
16
  const MAX_WIDTH = 15; // can't parse all numbers with more then 15 digits in javascript
@@ -79,11 +79,11 @@ export class NumberPrinterParser {
79
79
  }
80
80
  const value = this._getValue(context, contextValue);
81
81
  const symbols = context.symbols();
82
- let str = '' + Math.abs(value);
82
+ let str = `${Math.abs(value)}`;
83
83
  if (str.length > this._maxWidth) {
84
- throw new DateTimeException('Field ' + this._field +
85
- ' cannot be printed as the value ' + value +
86
- ' exceeds the maximum print width of ' + this._maxWidth);
84
+ throw new DateTimeException(`Field ${this._field
85
+ } cannot be printed as the value ${value
86
+ } exceeds the maximum print width of ${this._maxWidth}`);
87
87
  }
88
88
  str = symbols.convertNumberToI18N(str);
89
89
 
@@ -106,9 +106,9 @@ export class NumberPrinterParser {
106
106
  buf.append(symbols.negativeSign());
107
107
  break;
108
108
  case SignStyle.NOT_NEGATIVE:
109
- throw new DateTimeException('Field ' + this._field +
110
- ' cannot be printed as the value ' + value +
111
- ' cannot be negative according to the SignStyle');
109
+ throw new DateTimeException(`Field ${this._field
110
+ } cannot be printed as the value ${value
111
+ } cannot be negative according to the SignStyle`);
112
112
  }
113
113
  }
114
114
  for (let i = 0; i < this._minWidth - str.length; i++) {
@@ -230,12 +230,12 @@ export class NumberPrinterParser {
230
230
 
231
231
  toString() {
232
232
  if (this._minWidth === 1 && this._maxWidth === MAX_WIDTH && this._signStyle === SignStyle.NORMAL) {
233
- return 'Value(' + this._field + ')';
233
+ return `Value(${this._field})`;
234
234
  }
235
235
  if (this._minWidth === this._maxWidth && this._signStyle === SignStyle.NOT_NEGATIVE) {
236
- return 'Value(' + this._field + ',' + this._minWidth + ')';
236
+ return `Value(${this._field},${this._minWidth})`;
237
237
  }
238
- return 'Value(' + this._field + ',' + this._minWidth + ',' + this._maxWidth + ',' + this._signStyle + ')';
238
+ return `Value(${this._field},${this._minWidth},${this._maxWidth},${this._signStyle})`;
239
239
  }
240
240
 
241
241
  }
@@ -258,10 +258,10 @@ export class ReducedPrinterParser extends NumberPrinterParser {
258
258
  constructor(field, width, maxWidth, baseValue, baseDate) {
259
259
  super(field, width, maxWidth, SignStyle.NOT_NEGATIVE);
260
260
  if (width < 1 || width > 10) {
261
- throw new IllegalArgumentException('The width must be from 1 to 10 inclusive but was ' + width);
261
+ throw new IllegalArgumentException(`The width must be from 1 to 10 inclusive but was ${width}`);
262
262
  }
263
263
  if (maxWidth < 1 || maxWidth > 10) {
264
- throw new IllegalArgumentException('The maxWidth must be from 1 to 10 inclusive but was ' + maxWidth);
264
+ throw new IllegalArgumentException(`The maxWidth must be from 1 to 10 inclusive but was ${maxWidth}`);
265
265
  }
266
266
  if (maxWidth < width) {
267
267
  throw new IllegalArgumentException('The maxWidth must be greater than the width');
@@ -361,7 +361,7 @@ export class ReducedPrinterParser extends NumberPrinterParser {
361
361
  }
362
362
 
363
363
  toString() {
364
- return 'ReducedValue(' + this._field + ',' + this._minWidth + ',' + this._maxWidth + ',' + (this._baseDate != null ? this._baseDate : this._baseValue) + ')';
364
+ return `ReducedValue(${this._field},${this._minWidth},${this._maxWidth},${this._baseDate != null ? this._baseDate : this._baseValue})`;
365
365
  }
366
366
  }
367
367
 
@@ -4,11 +4,11 @@
4
4
  * @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
5
5
  */
6
6
 
7
- import {requireNonNull} from '../../assert';
8
- import {IllegalArgumentException} from '../../errors';
9
- import {MathUtil} from '../../MathUtil';
7
+ import { requireNonNull } from '../../assert';
8
+ import { IllegalArgumentException } from '../../errors';
9
+ import { MathUtil } from '../../MathUtil';
10
10
 
11
- import {ChronoField} from '../../temporal/ChronoField';
11
+ import { ChronoField } from '../../temporal/ChronoField';
12
12
 
13
13
  //-----------------------------------------------------------------------
14
14
  const PATTERNS = [
@@ -43,7 +43,7 @@ export class OffsetIdPrinterParser {
43
43
  return i;
44
44
  }
45
45
  }
46
- throw new IllegalArgumentException('Invalid zone offset pattern: ' + pattern);
46
+ throw new IllegalArgumentException(`Invalid zone offset pattern: ${pattern}`);
47
47
  }
48
48
 
49
49
  /**
@@ -66,14 +66,14 @@ export class OffsetIdPrinterParser {
66
66
  const bufPos = buf.length();
67
67
  let output = absHours;
68
68
  buf.append(totalSecs < 0 ? '-' : '+')
69
- .appendChar((MathUtil.intDiv(absHours, 10) + '0')).appendChar(MathUtil.intMod(absHours, 10) + '0');
69
+ .appendChar((`${MathUtil.intDiv(absHours, 10)}0`)).appendChar(`${MathUtil.intMod(absHours, 10)}0`);
70
70
  if (this.type >= 3 || (this.type >= 1 && absMinutes > 0)) {
71
71
  buf.append((this.type % 2) === 0 ? ':' : '')
72
- .appendChar((MathUtil.intDiv(absMinutes, 10) + '0')).appendChar((absMinutes % 10 + '0'));
72
+ .appendChar((`${MathUtil.intDiv(absMinutes, 10)}0`)).appendChar((`${absMinutes % 10}0`));
73
73
  output += absMinutes;
74
74
  if (this.type >= 7 || (this.type >= 5 && absSeconds > 0)) {
75
75
  buf.append((this.type % 2) === 0 ? ':' : '')
76
- .appendChar((MathUtil.intDiv(absSeconds, 10) + '0')).appendChar((absSeconds % 10 + '0'));
76
+ .appendChar((`${MathUtil.intDiv(absSeconds, 10)}0`)).appendChar((`${absSeconds % 10}0`));
77
77
  output += absSeconds;
78
78
  }
79
79
  }
@@ -169,7 +169,7 @@ export class OffsetIdPrinterParser {
169
169
 
170
170
  toString() {
171
171
  const converted = this.noOffsetText.replace('\'', '\'\'');
172
- return 'Offset(' + PATTERNS[this.type] + ',\'' + converted + '\')';
172
+ return `Offset(${PATTERNS[this.type]},'${converted}')`;
173
173
  }
174
174
  }
175
175
  OffsetIdPrinterParser.INSTANCE_ID = new OffsetIdPrinterParser('Z', '+HH:MM:ss');
@@ -4,9 +4,9 @@
4
4
  * @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
5
5
  */
6
6
 
7
- import {assert} from '../../assert';
7
+ import { assert } from '../../assert';
8
8
 
9
- import {DateTimeException} from '../../errors';
9
+ import { DateTimeException } from '../../errors';
10
10
 
11
11
  /**
12
12
  * Pads the output to a fixed width.
@@ -75,7 +75,7 @@ export class PadPrinterParserDecorator {
75
75
  }
76
76
 
77
77
  toString() {
78
- return `Pad(${this._printerParser},${this._padWidth}${(this._padChar === ' ' ? ')' : ',\'' + this._padChar + '\')')}`;
78
+ return `Pad(${this._printerParser},${this._padWidth}${(this._padChar === ' ' ? ')' : `,'${this._padChar}')`)}`;
79
79
  }
80
80
  }
81
81
 
@@ -4,7 +4,7 @@
4
4
  * @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
5
5
  */
6
6
 
7
- import {assert} from '../../assert';
7
+ import { assert } from '../../assert';
8
8
 
9
9
  /**
10
10
  * Prints or parses a string literal.
@@ -33,7 +33,7 @@ export class StringLiteralPrinterParser {
33
33
 
34
34
  toString() {
35
35
  const converted = this._literal.replace("'", "''");
36
- return '\'' + converted + '\'';
36
+ return `'${converted}'`;
37
37
  }
38
38
  }
39
39
 
@@ -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 {ZoneOffset} from '../../ZoneOffset';
8
- import {ZoneId} from '../../ZoneId';
9
- import {ZoneRegion} from '../../ZoneRegion';
7
+ import { ZoneOffset } from '../../ZoneOffset';
8
+ import { ZoneId } from '../../ZoneId';
9
+ import { ZoneRegion } from '../../ZoneRegion';
10
10
 
11
- import {ChronoField} from '../../temporal/ChronoField';
11
+ import { ChronoField } from '../../temporal/ChronoField';
12
12
 
13
13
  import { ZoneRulesProvider } from '../../zone/ZoneRulesProvider';
14
14
 
15
- import {OffsetIdPrinterParser} from './OffsetIdPrinterParser';
15
+ import { OffsetIdPrinterParser } from './OffsetIdPrinterParser';
16
16
 
17
17
  /**
18
18
  * Prints or parses a zone ID.
package/src/js-joda.js CHANGED
@@ -147,6 +147,11 @@ const jsJodaExports = {
147
147
  TextStyle,
148
148
  };
149
149
 
150
+ /**
151
+ * @private
152
+ *
153
+ * @type {function(*=): *}
154
+ */
150
155
  const use = bindUse(jsJodaExports);
151
156
  jsJodaExports.use = use;
152
157
 
@@ -4,12 +4,12 @@
4
4
  * @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
5
5
  */
6
6
 
7
- import {MAX_SAFE_INTEGER, MIN_SAFE_INTEGER} from '../MathUtil';
7
+ import { MAX_SAFE_INTEGER, MIN_SAFE_INTEGER } from '../MathUtil';
8
8
 
9
- import {ChronoUnit} from './ChronoUnit';
10
- import {TemporalField} from './TemporalField';
11
- import {ValueRange} from './ValueRange';
12
- import {YearConstants} from '../YearConstants';
9
+ import { ChronoUnit } from './ChronoUnit';
10
+ import { TemporalField } from './TemporalField';
11
+ import { ValueRange } from './ValueRange';
12
+ import { YearConstants } from '../YearConstants';
13
13
 
14
14
  /**
15
15
  * A standard set of fields.
@@ -4,11 +4,11 @@
4
4
  * @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
5
5
  */
6
6
 
7
- import {MathUtil} from '../MathUtil';
7
+ import { MathUtil } from '../MathUtil';
8
8
 
9
- import {Duration} from '../Duration';
10
- import {YearConstants} from '../YearConstants';
11
- import {TemporalUnit} from './TemporalUnit';
9
+ import { Duration } from '../Duration';
10
+ import { YearConstants } from '../YearConstants';
11
+ import { TemporalUnit } from './TemporalUnit';
12
12
 
13
13
  /**
14
14
  * A standard set of date periods units.
@@ -153,8 +153,8 @@ export class ChronoUnit extends TemporalUnit {
153
153
  }
154
154
 
155
155
  /**
156
- * @param {!Temporal} dateTime the temporal object to adjust.
157
- * @param {number} periodToAdd the period of this unit to add, positive or negative.
156
+ * @param {!Temporal} temporal the temporal object to adjust.
157
+ * @param {number} amount the period of this unit to add, positive or negative.
158
158
  * @return {Temporal} the adjusted temporal object.
159
159
  * @throws DateTimeException if the period cannot be added.
160
160
  */
@@ -4,22 +4,22 @@
4
4
  * @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
5
5
  */
6
6
 
7
- import {UnsupportedTemporalTypeException, IllegalStateException} from '../errors';
7
+ import { UnsupportedTemporalTypeException, IllegalStateException } from '../errors';
8
8
 
9
- import {DayOfWeek} from '../DayOfWeek';
10
- import {Duration} from '../Duration';
11
- import {MathUtil} from '../MathUtil';
12
- import {LocalDate} from '../LocalDate';
9
+ import { DayOfWeek } from '../DayOfWeek';
10
+ import { Duration } from '../Duration';
11
+ import { MathUtil } from '../MathUtil';
12
+ import { LocalDate } from '../LocalDate';
13
13
 
14
- import {ChronoField} from './ChronoField';
15
- import {ChronoUnit} from './ChronoUnit';
16
- import {TemporalField} from './TemporalField';
17
- import {TemporalUnit} from './TemporalUnit';
18
- import {ValueRange} from './ValueRange';
14
+ import { ChronoField } from './ChronoField';
15
+ import { ChronoUnit } from './ChronoUnit';
16
+ import { TemporalField } from './TemporalField';
17
+ import { TemporalUnit } from './TemporalUnit';
18
+ import { ValueRange } from './ValueRange';
19
19
 
20
- import {IsoChronology} from '../chrono/IsoChronology';
20
+ import { IsoChronology } from '../chrono/IsoChronology';
21
21
 
22
- import {ResolverStyle} from '../format/ResolverStyle';
22
+ import { ResolverStyle } from '../format/ResolverStyle';
23
23
 
24
24
  /**
25
25
  * Fields and units specific to the ISO-8601 calendar system,
@@ -3,18 +3,18 @@
3
3
  * @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
4
4
  */
5
5
 
6
- import {assert, requireNonNull} from '../assert';
7
- import {UnsupportedTemporalTypeException} from '../errors';
6
+ import { assert, requireNonNull } from '../assert';
7
+ import { UnsupportedTemporalTypeException } from '../errors';
8
8
 
9
- import {Instant} from '../Instant';
10
- import {LocalDate} from '../LocalDate';
11
- import {LocalTime} from '../LocalTime';
12
- import {MathUtil} from '../MathUtil';
13
- import {ZoneId} from '../ZoneId';
9
+ import { Instant } from '../Instant';
10
+ import { LocalDate } from '../LocalDate';
11
+ import { LocalTime } from '../LocalTime';
12
+ import { MathUtil } from '../MathUtil';
13
+ import { ZoneId } from '../ZoneId';
14
14
 
15
- import {ChronoField} from './ChronoField';
16
- import {TemporalQueries} from './TemporalQueries';
17
- import {TemporalAccessor} from './TemporalAccessor';
15
+ import { ChronoField } from './ChronoField';
16
+ import { TemporalQueries } from './TemporalQueries';
17
+ import { TemporalAccessor } from './TemporalAccessor';
18
18
 
19
19
  /**
20
20
  * A wrapper around a native javascript Date instance that
@@ -79,7 +79,7 @@ class NativeJsTemporal extends TemporalAccessor {
79
79
  case ChronoField.NANO_OF_SECOND: return MathUtil.floorMod(this._epochMilli, 1000) * 1000000;
80
80
  case ChronoField.INSTANT_SECONDS: return MathUtil.floorDiv(this._epochMilli, 1000);
81
81
  }
82
- throw new UnsupportedTemporalTypeException('Unsupported field: ' + field);
82
+ throw new UnsupportedTemporalTypeException(`Unsupported field: ${field}`);
83
83
  }
84
84
  return field.getFrom(this);
85
85
  }
@@ -4,8 +4,11 @@
4
4
  * @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
5
5
  */
6
6
 
7
- import {TemporalAccessor} from './TemporalAccessor';
8
- import { abstractMethodFail } from '../assert';
7
+ import { assert, abstractMethodFail, requireInstance, requireNonNull } from '../assert';
8
+ import { IllegalArgumentException } from '../errors';
9
+ import { TemporalAccessor } from './TemporalAccessor';
10
+ import { TemporalAmount } from './TemporalAmount';
11
+ import { TemporalUnit } from './TemporalUnit';
9
12
 
10
13
  /**
11
14
  * Framework-level interface defining read-write access to a temporal object,
@@ -72,11 +75,11 @@ export class Temporal extends TemporalAccessor {
72
75
 
73
76
  * Implementations must not alter this object.
74
77
 
75
- * @param {TemporalUnit} unit - the unit to check, null returns false
78
+ * @param {TemporalUnit} fieldOrUnit - the unit to check, null returns false
76
79
  * @return {boolean} true if this date-time can be queried for the unit, false if not
77
80
  */
78
81
  // eslint-disable-next-line no-unused-vars
79
- isSupported(unit) {
82
+ isSupported(fieldOrUnit) {
80
83
  abstractMethodFail('isSupported');
81
84
  }
82
85
 
@@ -87,16 +90,15 @@ export class Temporal extends TemporalAccessor {
87
90
  *
88
91
  * Otherwise {@link Temporal.minusAmountUnit} is called.
89
92
  *
90
- * @param {!(TemporalAmount|number)} p1
91
- * @param {TemporalUnit} p2
93
+ * @param {!(TemporalAmount|number)} amount
94
+ * @param {TemporalUnit} unit
92
95
  * @return {Temporal}
93
96
  */
94
- // eslint-disable-next-line no-unused-vars
95
- minus(p1, p2) {
97
+ minus(amount, unit) {
96
98
  if (arguments.length < 2) {
97
- return this.minusAmount(p1);
99
+ return this._minusAmount(amount);
98
100
  } else {
99
- return this.minusAmountUnit(p1, p2);
101
+ return this._minusUnit(amount, unit);
100
102
  }
101
103
  }
102
104
 
@@ -125,9 +127,10 @@ export class Temporal extends TemporalAccessor {
125
127
  * @throws DateTimeException - if the subtraction cannot be made
126
128
  * @throws ArithmeticException - if numeric overflow occurs
127
129
  */
128
- // eslint-disable-next-line no-unused-vars
129
- minusAmount(amount) {
130
- abstractMethodFail('minusAmount');
130
+ _minusAmount(amount) {
131
+ requireNonNull(amount, 'amount');
132
+ requireInstance(amount, TemporalAmount, 'amount');
133
+ return amount.subtractFrom(this);
131
134
  }
132
135
 
133
136
  /**
@@ -148,9 +151,11 @@ export class Temporal extends TemporalAccessor {
148
151
  * @throws DateTimeException - if the unit cannot be subtracted
149
152
  * @throws ArithmeticException - if numeric overflow occurs
150
153
  */
151
- // eslint-disable-next-line no-unused-vars
152
- minusAmountUnit(amountToSubtract, unit) {
153
- abstractMethodFail('minusAmountUnit');
154
+ _minusUnit(amountToSubtract, unit) {
155
+ requireNonNull(amountToSubtract, 'amountToSubtract');
156
+ requireNonNull(unit, 'unit');
157
+ requireInstance(unit, TemporalUnit, 'unit');
158
+ return this._plusUnit(-amountToSubtract, unit);
154
159
  }
155
160
 
156
161
  /**
@@ -160,16 +165,15 @@ export class Temporal extends TemporalAccessor {
160
165
  *
161
166
  * Otherwise {@link Temporal.plusAmountUnit} is called.
162
167
  *
163
- * @param {!(TemporalAmount|number)} p1
164
- * @param {TemporalUnit} p2
168
+ * @param {!(TemporalAmount|number)} amount
169
+ * @param {TemporalUnit} unit
165
170
  * @return {Temporal}
166
171
  */
167
- // eslint-disable-next-line no-unused-vars
168
- plus(p1, p2) {
172
+ plus(amount, unit) {
169
173
  if (arguments.length < 2) {
170
- return this.plusAmount(p1);
174
+ return this._plusAmount(amount);
171
175
  } else {
172
- return this.plusAmountUnit(p1, p2);
176
+ return this._plusUnit(amount, unit);
173
177
  }
174
178
  }
175
179
 
@@ -195,9 +199,10 @@ export class Temporal extends TemporalAccessor {
195
199
  * @throws DateTimeException - if the addition cannot be made
196
200
  * @throws ArithmeticException - if numeric overflow occurs
197
201
  */
198
- // eslint-disable-next-line no-unused-vars
199
- plusAmount(amount) {
200
- abstractMethodFail('plusAmount');
202
+ _plusAmount(amount) {
203
+ requireNonNull(amount, 'amount');
204
+ requireInstance(amount, TemporalAmount, 'amount');
205
+ return amount.addTo(this);
201
206
  }
202
207
 
203
208
  /**
@@ -221,8 +226,8 @@ export class Temporal extends TemporalAccessor {
221
226
  * @throws ArithmeticException - if numeric overflow occurs
222
227
  */
223
228
  // eslint-disable-next-line no-unused-vars
224
- plusAmountUnit(amountToAdd, unit) {
225
- abstractMethodFail('plusAmountUnit');
229
+ _plusUnit(amountToAdd, unit) {
230
+ abstractMethodFail('_plusUnit');
226
231
  }
227
232
 
228
233
  /**
@@ -283,16 +288,15 @@ export class Temporal extends TemporalAccessor {
283
288
  *
284
289
  * Otherwise {@link Temporal.withFieldValue} is called.
285
290
  *
286
- * @param {!(TemporalAdjuster|TemporalField)} p1
287
- * @param {number} p2
291
+ * @param {!(TemporalAdjuster|TemporalField)} adjusterOrField
292
+ * @param {number} newValue
288
293
  * @return {Temporal}
289
294
  */
290
- // eslint-disable-next-line no-unused-vars
291
- with(p1, p2) {
295
+ with(adjusterOrField, newValue) {
292
296
  if (arguments.length < 2) {
293
- return this.withAdjuster(p1);
297
+ return this._withAdjuster(adjusterOrField);
294
298
  } else {
295
- return this.withFieldValue(p1, p2);
299
+ return this._withField(adjusterOrField, newValue);
296
300
  }
297
301
  }
298
302
 
@@ -316,9 +320,12 @@ export class Temporal extends TemporalAccessor {
316
320
  * @throws DateTimeException - if unable to make the adjustment
317
321
  * @throws ArithmeticException - if numeric overflow occurs
318
322
  */
319
- // eslint-disable-next-line no-unused-vars
320
- withAdjuster(adjuster) {
321
- abstractMethodFail('withAdjuster');
323
+ _withAdjuster(adjuster) {
324
+ requireNonNull(adjuster, 'adjuster');
325
+ assert(typeof adjuster.adjustInto === 'function',
326
+ 'adjuster must be a TemporalAdjuster',
327
+ IllegalArgumentException);
328
+ return adjuster.adjustInto(this);
322
329
  }
323
330
 
324
331
  /**
@@ -340,7 +347,7 @@ export class Temporal extends TemporalAccessor {
340
347
  * @throws ArithmeticException - if numeric overflow occurs
341
348
  */
342
349
  // eslint-disable-next-line no-unused-vars
343
- withFieldValue(field, newValue) {
344
- abstractMethodFail('withFieldValue');
350
+ _withField(field, newValue) {
351
+ abstractMethodFail('_withField');
345
352
  }
346
353
  }
@@ -4,10 +4,11 @@
4
4
  * @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
5
5
  */
6
6
 
7
- import {UnsupportedTemporalTypeException} from '../errors';
7
+ import { UnsupportedTemporalTypeException } from '../errors';
8
+ import { abstractMethodFail } from '../assert';
8
9
 
9
- import {ChronoField} from './ChronoField';
10
- import {TemporalQueries} from './TemporalQueries';
10
+ import { ChronoField } from './ChronoField';
11
+ import { TemporalQueries } from './TemporalQueries';
11
12
 
12
13
  export class TemporalAccessor {
13
14
  /**
@@ -83,6 +84,11 @@ export class TemporalAccessor {
83
84
  return this.range(field).checkValidIntValue(this.getLong(field), field);
84
85
  }
85
86
 
87
+ // eslint-disable-next-line no-unused-vars
88
+ getLong(field) {
89
+ abstractMethodFail('getLong');
90
+ }
91
+
86
92
  /**
87
93
  * Gets the range of valid values for the specified field.
88
94
  *
@@ -117,9 +123,13 @@ export class TemporalAccessor {
117
123
  if (this.isSupported(field)) {
118
124
  return field.range();
119
125
  }
120
- throw new UnsupportedTemporalTypeException('Unsupported field: ' + field);
126
+ throw new UnsupportedTemporalTypeException(`Unsupported field: ${field}`);
121
127
  }
122
128
  return field.rangeRefinedBy(this);
123
129
  }
124
130
 
131
+ // eslint-disable-next-line no-unused-vars
132
+ isSupported(field) {
133
+ abstractMethodFail('isSupported');
134
+ }
125
135
  }
@@ -4,7 +4,7 @@
4
4
  * @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
5
5
  */
6
6
 
7
- import {abstractMethodFail} from '../assert';
7
+ import { abstractMethodFail } from '../assert';
8
8
 
9
9
  /**
10
10
  * Strategy for adjusting a temporal object.
@@ -4,13 +4,13 @@
4
4
  * @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
5
5
  */
6
6
 
7
- import {requireNonNull} from '../assert';
8
- import {IllegalStateException} from '../errors';
7
+ import { requireNonNull } from '../assert';
8
+ import { IllegalStateException } from '../errors';
9
9
 
10
- import {TemporalAdjuster} from './TemporalAdjuster';
11
- import {ChronoField} from '../temporal/ChronoField';
12
- import {ChronoUnit} from '../temporal/ChronoUnit';
13
- import {MathUtil} from '../MathUtil';
10
+ import { TemporalAdjuster } from './TemporalAdjuster';
11
+ import { ChronoField } from '../temporal/ChronoField';
12
+ import { ChronoUnit } from '../temporal/ChronoUnit';
13
+ import { MathUtil } from '../MathUtil';
14
14
 
15
15
  /**
16
16
  * Common implementations of {@link TemporalAdjuster}.
@@ -4,7 +4,7 @@
4
4
  * @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
5
5
  */
6
6
 
7
- import {abstractMethodFail} from '../assert';
7
+ import { abstractMethodFail } from '../assert';
8
8
 
9
9
  /**
10
10
  * Framework-level interface defining an amount of time, such as