@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@js-joda/core",
3
- "version": "3.2.0",
3
+ "version": "4.2.1",
4
4
  "description": "a date and time library for javascript",
5
5
  "repository": {
6
6
  "type": "git",
@@ -18,17 +18,17 @@
18
18
  "README.md"
19
19
  ],
20
20
  "scripts": {
21
- "prepublish": "npm run build-dist",
22
- "test": "NODE_ENV=test ./node_modules/.bin/mocha --timeout 5000 --require @babel/register ./test/*Test_mochaOnly.js ./test/*Test.js ./test/**/*Test.js ./test/**/**/*Test.js",
23
- "test-coverage": "NODE_ENV=test COVERAGE=1 ../../node_modules/.bin/nyc --report-dir=build/coverage --reporter=lcov --reporter html ./node_modules/.bin/mocha --timeout 5000 --require @babel/register --reporter progress ./test/*Test.js ./test/**/*Test.js ./test/**/**/*Test.js",
24
- "test-browser": "./node_modules/.bin/karma start --reporters=dots --single-run",
25
- "test-saucelabs": "./node_modules/.bin/karma start --reporters=\"dots,saucelabs\" --browsers=\"sl_chrome,sl_ie,sl_firefox,sl_ios_simulator\" --single-run=true",
26
- "test-ci": "npm run build-dist && npm run test && npm run test-browser -- --browsers \"Firefox,PhantomJS\" && npm run test-ts-definitions && npm run test-coverage",
21
+ "version": "npm run build-dist",
22
+ "test": "NODE_ENV=test npx mocha --timeout 5000 --require @babel/register ./test/*Test_mochaOnly.js ./test/*Test.js ./test/**/*Test.js ./test/**/**/*Test.js",
23
+ "test-coverage": "NODE_ENV=test COVERAGE=1 npx nyc --report-dir=build/coverage --reporter=lcov --reporter html npx mocha --timeout 5000 --require @babel/register --reporter progress ./test/*Test.js ./test/**/*Test.js ./test/**/**/*Test.js",
24
+ "test-browser": "npx karma start --reporters=dots --single-run",
25
+ "test-saucelabs": "npx karma start --reporters=\"dots,saucelabs\" --browsers=\"sl_chrome,sl_ie,sl_firefox,sl_ios_simulator\" --single-run=true",
26
+ "test-ci": "npm run build-dist && npm run test && npm run test-browser && npm run test-ts-definitions && npm run test-coverage",
27
27
  "test-ts-definitions": "TS_NODE_PROJECT='test/typescript_definitions/tsconfig.json' NODE_ENV=test mocha --timeout 5000 --require ts-node/register ./test/typescript_definitions/*.ts",
28
28
  "build-dist": "npx rollup -c rollup.config.js",
29
- "build-md-toc": "./node_modules/.bin/markdown-toc -i CheatSheet.md",
29
+ "build-md-toc": "npx markdown-toc -i CheatSheet.md",
30
30
  "build-gz-check": "gzip -kf dist/js-joda.min.js && ls -alh ./dist/js-joda.min.js*",
31
- "lint": "../../node_modules/.bin/eslint ./src ./test"
31
+ "lint": "npx eslint ."
32
32
  },
33
33
  "keywords": [
34
34
  "date",
@@ -41,36 +41,6 @@
41
41
  },
42
42
  "author": "pithu",
43
43
  "homepage": "https://js-joda.github.io/js-joda",
44
- "devDependencies": {
45
- "@babel/cli": "^7.7.4",
46
- "@babel/core": "^7.7.4",
47
- "@babel/preset-env": "^7.7.4",
48
- "@babel/register": "^7.7.4",
49
- "@types/chai": "^4.2.11",
50
- "@types/mocha": "^7.0.2",
51
- "babel-loader": "^8.0.6",
52
- "babel-plugin-istanbul": "^5.2.0",
53
- "chai": "^4.2.0",
54
- "coveralls": "^3.0.8",
55
- "karma": "^4.4.1",
56
- "karma-chai-plugins": "^0.9.0",
57
- "karma-chrome-launcher": "^3.1.0",
58
- "karma-firefox-launcher": "^1.2.0",
59
- "karma-mocha": "^1.3.0",
60
- "karma-phantomjs-launcher": "^1.0.4",
61
- "karma-sauce-launcher": "^2.0.2",
62
- "karma-sourcemap-loader": "^0.3.7",
63
- "karma-webpack": "^4.0.2",
64
- "markdown-toc": "^1.2.0",
65
- "mocha": "^6.2.2",
66
- "phantomjs-prebuilt": "^2.1.16",
67
- "rollup": "^1.27.4",
68
- "rollup-plugin-babel": "^4.3.3",
69
- "rollup-plugin-uglify": "^6.0.3",
70
- "ts-node": "^8.10.2",
71
- "typescript": "^3.7.2",
72
- "webpack": "^4.41.2"
73
- },
74
44
  "license": "BSD-3-Clause",
