@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.
@@ -5,6 +5,7 @@
5
5
  */
6
6
 
7
7
  import {TemporalAccessor} from './TemporalAccessor';
8
+ import { abstractMethodFail } from '../assert';
8
9
 
9
10
  /**
10
11
  * Framework-level interface defining read-write access to a temporal object,
@@ -60,4 +61,286 @@ import {TemporalAccessor} from './TemporalAccessor';
60
61
  *
61
62
  * @interface
62
63
  */
63
- export class Temporal extends TemporalAccessor {}
64
+ export class Temporal extends TemporalAccessor {
65
+ /**
66
+ * Checks if the specified unit is supported.
67
+ * This checks if the date-time can be queried for the specified unit. If false, then calling the plus and minus methods will throw an exception.
68
+
69
+ * ### Specification for implementors
70
+ * Implementations must check and handle all fields defined in {@link ChronoUnit}. If the field is supported, then true is returned, otherwise false
71
+ * If the field is not a {@link ChronoUnit}, then the result of this method is obtained by invoking `TemporalUnit.isSupportedBy(Temporal)` passing this as the argument.
72
+
73
+ * Implementations must not alter this object.
74
+
75
+ * @param {TemporalUnit} unit - the unit to check, null returns false
76
+ * @return {boolean} true if this date-time can be queried for the unit, false if not
77
+ */
78
+ // eslint-disable-next-line no-unused-vars
79
+ isSupported(unit) {
80
+ abstractMethodFail('isSupported');
81
+ }
82
+
83
+ /**
84
+ * function overloading for {@link Temporal.plus}
85
+ *
86
+ * Called with 1 (or less) arguments, p1 is expected to be a {@link TemporalAmount} and {@link Temporal.minusAmount} is called.
87
+ *
88
+ * Otherwise {@link Temporal.minusAmountUnit} is called.
89
+ *
90
+ * @param {!(TemporalAmount|number)} p1
91
+ * @param {TemporalUnit} p2
92
+ * @return {Temporal}
93
+ */
94
+ // eslint-disable-next-line no-unused-vars
95
+ minus(p1, p2) {
96
+ if (arguments.length < 2) {
97
+ return this.minusAmount(p1);
98
+ } else {
99
+ return this.minusAmountUnit(p1, p2);
100
+ }
101
+ }
102
+
103
+ /**
104
+ * Returns an object of the same type as this object with an amount subtracted.
105
+ * This adjusts this temporal, subtracting according to the rules of the specified amount. The
106
+ * amount is typically a {@link Period} but may be any other type implementing the {@link TemporalAmount} interface, such as Duration.
107
+ *
108
+ * Some example code indicating how and why this method is used:
109
+ *
110
+ * <pre>
111
+ * date = date.minus(period); // subtract a Period instance
112
+ * date = date.minus(duration); // subtract a Duration instance
113
+ * date = date.minus(workingDays(6)); // example user-written workingDays method
114
+ * </pre>
115
+ *
116
+ * Note that calling plus followed by minus is not guaranteed to return the same date-time.
117
+ *
118
+ * ### Specification for implementors
119
+ * Implementations must not alter either this object. Instead, an adjusted copy of the original
120
+ * must be returned. This provides equivalent, safe behavior for immutable and mutable
121
+ * implementations.
122
+ *
123
+ * @param {TemporalAmount} amount - the amount to subtract, not null
124
+ * @return {Temporal} an object of the same type with the specified adjustment made, not null
125
+ * @throws DateTimeException - if the subtraction cannot be made
126
+ * @throws ArithmeticException - if numeric overflow occurs
127
+ */
128
+ // eslint-disable-next-line no-unused-vars
129
+ minusAmount(amount) {
130
+ abstractMethodFail('minusAmount');
131
+ }
132
+
133
+ /**
134
+ * Returns an object of the same type as this object with the specified period subtracted.
135
+ * This method returns a new object based on this one with the specified period subtracted. For example, on a {@link LocalDate}, this could be used to subtract a number of years, months or days. The returned object will have the same observable type as this object.
136
+ *
137
+ * In some cases, changing a field is not fully defined. For example, if the target object is a date representing the 31st March, then subtracting one month would be unclear. In cases like this, the field is responsible for resolving the result. Typically it will choose the previous valid date, which would be the last valid day of February in this example.
138
+ *
139
+ * If the implementation represents a date-time that has boundaries, such {@link as} LocalTime, then the permitted units must include the boundary unit, but no multiples of the boundary unit. For example, {@link LocalTime} must accept `DAYS` but not `WEEKS` or `MONTHS`.
140
+ *
141
+ * ### Specification for implementors
142
+ * Implementations must behave in a manor equivalent to the default method behavior.
143
+ * Implementations must not alter either this object or the specified temporal object. Instead, an adjusted copy of the original must be returned. This provides equivalent, safe behavior for immutable and mutable implementations.
144
+ *
145
+ * @param {number} amountToSubtract - the amount of the specified unit to subtract, may be negative
146
+ * @param {TemporalUnit} unit - the unit of the period to subtract, not null
147
+ * @return {Temporal} an object of the same type with the specified period subtracted, not null
148
+ * @throws DateTimeException - if the unit cannot be subtracted
149
+ * @throws ArithmeticException - if numeric overflow occurs
150
+ */
151
+ // eslint-disable-next-line no-unused-vars
152
+ minusAmountUnit(amountToSubtract, unit) {
153
+ abstractMethodFail('minusAmountUnit');
154
+ }
155
+
156
+ /**
157
+ * function overloading for {@link Temporal.plus}
158
+ *
159
+ * Called with 1 (or less) arguments, p1 is expected to be a {@link TemporalAmount} and {@link Temporal.plusAmount} is called.
160
+ *
161
+ * Otherwise {@link Temporal.plusAmountUnit} is called.
162
+ *
163
+ * @param {!(TemporalAmount|number)} p1
164
+ * @param {TemporalUnit} p2
165
+ * @return {Temporal}
166
+ */
167
+ // eslint-disable-next-line no-unused-vars
168
+ plus(p1, p2) {
169
+ if (arguments.length < 2) {
170
+ return this.plusAmount(p1);
171
+ } else {
172
+ return this.plusAmountUnit(p1, p2);
173
+ }
174
+ }
175
+
176
+ /**
177
+ * Returns an object of the same type as this object with an amount added.
178
+ * This adjusts this temporal, adding according to the rules of the specified amount. The amount is typically a {@link Period} but may be any other type implementing the {@link TemporalAmount} interface, such as {@link Duration}.
179
+ *
180
+ * Some example code indicating how and why this method is used:
181
+ *
182
+ * <pre>
183
+ * date = date.plus(period); // add a Period instance
184
+ * date = date.plus(duration); // add a Duration instance
185
+ * date = date.plus(workingDays(6)); // example user-written workingDays method
186
+ * </pre>
187
+ *
188
+ * Note that calling plus followed by minus is not guaranteed to return the same date-time.
189
+ *
190
+ * ### Specification for implementors
191
+ * Implementations must not alter either this object. Instead, an adjusted copy of the original must be returned. This provides equivalent, safe behavior for immutable and mutable implementations.
192
+ *
193
+ * @param {TemporalAmount} amount - the amount to add, not null
194
+ * @return {Temporal} an object of the same type with the specified adjustment made, not null
195
+ * @throws DateTimeException - if the addition cannot be made
196
+ * @throws ArithmeticException - if numeric overflow occurs
197
+ */
198
+ // eslint-disable-next-line no-unused-vars
199
+ plusAmount(amount) {
200
+ abstractMethodFail('plusAmount');
201
+ }
202
+
203
+ /**
204
+ * Returns an object of the same type as this object with the specified period added.
205
+ * This method returns a new object based on this one with the specified period added. For example, on a {@link LocalDate}, this could be used to add a number of years, months or days. The returned object will have the same observable type as this object.
206
+ *
207
+ * In some cases, changing a field is not fully defined. For example, if the target object is a date representing the 31st January, then adding one month would be unclear. In cases like this, the field is responsible for resolving the result. Typically it will choose the previous valid date, which would be the last valid day of February in this example.
208
+ *
209
+ * If the implementation represents a date-time that has boundaries, such as {@link LocalTime}, then the permitted units must include the boundary unit, but no multiples of the boundary unit. For example, {@link LocalTime} must accept `DAYS` but not `WEEKS` or `MONTHS`.
210
+ *
211
+ * ### Specification for implementors
212
+ * Implementations must check and handle all units defined in {@link ChronoUnit}. If the unit is supported, then the addition must be performed. If unsupported, then a {@link DateTimeException} must be thrown.
213
+ * If the unit is not a {@link ChronoUnit}, then the result of this method is obtained by invoking `TemporalUnit.addTo(Temporal, long)` passing this as the first argument.
214
+ *
215
+ * Implementations must not alter either this object or the specified temporal object. Instead, an adjusted copy of the original must be returned. This provides equivalent, safe behavior for immutable and mutable implementations.
216
+ *
217
+ * @param {number} amountToAdd - the amount of the specified unit to add, may be negative
218
+ * @param {TemporalUnit} unit - the unit of the period to add, not null
219
+ * @return {Temporal} an object of the same type with the specified period added, not null
220
+ * @throws DateTimeException - if the unit cannot be added
221
+ * @throws ArithmeticException - if numeric overflow occurs
222
+ */
223
+ // eslint-disable-next-line no-unused-vars
224
+ plusAmountUnit(amountToAdd, unit) {
225
+ abstractMethodFail('plusAmountUnit');
226
+ }
227
+
228
+ /**
229
+ * Calculates the period between this temporal and another temporal in terms of the specified unit.
230
+ * This calculates the period between two temporals in terms of a single unit. The start and end points are this and the specified temporal. The result will be negative if the end is before the start. For example, the period in hours between two temporal objects can be calculated using `startTime.until(endTime, HOURS)`.
231
+ *
232
+ * The calculation returns a whole number, representing the number of complete units between the two temporals. For example, the period in hours between the times 11:30 and 13:29 will only be one hour as it is one minute short of two hours.
233
+ *
234
+ * 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)`:
235
+ *
236
+ * <pre>
237
+ * // these two lines are equivalent
238
+ * between = thisUnit.between(start, end);
239
+ * between = start.until(end, thisUnit);
240
+ * </pre>
241
+ *
242
+ * The choice should be made based on which makes the code more readable.
243
+ * For example, this method allows the number of days between two dates to be calculated:
244
+ *
245
+ * <pre>
246
+ * long daysBetween = DAYS.between(start, end);
247
+ * // or alternatively
248
+ * long daysBetween = start.until(end, DAYS);
249
+ * </pre>
250
+ *
251
+ * ### Specification for implementors
252
+ * 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}. A {@link DateTimeException} must be thrown for {@link ChronoUnit} instances that are unsupported.
253
+ * 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 input temporal as the second argument.
254
+ *
255
+ * In summary, implementations must behave in a manner equivalent to this code:
256
+ *
257
+ * <pre>
258
+ * // check input temporal is the same type as this class
259
+ * if (unit instanceof ChronoUnit) {
260
+ * // if unit is supported, then calculate and return result
261
+ * // else throw DateTimeException for unsupported units
262
+ * }
263
+ * return unit.between(this, endTemporal);
264
+ * </pre>
265
+ *
266
+ * The target object must not be altered by this method.
267
+ *
268
+ * @param {Temporal} endTemporal - the end temporal, of the same type as this object, not null
269
+ * @param {TemporalUnit} unit - the unit to measure the period in, not null
270
+ * @return {number} the amount of the period between this and the end
271
+ * @throws DateTimeException - if the period cannot be calculated
272
+ * @throws ArithmeticException - if numeric overflow occurs
273
+ */
274
+ // eslint-disable-next-line no-unused-vars
275
+ until(endTemporal, unit) {
276
+ abstractMethodFail('until');
277
+ }
278
+
279
+ /**
280
+ * function overloading for {@link Temporal.with}
281
+ *
282
+ * Called with 1 (or less) arguments, p1 is expected to be a {@link TemporalAdjuster} and {@link Temporal.withAdjuster} is called.
283
+ *
284
+ * Otherwise {@link Temporal.withFieldValue} is called.
285
+ *
286
+ * @param {!(TemporalAdjuster|TemporalField)} p1
287
+ * @param {number} p2
288
+ * @return {Temporal}
289
+ */
290
+ // eslint-disable-next-line no-unused-vars
291
+ with(p1, p2) {
292
+ if (arguments.length < 2) {
293
+ return this.withAdjuster(p1);
294
+ } else {
295
+ return this.withFieldValue(p1, p2);
296
+ }
297
+ }
298
+
299
+ /**
300
+ * Returns an adjusted object of the same type as this object with the adjustment made.
301
+ * This adjusts this date-time according to the rules of the specified adjuster. A simple adjuster might simply set the one of the fields, such as the year field. A more complex adjuster might set the date to the last day of the month. A selection of common adjustments is provided in {@link TemporalAdjusters}. These include finding the "last day of the month" and "next Wednesday". The adjuster is responsible for handling special cases, such as the varying lengths of month and leap years.
302
+ *
303
+ * Some example code indicating how and why this method is used:
304
+ *
305
+ * <pre>
306
+ * date = date.with(Month.JULY); // most key classes implement TemporalAdjuster
307
+ * date = date.with(lastDayOfMonth()); // static import from TemporalAdjusters
308
+ * date = date.with(next(WEDNESDAY)); // static import from TemporalAdjusters and DayOfWeek
309
+ * </pre>
310
+ *
311
+ * ### Specification for implementors
312
+ * Implementations must not alter either this object. Instead, an adjusted copy of the original must be returned. This provides equivalent, safe behavior for immutable and mutable implementations.
313
+ *
314
+ * @param {TemporalAdjuster} adjuster - the adjuster to use, not null
315
+ * @return {Temporal} an object of the same type with the specified adjustment made, not null
316
+ * @throws DateTimeException - if unable to make the adjustment
317
+ * @throws ArithmeticException - if numeric overflow occurs
318
+ */
319
+ // eslint-disable-next-line no-unused-vars
320
+ withAdjuster(adjuster) {
321
+ abstractMethodFail('withAdjuster');
322
+ }
323
+
324
+ /**
325
+ * Returns an object of the same type as this object with the specified field altered.
326
+ * This returns a new object based on this one with the value for the specified field changed. For example, on a {@link LocalDate}, this could be used to set the year, month or day-of-month. The returned object will have the same observable type as this object.
327
+ *
328
+ * In some cases, changing a field is not fully defined. For example, if the target object is a date representing the 31st January, then changing the month to February would be unclear. In cases like this, the field is responsible for resolving the result. Typically it will choose the previous valid date, which would be the last valid day of February in this example.
329
+ *
330
+ * ### Specification for implementors
331
+ * Implementations must check and handle all fields defined in {@link ChronoField}. If the field is supported, then the adjustment must be performed. If unsupported, then a {@link DateTimeException} must be thrown.
332
+ * If the field is not a {@link ChronoField}, then the result of this method is obtained by invoking `TemporalField.adjustInto(Temporal, long)` passing this as the first argument.
333
+ *
334
+ * Implementations must not alter either this object or the specified temporal object. Instead, an adjusted copy of the original must be returned. This provides equivalent, safe behavior for immutable and mutable implementations.
335
+ *
336
+ * @param {TemporalField} field - the field to set in the result, not null
337
+ * @param {number} newValue - the new value of the field in the result
338
+ * @return {Temporal} an object of the same type with the specified field set, not null
339
+ * @throws DateTimeException - if the field cannot be set
340
+ * @throws ArithmeticException - if numeric overflow occurs
341
+ */
342
+ // eslint-disable-next-line no-unused-vars
343
+ withFieldValue(field, newValue) {
344
+ abstractMethodFail('withFieldValue');
345
+ }
346
+ }
@@ -1,3 +1,5 @@
1
+ import { abstractMethodFail } from '../assert';
2
+
1
3
  /**
2
4
  * @copyright (c) 2016, Philipp Thürwächter & Pattrick Hüper
3
5
  * @copyright (c) 2007-present, Stephen Colebourne & Michael Nascimento Santos
@@ -21,4 +23,226 @@
21
23
  *
22
24
  * @interface
23
25
  */