75
- "dependencies": {}
45
+ "gitHead": "485c4b2be852563615e2d2a8c3f0bca22d86bcd4"
76
46
  }
package/src/Clock.js CHANGED
@@ -4,10 +4,10 @@
4
4
  * @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
5
5
  */
6
6
 
7
- import {abstractMethodFail, requireNonNull} from './assert';
8
- import {Instant} from './Instant';
9
- import {ZoneId} from './ZoneId';
10
- import {ZoneOffset} from './ZoneOffset';
7
+ import { abstractMethodFail, requireNonNull } from './assert';
8
+ import { Instant } from './Instant';
9
+ import { ZoneId } from './ZoneId';
10
+ import { ZoneOffset } from './ZoneOffset';
11
11
 
12
12
  /**
13
13
  * A clock providing access to the current instant, date and time using a time-zone.
@@ -121,7 +121,7 @@ export class Clock {
121
121
  * providing that the base clock is.
122
122
  *
123
123
  * @param baseClock the base clock to add the duration to, not null
124
- * @param offsetDuration the duration to add, not null
124
+ * @param duration the duration to add, not null
125
125
  * @return a clock based on the base clock with the duration added, not null
126
126
  */
127
127
  static offset(baseClock, duration) {
@@ -170,7 +170,6 @@ export class Clock {
170
170
  * to a date or time using a time-zone. This method returns a clock with
171
171
  * similar properties but using a different time-zone.
172
172
  *
173
- * @param zone the time-zone to change to, not null
174
173
  * @return a clock based on this clock with the specified time-zone, not null
175
174
  */
176
175
  withZone(){
@@ -238,7 +237,7 @@ class SystemClock extends Clock {
238
237
  * @returns {string}
239
238
  */
240
239
  toString(){
241
- return 'SystemClock[' + this._zone.toString() + ']';
240
+ return `SystemClock[${this._zone.toString()}]`;
242
241
  }
243
242
 
244
243
  }
@@ -325,6 +324,6 @@ class OffsetClock extends Clock {
325
324
  }
326
325
 
327
326
  toString() {
328
- return 'OffsetClock[' + this._baseClock + ',' + this._offset + ']';
327
+ return `OffsetClock[${this._baseClock},${this._offset}]`;
329
328
  }
330
- }
329
+ }
package/src/DayOfWeek.js CHANGED
@@ -4,16 +4,16 @@
4
4
  * @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
5
5
  */
6
6
 
7
- import {DateTimeException, UnsupportedTemporalTypeException, NullPointerException} from './errors';
8
- import {MathUtil} from './MathUtil';
9
- import {assert, requireNonNull, requireInstance} from './assert';
7
+ import { DateTimeException, UnsupportedTemporalTypeException, NullPointerException } from './errors';
8
+ import { MathUtil } from './MathUtil';
9
+ import { assert, requireNonNull, requireInstance } from './assert';
10
10
 
11
- import {ChronoField} from './temporal/ChronoField';
12
- import {ChronoUnit} from './temporal/ChronoUnit';
13
- import {IllegalArgumentException} from './errors';
14
- import {TemporalAccessor} from './temporal/TemporalAccessor';
15
- import {TemporalQueries} from './temporal/TemporalQueries';
16
- import {createTemporalQuery} from './temporal/TemporalQuery';
11
+ import { ChronoField } from './temporal/ChronoField';
12
+ import { ChronoUnit } from './temporal/ChronoUnit';
13
+ import { IllegalArgumentException } from './errors';
14
+ import { TemporalAccessor } from './temporal/TemporalAccessor';
15
+ import { TemporalQueries } from './temporal/TemporalQueries';
16
+ import { createTemporalQuery } from './temporal/TemporalQuery';
17
17
 
18
18
  /**
19
19
  * ### Static properties of Class {@link DayOfWeek}
@@ -93,7 +93,7 @@ export class DayOfWeek extends TemporalAccessor {
93
93
  */
94
94
  static of(dayOfWeek) {
95
95
  if (dayOfWeek < 1 || dayOfWeek > 7) {
96
- throw new DateTimeException('Invalid value for DayOfWeek: ' + dayOfWeek);
96
+ throw new DateTimeException(`Invalid value for DayOfWeek: ${dayOfWeek}`);
97
97
  }
98
98
  return ENUMS[dayOfWeek - 1];
99
99
  }
@@ -122,8 +122,8 @@ export class DayOfWeek extends TemporalAccessor {
122
122
  return DayOfWeek.of(temporal.get(ChronoField.DAY_OF_WEEK));
123
123
  } catch (ex) {
124
124
  if(ex instanceof DateTimeException) {
125
- throw new DateTimeException('Unable to obtain DayOfWeek from TemporalAccessor: ' +
126
- temporal + ', type ' + (temporal.constructor != null ? temporal.constructor.name : ''), ex);
125
+ throw new DateTimeException(`Unable to obtain DayOfWeek from TemporalAccessor: ${
126
+ temporal}, type ${temporal.constructor != null ? temporal.constructor.name : ''}`, ex);
127
127
  } else {
128
128
  throw ex;
129
129
  }
@@ -211,7 +211,7 @@ export class DayOfWeek extends TemporalAccessor {
211
211
  if (field === ChronoField.DAY_OF_WEEK) {
212
212
  return field.range();
213
213
  } else if (field instanceof ChronoField) {
214
- throw new UnsupportedTemporalTypeException('Unsupported field: ' + field);
214
+ throw new UnsupportedTemporalTypeException(`Unsupported field: ${field}`);
215
215
  }
216
216
  return field.rangeRefinedBy(this);
217
217
  }
@@ -272,7 +272,7 @@ export class DayOfWeek extends TemporalAccessor {
272
272
  if (field === ChronoField.DAY_OF_WEEK) {
273
273
  return this.value();
274
274
  } else if (field instanceof ChronoField) {
275
- throw new UnsupportedTemporalTypeException('Unsupported field: ' + field);
275
+ throw new UnsupportedTemporalTypeException(`Unsupported field: ${field}`);
276
276
  }
277
277
  return field.getFrom(this);
278
278
  }
package/src/Duration.js CHANGED
@@ -3,16 +3,16 @@
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 {requireNonNull, requireInstance} from './assert';
7
- import {ArithmeticException, DateTimeParseException, UnsupportedTemporalTypeException} from './errors';
8
- import {MathUtil, MAX_SAFE_INTEGER, MIN_SAFE_INTEGER} from './MathUtil';
6
+ import { requireNonNull, requireInstance } from './assert';
7
+ import { ArithmeticException, DateTimeParseException, UnsupportedTemporalTypeException } from './errors';
8
+ import { MathUtil, MAX_SAFE_INTEGER, MIN_SAFE_INTEGER } from './MathUtil';
9
9
 
10
- import {ChronoField} from './temporal/ChronoField';
11
- import {ChronoUnit} from './temporal/ChronoUnit';
12
- import {TemporalAmount} from './temporal/TemporalAmount';
13
- import {TemporalUnit} from './temporal/TemporalUnit';
10
+ import { ChronoField } from './temporal/ChronoField';
11
+ import { ChronoUnit } from './temporal/ChronoUnit';
12
+ import { TemporalAmount } from './temporal/TemporalAmount';
13
+ import { TemporalUnit } from './temporal/TemporalUnit';
14
14
 
15
- import {LocalTime} from './LocalTime';
15
+ import { LocalTime } from './LocalTime';
16
16
 
17
17
  /**
18
18
  * A time-based amount of time, such as '34.5 seconds'.
@@ -355,7 +355,7 @@ export class Duration extends TemporalAmount /*implements TemporalAmount, Compar
355
355
  }
356
356
  return MathUtil.safeMultiply(parseFloat(parsed), multiplier);
357
357
  } catch (ex) {
358
- throw new DateTimeParseException('Text cannot be parsed to a Duration: ' + errorText, text, 0, ex);
358
+ throw new DateTimeParseException(`Text cannot be parsed to a Duration: ${errorText}`, text, 0, ex);
359
359
  }
360
360
  }
361
361
 
@@ -364,7 +364,7 @@ export class Duration extends TemporalAmount /*implements TemporalAmount, Compar
364
364
  if (parsed == null || parsed.length === 0) {
365
365
  return 0;
366
366
  }
367
- parsed = (parsed + '000000000').substring(0, 9);
367
+ parsed = (`${parsed}000000000`).substring(0, 9);
368
368
  return parseFloat(parsed) * negate;
369
369
  }
370
370
 
@@ -423,7 +423,7 @@ export class Duration extends TemporalAmount /*implements TemporalAmount, Compar
423
423
  } else if (unit === ChronoUnit.NANOS) {
424
424
  return this._nanos;
425
425
  } else {
426
- throw new UnsupportedTemporalTypeException('Unsupported unit: ' + unit);
426
+ throw new UnsupportedTemporalTypeException(`Unsupported unit: ${unit}`);
427
427
  }
428
428
  }
429
429
 
@@ -1151,10 +1151,10 @@ export class Duration extends TemporalAmount /*implements TemporalAmount, Compar
1151
1151
  const secs = MathUtil.intMod(this._seconds, LocalTime.SECONDS_PER_MINUTE);
1152
1152
  let rval = 'PT';
1153
1153
  if (hours !== 0) {
1154
- rval += hours + 'H';
1154
+ rval += `${hours}H`;
1155
1155
  }
1156
1156
  if (minutes !== 0) {
1157
- rval += minutes + 'M';
1157
+ rval += `${minutes}M`;
1158
1158
  }
1159
1159
  if (secs === 0 && this._nanos === 0 && rval.length > 2) {
1160
1160
  return rval;
@@ -1172,9 +1172,9 @@ export class Duration extends TemporalAmount /*implements TemporalAmount, Compar
1172
1172
  rval += '.';
1173
1173
  let nanoString;
1174
1174
  if (secs < 0) {
1175
- nanoString = '' + (2 * LocalTime.NANOS_PER_SECOND - this._nanos);
1175
+ nanoString = `${2 * LocalTime.NANOS_PER_SECOND - this._nanos}`;
1176
1176
  } else {
1177
- nanoString = '' + (LocalTime.NANOS_PER_SECOND + this._nanos);
1177
+ nanoString = `${LocalTime.NANOS_PER_SECOND + this._nanos}`;
1178
1178
  }
1179
1179
  // remove the leading '1'
1180
1180
  nanoString = nanoString.slice(1, nanoString.length);
package/src/Instant.js CHANGED
@@ -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 {requireNonNull, requireInstance} from './assert';
8
- import {DateTimeException, UnsupportedTemporalTypeException} from './errors';
9
-
10
- import {Clock} from './Clock';
11
- import {LocalTime} from './LocalTime';
12
- import {ZonedDateTime} from './ZonedDateTime';
13
- import {MathUtil} from './MathUtil';
14
- import {OffsetDateTime} from './OffsetDateTime';
15
-
16
- import {Temporal} from './temporal/Temporal';
17
- import {ChronoField} from './temporal/ChronoField';
18
- import {ChronoUnit} from './temporal/ChronoUnit';
19
- import {TemporalQueries} from './temporal/TemporalQueries';
20
- import {TemporalUnit} from './temporal/TemporalUnit';
21
- import {createTemporalQuery} from './temporal/TemporalQuery';
22
- import {DateTimeFormatter} from './format/DateTimeFormatter';
7
+ import { requireNonNull, requireInstance } from './assert';
8
+ import { DateTimeException, UnsupportedTemporalTypeException } from './errors';
9
+
10
+ import { Clock } from './Clock';
11
+ import { LocalTime } from './LocalTime';
12
+ import { ZonedDateTime } from './ZonedDateTime';
13
+ import { MathUtil } from './MathUtil';
14
+ import { OffsetDateTime } from './OffsetDateTime';
15
+
16
+ import { Temporal } from './temporal/Temporal';
17
+ import { ChronoField } from './temporal/ChronoField';
18
+ import { ChronoUnit } from './temporal/ChronoUnit';
19
+ import { TemporalQueries } from './temporal/TemporalQueries';
20
+ import { TemporalUnit } from './temporal/TemporalUnit';
21
+ import { createTemporalQuery } from './temporal/TemporalQuery';
22
+ import { DateTimeFormatter } from './format/DateTimeFormatter';
23
23
 
24
24
  const NANOS_PER_MILLI = 1000000;
25
25
 
@@ -194,8 +194,8 @@ export class Instant extends Temporal {
194
194
  const nanoOfSecond = temporal.get(ChronoField.NANO_OF_SECOND);
195
195
  return Instant.ofEpochSecond(instantSecs, nanoOfSecond);
196
196
  } catch (ex) {
197
- throw new DateTimeException('Unable to obtain Instant from TemporalAccessor: ' +
198
- temporal + ', type ' + typeof temporal, ex);
197
+ throw new DateTimeException(`Unable to obtain Instant from TemporalAccessor: ${
198
+ temporal}, type ${typeof temporal}`, ex);
199
199
  }
200
200
  }
201
201
 
@@ -374,7 +374,7 @@ export class Instant extends Temporal {
374
374
  case ChronoField.MILLI_OF_SECOND: return MathUtil.intDiv(this._nanos, NANOS_PER_MILLI);
375
375
  case ChronoField.INSTANT_SECONDS: return this._seconds;
376
376
  }
377
- throw new UnsupportedTemporalTypeException('Unsupported field: ' + field);
377
+ throw new UnsupportedTemporalTypeException(`Unsupported field: ${field}`);
378
378
  }
379
379
  return field.getFrom(this);
380
380
  }
@@ -405,30 +405,7 @@ export class Instant extends Temporal {
405
405
  return this._nanos;
406
406
  }
407
407
 
408
- //-------------------------------------------------------------------------
409
- /**
410
- * Returns an adjusted copy of this instant.
411
- *
412
- * This returns a new {@link Instant}, based on this one, with the date adjusted.
413
- * The adjustment takes place using the specified adjuster strategy object.
414
- * Read the documentation of the adjuster to understand what adjustment will be made.
415
- *
416
- * The result of this method is obtained by invoking the
417
- * {@link TemporalAdjuster#adjustInto} method on the
418
- * specified adjuster passing `this` as the argument.
419
- *
420
- * This instance is immutable and unaffected by this method call.
421
- *
422
- * @param {!TemporalAdjuster} adjuster - the adjuster to use, not null
423
- * @return {Instant} an {@link Instant} based on `this` with the adjustment made, not null
424
- * @throws DateTimeException if the adjustment cannot be made
425
- * @throws ArithmeticException if numeric overflow occurs
426
- */
427
- withAdjuster(adjuster) {
428
- requireNonNull(adjuster, 'adjuster');
429
- return adjuster.adjustInto(this);
430
- }
431
-
408
+ //-----------------------------------------------------------------------
432
409
  /**
433
410
  * Returns a copy of this instant with the specified field set to a new value.
434
411
  *
@@ -472,7 +449,7 @@ export class Instant extends Temporal {
472
449
  * @throws DateTimeException if the field cannot be set
473
450
  * @throws ArithmeticException if numeric overflow occurs
474
451
  */
475
- withFieldValue(field, newValue) {
452
+ _withField(field, newValue) {
476
453
  requireNonNull(field, 'field');
477
454
  if (field instanceof ChronoField) {
478
455
  field.checkValidValue(newValue);
@@ -488,7 +465,7 @@ export class Instant extends Temporal {
488
465
  case ChronoField.NANO_OF_SECOND: return (newValue !== this._nanos? Instant._create(this._seconds, newValue) : this);
489
466
  case ChronoField.INSTANT_SECONDS: return (newValue !== this._seconds ? Instant._create(newValue, this._nanos) : this);
490
467
  }
491
- throw new UnsupportedTemporalTypeException('Unsupported field: ' + field);
468
+ throw new UnsupportedTemporalTypeException(`Unsupported field: ${field}`);
492
469
  }
493
470
  return field.adjustInto(this, newValue);
494
471
  }
@@ -534,18 +511,6 @@ export class Instant extends Temporal {
534
511
  }
535
512
 
536
513
  //-----------------------------------------------------------------------
537
-
538
- /**
539
- * @param {!TemporalAmount} amount
540
- * @return {Instant}
541
- * @throws DateTimeException
542
- * @throws ArithmeticException
543
- */
544
- plusAmount(amount) {
545
- requireNonNull(amount, 'amount');
546
- return amount.addTo(this);
547
- }
548
-
549
514
  /**
550
515
  * @param {!number} amountToAdd
551
516
  * @param {!TemporalUnit} unit
@@ -553,7 +518,7 @@ export class Instant extends Temporal {
553
518
  * @throws DateTimeException
554
519
  * @throws ArithmeticException
555
520
  */
556
- plusAmountUnit(amountToAdd, unit) {
521
+ _plusUnit(amountToAdd, unit) {
557
522
  requireNonNull(amountToAdd, 'amountToAdd');
558
523
  requireNonNull(unit, 'unit');
559
524
  requireInstance(unit, TemporalUnit);
@@ -568,7 +533,7 @@ export class Instant extends Temporal {
568
533
  case ChronoUnit.HALF_DAYS: return this.plusSeconds(MathUtil.safeMultiply(amountToAdd, LocalTime.SECONDS_PER_DAY / 2));
569
534
  case ChronoUnit.DAYS: return this.plusSeconds(MathUtil.safeMultiply(amountToAdd, LocalTime.SECONDS_PER_DAY));
570
535
  }
571
- throw new UnsupportedTemporalTypeException('Unsupported unit: ' + unit);
536
+ throw new UnsupportedTemporalTypeException(`Unsupported unit: ${unit}`);
572
537
  }
573
538
  return unit.addTo(this, amountToAdd);
574
539
  }
@@ -635,17 +600,6 @@ export class Instant extends Temporal {
635
600
 
636
601
  //-----------------------------------------------------------------------
637
602
 
638
- /**
639
- * @param {!TemporalAmount} amount
640
- * @return {Instant}
641
- * @throws DateTimeException
642
- * @throws ArithmeticException
643
- */
644
- minusAmount(amount) {
645
- requireNonNull(amount, 'amount');
646
- return amount.subtractFrom(this);
647
- }
648
-
649
603
  /**
650
604
  * @param {!number} amountToSubtract
651
605
  * @param {!TemporalUnit} unit
@@ -653,8 +607,8 @@ export class Instant extends Temporal {
653
607
  * @throws DateTimeException
654
608
  * @throws ArithmeticException
655
609
  */
656
- minusAmountUnit(amountToSubtract, unit) {
657
- return this.plusAmountUnit(-1 * amountToSubtract, unit);
610
+ _minusUnit(amountToSubtract, unit) {
611
+ return this._plusUnit(-1 * amountToSubtract, unit);
658
612
  }
659
613
 
660
614
  /**
@@ -808,7 +762,7 @@ export class Instant extends Temporal {
808
762
  if (unit instanceof ChronoUnit) {
809
763
  switch (unit) {
810
764
  case ChronoUnit.NANOS: return this._nanosUntil(end);
811
- case ChronoUnit.MICROS: return MathUtil.intDiv(this._nanosUntil(end), 1000);
765
+ case ChronoUnit.MICROS: return this._microsUntil(end);
812
766
  case ChronoUnit.MILLIS: return MathUtil.safeSubtract(end.toEpochMilli(), this.toEpochMilli());
813
767
  case ChronoUnit.SECONDS: return this._secondsUntil(end);
814
768
  case ChronoUnit.MINUTES: return MathUtil.intDiv(this._secondsUntil(end), LocalTime.SECONDS_PER_MINUTE);
@@ -816,11 +770,23 @@ export class Instant extends Temporal {
816
770
  case ChronoUnit.HALF_DAYS: return MathUtil.intDiv(this._secondsUntil(end), (12 * LocalTime.SECONDS_PER_HOUR));
817
771
  case ChronoUnit.DAYS: return MathUtil.intDiv(this._secondsUntil(end), LocalTime.SECONDS_PER_DAY);
818
772
  }
819
- throw new UnsupportedTemporalTypeException('Unsupported unit: ' + unit);
773
+ throw new UnsupportedTemporalTypeException(`Unsupported unit: ${unit}`);
820
774
  }
821
775
  return unit.between(this, end);
822
776
  }
823
777
 
778
+ /**
779
+ *
780
+ * @param {Temporal} end
781
+ * @returns {number}
782
+ * @private
783
+ */
784
+ _microsUntil(end) {
785
+ const secsDiff = MathUtil.safeSubtract(end.epochSecond(), this.epochSecond());
786
+ const totalMicros = MathUtil.safeMultiply(secsDiff, 1000000);
787
+ return MathUtil.safeAdd(totalMicros, MathUtil.intDiv(end.nano() - this.nano(), 1000));
788
+ }
789
+
824
790
  /**
825
791
  *
826
792
  * @param {Temporal} end