24
- export class TemporalField {}
26
+ export class TemporalField {
27
+ /**
28
+ * Checks if this field represents a component of a date.
29
+ *
30
+ * @return {boolean} `true` if it is a component of a date, `false` otherwise.
31
+ */
32
+ isDateBased() {
33
+ abstractMethodFail('isDateBased');
34
+ }
35
+
36
+ /**
37
+ * Checks if this field represents a component of a time.
38
+ *
39
+ * @return {boolean} `true` if it is a component of a time, `false` otherwise.
40
+ */
41
+ isTimeBased() {
42
+ abstractMethodFail('isTimeBased');
43
+ }
44
+
45
+ /**
46
+ * Gets the unit that the field is measured in.
47
+ *
48
+ * The unit of the field is the period that varies within the range.
49
+ * For example, in the field 'MonthOfYear', the unit is 'Months'.
50
+ * See also {@link rangeUnit}.
51
+ *
52
+ * @return {TemporalUnit} the period unit defining the base unit of the field.
53
+ */
54
+ baseUnit() {
55
+ abstractMethodFail('baseUnit');
56
+ }
57
+
58
+ /**
59
+ * Gets the range that the field is bound by.
60
+ *
61
+ * The range of the field is the period that the field varies within.
62
+ * For example, in the field 'MonthOfYear', the range is 'Years'.
63
+ * See also {@link baseUnit}.
64
+ *
65
+ * The range is never null. For example, the 'Year' field is shorthand for
66
+ * 'YearOfForever'. It therefore has a unit of 'Years' and a range of 'Forever'.
67
+ *
68
+ * @return {TemporalUnit} the period unit defining the range of the field.
69
+ */
70
+ rangeUnit() {
71
+ abstractMethodFail('rangeUnit');
72
+ }
73
+
74
+ /**
75
+ * Gets the range of valid values for the field.
76
+ *
77
+ * All fields can be expressed as an integer.
78
+ * This method returns an object that describes the valid range for that value.
79
+ * This method is generally only applicable to the ISO-8601 calendar system.
80
+ *
81
+ * Note that the result only describes the minimum and maximum valid values
82
+ * and it is important not to read too much into them. For example, there
83
+ * could be values within the range that are invalid for the field.
84
+ *
85
+ * @return {ValueRange} the range of valid values for the field.
86
+ */
87
+ range() {
88
+ abstractMethodFail('range');
89
+ }
90
+
91
+ /**
92
+ * Get the range of valid values for this field using the temporal object to
93
+ * refine the result.
94
+ *
95
+ * This uses the temporal object to find the range of valid values for the field.
96
+ * This is similar to {@link range}, however this method refines the result
97
+ * using the temporal. For example, if the field is {@link DAY_OF_MONTH} the
98
+ * {@link range} method is not accurate as there are four possible month lengths,
99
+ * 28, 29, 30 and 31 days. Using this method with a date allows the range to be
100
+ * accurate, returning just one of those four options.
101
+ *
102
+ * There are two equivalent ways of using this method.
103
+ * The first is to invoke this method directly.
104
+ * The second is to use {@link TemporalAccessor#range}:
105
+ * <pre>
106
+ * // these two lines are equivalent, but the second approach is recommended
107
+ * temporal = thisField.rangeRefinedBy(temporal);
108
+ * temporal = temporal.range(thisField);
109
+ * </pre>
110
+ * It is recommended to use the second approach, {@link range},
111
+ * as it is a lot clearer to read in code.
112
+ *
113
+ * Implementations should perform any queries or calculations using the fields
114
+ * available in {@link ChronoField}.
115
+ * If the field is not supported a {@link DateTimeException} must be thrown.
116
+ *
117
+ * @param {!TemporalAccessor} temporal the temporal object used to refine the result.
118
+ * @return {ValueRange} the range of valid values for this field.
119
+ * @throws {DateTimeException} if the range for the field cannot be obtained.
120
+ *
121
+ */
122
+ // eslint-disable-next-line no-unused-vars
123
+ rangeRefinedBy(temporal) {
124
+ abstractMethodFail('rangeRefinedBy');
125
+ }
126
+
127
+ /**
128
+ * Gets the value of this field from the specified temporal object.
129
+ *
130
+ * This queries the temporal object for the value of this field.
131
+ *
132
+ * There are two equivalent ways of using this method.
133
+ * The first is to invoke this method directly.
134
+ * The second is to use {@link TemporalAccessor#get}:
135
+ * <pre>
136
+ * // these two lines are equivalent, but the second approach is recommended
137
+ * temporal = thisField.getFrom(temporal);
138
+ * temporal = temporal.get(thisField);
139
+ * </pre>
140
+ * It is recommended to use the second approach, as it is a lot clearer to read in code.
141
+ *
142
+ * Implementations should perform any queries or calculations using the fields
143
+ * available in {@link ChronoField}.
144
+ * If the field is not supported a {@link DateTimeException} must be thrown.
145
+ *
146
+ * @param {!TemporalAccesor} temporal the temporal object to query.
147
+ * @return {number} the value of this field.
148
+ * @throws {DateTimeException} if a value for the field cannot be obtained.
149
+ */
150
+ // eslint-disable-next-line no-unused-vars
151
+ getFrom(temporal) {
152
+ abstractMethodFail('getFrom');
153
+ }
154
+
155
+ /**
156
+ * Returns a copy of the specified temporal object with the value of this field set.
157
+ *
158
+ * This returns a new temporal object based on the specified one with the value for
159
+ * this field changed. For example, on a {@link LocalDate}, this could be used to
160
+ * set the year, month or day-of-month.
161
+ * The returned object has the same observable type as the specified object.
162
+ *
163
+ * In some cases, changing a field is not fully defined. For example, if the target object is
164
+ * a date representing the 31st January, then changing the month to February would be unclear.
165
+ * In cases like this, the implementation is responsible for resolving the result.
166
+ * Typically it will choose the previous valid date, which would be the last valid
167
+ * day of February in this example.
168
+ *
169
+ * There are two equivalent ways of using this method.
170
+ * The first is to invoke this method directly.
171
+ * The second is to use {@link Temporal#with}:
172
+ * <pre>
173
+ * // these two lines are equivalent, but the second approach is recommended
174
+ * temporal = thisField.adjustInto(temporal);
175
+ * temporal = temporal.with(thisField);
176
+ * </pre>
177
+ * It is recommended to use the second approach, `with(temporal)`,
178
+ * as it is a lot clearer to read in code.
179
+ *
180
+ * Implementations should perform any queries or calculations using the fields
181
+ * available in {@link ChronoField}.
182
+ * If the field is not supported a {@link DateTimeException} must be thrown.
183
+ *
184
+ * Implementations must not alter the specified temporal object.
185
+ * Instead, an adjusted copy of the original must be returned.
186
+ * This provides equivalent, safe behavior for immutable and mutable implementations.
187
+ *
188
+ * @param {!Temporal} temporal the temporal object to adjust.
189
+ * @param {!number} newValue the new value of the field.
190
+ * @return {Temporal} the adjusted temporal object.
191
+ * @throws {DateTimeException} if the field cannot be set.
192
+ */
193
+ // eslint-disable-next-line no-unused-vars
194
+ adjustInto(temporal, newValue) {
195
+ abstractMethodFail('adjustInto');
196
+ }
197
+
198
+ /**
199
+ * Checks if this field is supported by the temporal object.
200
+ *
201
+ * This determines whether the temporal accessor supports this field.
202
+ * If this returns false, the the temporal cannot be queried for this field.
203
+ *
204
+ * There are two equivalent ways of using this method.
205
+ * The first is to invoke this method directly.
206
+ * The second is to use {@link TemporalAccessor#isSupported}:
207
+ * <pre>
208
+ * // these two lines are equivalent, but the second approach is recommended
209
+ * temporal = thisField.isSupportedBy(temporal);
210
+ * temporal = temporal.isSupported(thisField);
211
+ * </pre>
212
+ * It is recommended to use the second approach, `isSupported(temporal)`,
213
+ * as it is a lot clearer to read in code.
214
+ *
215
+ * Implementations should determine whether they are supported using the fields
216
+ * available in {@link ChronoField}.
217
+ *
218
+ * @param {!TemporalAccesor} temporal the temporal object to query.
219
+ * @return {boolean} `true` if the date-time can be queried for this field, `false` if not.
220
+ */
221
+ // eslint-disable-next-line no-unused-vars
222
+ isSupportedBy(temporal) {
223
+ abstractMethodFail('isSupportedBy');
224
+ }
225
+
226
+ /**
227
+ * @return {string}
228
+ */
229
+ displayName(/* TODO: locale */) {
230
+ abstractMethodFail('displayName');
231
+ }
232
+
233
+ /**
234
+ * @param {*} other
235
+ * @returns {boolean}
236
+ */
237
+ // eslint-disable-next-line no-unused-vars
238
+ equals(other) {
239
+ abstractMethodFail('equals');
240
+ }
241
+
242
+ /**
243
+ * @returns {string}
244
+ */
245
+ name() {
246
+ abstractMethodFail('name');
247
+ }
248
+ }
@@ -32,14 +32,14 @@ export class TemporalUnit {
32
32
  *
33
33
  * All units return a duration measured in standard nanoseconds from this method.
34
34
  * The duration will be positive and non-zero.
35
- * For example, an hour has a duration of `60 * 60 * 1,000,000,000ns`.
35
+ * For example, an hour has a duration of `60 * 60 * 1,000,000,000 ns`.
36
36
  *
37
37
  * Some units may return an accurate duration while others return an estimate.
38
38
  * For example, days have an estimated duration due to the possibility of
39
39
  * daylight saving time changes.
40
40
  * To determine if the duration is an estimate, use {@link isDurationEstimated}.
41
41
  *
42
- * @return {Duration} the duration of this unit, which may be an estimate, not null
42
+ * @return {Duration} the duration of this unit, which may be an estimate.
43
43
  */
44
44
  duration() {
45
45
  abstractMethodFail('duration');
@@ -54,7 +54,7 @@ export class TemporalUnit {
54
54
  * This method returns true if the duration is an estimate and false if it is
55
55
  * accurate. Note that accurate/estimated ignores leap seconds.
56
56
  *
57
- * @return {boolean} true if the duration is estimated, false if accurate
57
+ * @return {boolean} `true` if the duration is estimated, `false` if accurate.
58
58
  */
59
59
  isDurationEstimated() {
60
60
  abstractMethodFail('isDurationEstimated');
@@ -63,7 +63,7 @@ export class TemporalUnit {
63
63
  /**
64
64
  * Checks if this unit is date-based.
65
65
  *
66
- * @return {boolean} true if date-based
66
+ * @return {boolean} `true` if date unit, `false` if a time unit.
67
67
  */
68
68
  isDateBased() {
69
69
  abstractMethodFail('isDateBased');
@@ -72,7 +72,7 @@ export class TemporalUnit {
72
72
  /**
73
73
  * Checks if this unit is time-based.
74
74
  *
75
- * @return {boolean} true if time-based
75
+ * @return {boolean} `true` if time unit, `false` if a date unit.
76
76
  */
77
77
  isTimeBased() {
78
78
  abstractMethodFail('isTimeBased');
@@ -85,8 +85,8 @@ export class TemporalUnit {
85
85
  * This checks that the implementing date-time can add/subtract this unit.
86
86
  * This can be used to avoid throwing an exception.
87
87
  *
88
- * @param {Temporal} temporal the temporal object to check, not null
89
- * @return {boolean} true if the unit is supported
88
+ * @param {!Temporal} temporal the temporal object to check.
89
+ * @return {boolean} `true` if the unit is supported.
90
90
  */
91
91
  // eslint-disable-next-line no-unused-vars
92
92
  isSupportedBy(temporal) {
@@ -120,10 +120,10 @@ export class TemporalUnit {
120
120
  * Instead, an adjusted copy of the original must be returned.
121
121
  * This provides equivalent, safe behavior for immutable and mutable implementations.
122
122
  *
123
- * @param {Temporal} dateTime the temporal object to adjust, not null
124
- * @param {number} periodToAdd the period of this unit to add, positive or negative
125
- * @return {Temporal} the adjusted temporal object, not null
126
- * @throws DateTimeException if the period cannot be added
123
+ * @param {!Temporal} dateTime the temporal object to adjust.
124
+ * @param {number} periodToAdd the period of this unit to add, positive or negative.
125
+ * @return {Temporal} the adjusted temporal object.
126
+ * @throws DateTimeException if the period cannot be added.
127
127
  */
128
128
  // eslint-disable-next-line no-unused-vars
129
129
  addTo(dateTime, periodToAdd) {
@@ -141,7 +141,7 @@ export class TemporalUnit {
141
141
  * using {@link HOURS.between}.
142
142
  *
143
143
  * The calculation returns a whole number, representing the number of complete units between the two temporals.
144
- * For example, the period in hours between the times 11:30 and 13:29 will only b
144
+ * For example, the period in hours between the times 11:30 and 13:29 will only be
145
145
  * one hour as it is one minute short of two hours.
146
146
  *
147
147
  * There are two equivalent ways of using this method.
@@ -162,19 +162,18 @@ export class TemporalUnit {
162
162
  * </pre>
163
163
  * Implementations should perform any queries or calculations using the units available in
164
164
  * {@link ChronoUnit} or the fields available in {@link ChronoField}.
165
- * If the unit is not supported a DateTimeException must be thrown.
165
+ * If the unit is not supported a {@link DateTimeException} must be thrown.
166
166
  * Implementations must not alter the specified temporal objects.
167
167
  *
168
- * @param {Temporal} temporal1 the base temporal object, not null
169
- * @param {Temporal} temporal2 the other temporal object, not null
168
+ * @param {!Temporal} temporal1 the base temporal object.
169
+ * @param {!Temporal} temporal2 the other temporal object.
170
170
  * @return {number} the period between temporal1 and temporal2 in terms of this unit;
171
- * positive if temporal2 is later than temporal1, negative if earlier
172
- * @throws DateTimeException if the period cannot be calculated
173
- * @throws ArithmeticException if numeric overflow occurs
171
+ * positive if temporal2 is later than temporal1, negative if earlier.
172
+ * @throws DateTimeException if the period cannot be calculated.
173
+ * @throws ArithmeticException if numeric overflow occurs.
174
174
  */
175
175
  // eslint-disable-next-line no-unused-vars
176
176
  between(temporal1, temporal2) {
177
177
  abstractMethodFail('between');
178
178
  }
179
-
180
179
  }
@@ -115,6 +115,7 @@ export class ValueRange {
115
115
  }
116
116
  return assert(false, msg, DateTimeException);
117
117
  }
118
+ return value;
118
119
  }
119
120
 
120
121
  /**