@js-joda/core 4.1.0 → 4.3.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.
- package/CHANGELOG.md +16 -1
- package/README.md +42 -32
- package/dist/js-joda.esm.js +11345 -9928
- package/dist/js-joda.js +11345 -9928
- package/dist/js-joda.js.map +1 -1
- package/dist/js-joda.min.js +2 -2
- package/package.json +22 -46
- package/src/Clock.js +6 -6
- package/src/DayOfWeek.js +13 -13
- package/src/Duration.js +15 -15
- package/src/Instant.js +21 -21
- package/src/LocalDate.js +44 -44
- package/src/LocalDateTime.js +19 -19
- package/src/LocalTime.js +21 -21
- package/src/MathUtil.js +3 -3
- package/src/Month.js +12 -12
- package/src/MonthDay.js +23 -23
- package/src/OffsetDateTime.js +21 -21
- package/src/OffsetTime.js +16 -16
- package/src/Period.js +12 -12
- package/src/StringUtil.js +1 -1
- package/src/Year.js +30 -30
- package/src/YearMonth.js +26 -26
- package/src/ZoneId.js +7 -7
- package/src/ZoneIdFactory.js +13 -13
- package/src/ZoneOffset.js +20 -20
- package/src/ZoneRegion.js +2 -2
- package/src/ZonedDateTime.js +24 -24
- package/src/_init.js +24 -24
- package/src/assert.js +4 -4
- package/src/chrono/ChronoLocalDate.js +7 -7
- package/src/chrono/ChronoLocalDateTime.js +9 -9
- package/src/chrono/ChronoZonedDateTime.js +7 -7
- package/src/chrono/IsoChronology.js +13 -13
- package/src/convert.js +7 -7
- package/src/errors.js +3 -3
- package/src/format/DateTimeBuilder.js +17 -17
- package/src/format/DateTimeFormatter.js +19 -19
- package/src/format/DateTimeFormatterBuilder.js +59 -59
- package/src/format/DateTimeParseContext.js +6 -6
- package/src/format/DateTimePrintContext.js +3 -3
- package/src/format/DecimalStyle.js +1 -1
- package/src/format/ResolverStyle.js +1 -1
- package/src/format/SignStyle.js +1 -1
- package/src/format/TextStyle.js +1 -1
- package/src/format/parser/CharLiteralPrinterParser.js +3 -3
- package/src/format/parser/FractionPrinterParser.js +9 -9
- package/src/format/parser/NumberPrinterParser.js +17 -17
- package/src/format/parser/OffsetIdPrinterParser.js +9 -9
- package/src/format/parser/PadPrinterParserDecorator.js +3 -3
- package/src/format/parser/StringLiteralPrinterParser.js +2 -2
- package/src/format/parser/ZoneIdPrinterParser.js +5 -5
- package/src/temporal/ChronoField.js +5 -5
- package/src/temporal/ChronoUnit.js +4 -4
- package/src/temporal/IsoFields.js +12 -12
- package/src/temporal/NativeJsTemporal.js +11 -11
- package/src/temporal/Temporal.js +5 -5
- package/src/temporal/TemporalAccessor.js +5 -5
- package/src/temporal/TemporalAdjuster.js +1 -1
- package/src/temporal/TemporalAdjusters.js +6 -6
- package/src/temporal/TemporalAmount.js +1 -1
- package/src/temporal/TemporalQueriesFactory.js +6 -6
- package/src/temporal/TemporalQuery.js +2 -2
- package/src/temporal/TemporalUnit.js +1 -1
- package/src/temporal/ValueRange.js +15 -15
- package/src/zone/SystemDefaultZoneId.js +2 -2
- package/src/zone/SystemDefaultZoneRules.js +3 -3
- package/src/zone/ZoneOffsetTransition.js +7 -7
- package/src/zone/ZoneRules.js +4 -4
- package/src/zone/ZoneRulesProvider.js +2 -2
- package/{dist → typings}/js-joda.d.ts +0 -0
- package/{dist → typings}/js-joda.flow.js +1 -1
- package/CheatSheet.md +0 -947
- package/bower.json +0 -21
package/src/LocalTime.js
CHANGED
|
@@ -5,23 +5,23 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
import {MathUtil} from './MathUtil';
|
|
9
|
-
import {requireNonNull, requireInstance} from './assert';
|
|
10
|
-
import {DateTimeException, UnsupportedTemporalTypeException} 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';
|
|
15
|
-
import {OffsetTime} from './OffsetTime';
|
|
12
|
+
import { Clock } from './Clock';
|
|
13
|
+
import { LocalDateTime } from './LocalDateTime';
|
|
14
|
+
import { ZoneId } from './ZoneId';
|
|
15
|
+
import { OffsetTime } from './OffsetTime';
|
|
16
16
|
|
|
17
|
-
import {DateTimeFormatter} from './format/DateTimeFormatter';
|
|
17
|
+
import { DateTimeFormatter } from './format/DateTimeFormatter';
|
|
18
18
|
|
|
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';
|
|
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';
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* A time without time-zone in the ISO-8601 calendar system,
|
|
@@ -461,7 +461,7 @@ export class LocalTime extends Temporal /** implements Temporal, TemporalAdjuste
|
|
|
461
461
|
case ChronoField.CLOCK_HOUR_OF_DAY: return (this._hour === 0 ? 24 : this._hour);
|
|
462
462
|
case ChronoField.AMPM_OF_DAY: return MathUtil.intDiv(this._hour, 12);
|
|
463
463
|
}
|
|
464
|
-
throw new UnsupportedTemporalTypeException(`Unsupported field: ${
|
|
464
|
+
throw new UnsupportedTemporalTypeException(`Unsupported field: ${field}`);
|
|
465
465
|
}
|
|
466
466
|
|
|
467
467
|
//-----------------------------------------------------------------------
|
|
@@ -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: ${
|
|
636
|
+
throw new UnsupportedTemporalTypeException(`Unsupported field: ${field}`);
|
|
637
637
|
}
|
|
638
638
|
return field.adjustInto(this, newValue);
|
|
639
639
|
}
|
|
@@ -769,7 +769,7 @@ export class LocalTime extends Temporal /** implements Temporal, TemporalAdjuste
|
|
|
769
769
|
case ChronoUnit.HOURS: return this.plusHours(amountToAdd);
|
|
770
770
|
case ChronoUnit.HALF_DAYS: return this.plusHours(MathUtil.intMod(amountToAdd, 2) * 12);
|
|
771
771
|
}
|
|
772
|
-
throw new UnsupportedTemporalTypeException(`Unsupported unit: ${
|
|
772
|
+
throw new UnsupportedTemporalTypeException(`Unsupported unit: ${unit}`);
|
|
773
773
|
}
|
|
774
774
|
return unit.addTo(this, amountToAdd);
|
|
775
775
|
}
|
|
@@ -1077,7 +1077,7 @@ export class LocalTime extends Temporal /** implements Temporal, TemporalAdjuste
|
|
|
1077
1077
|
case ChronoUnit.HOURS: return MathUtil.intDiv(nanosUntil, LocalTime.NANOS_PER_HOUR);
|
|
1078
1078
|
case ChronoUnit.HALF_DAYS: return MathUtil.intDiv(nanosUntil, (12 * LocalTime.NANOS_PER_HOUR));
|
|
1079
1079
|
}
|
|
1080
|
-
throw new UnsupportedTemporalTypeException(`Unsupported unit: ${
|
|
1080
|
+
throw new UnsupportedTemporalTypeException(`Unsupported unit: ${unit}`);
|
|
1081
1081
|
}
|
|
1082
1082
|
return unit.between(this, end);
|
|
1083
1083
|
}
|
|
@@ -1255,11 +1255,11 @@ export class LocalTime extends Temporal /** implements Temporal, TemporalAdjuste
|
|
|
1255
1255
|
if (nanoValue > 0) {
|
|
1256
1256
|
buf += '.';
|
|
1257
1257
|
if(MathUtil.intMod(nanoValue, 1000000) === 0) {
|
|
1258
|
-
buf += (`${
|
|
1258
|
+
buf += (`${MathUtil.intDiv(nanoValue, 1000000) + 1000}`).substring(1);
|
|
1259
1259
|
} else if (MathUtil.intMod(nanoValue, 1000) === 0) {
|
|
1260
|
-
buf += (`${
|
|
1260
|
+
buf += (`${MathUtil.intDiv(nanoValue, 1000) + 1000000}`).substring(1);
|
|
1261
1261
|
} else {
|
|
1262
|
-
buf += (`${
|
|
1262
|
+
buf += (`${nanoValue + 1000000000}`).substring(1);
|
|
1263
1263
|
}
|
|
1264
1264
|
}
|
|
1265
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: ${
|
|
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: ${
|
|
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: ${
|
|
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: ${
|
|
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: ${
|
|
540
|
+
assert(false, `Invalid value for MonthOfYear: ${month}`, DateTimeException);
|
|
541
541
|
}
|
|
542
542
|
return MONTHS[month-1];
|
|
543
543
|
}
|
|
@@ -572,7 +572,7 @@ export class Month extends TemporalAccessor {
|
|
|
572
572
|
return Month.of(temporal.get(ChronoField.MONTH_OF_YEAR));
|
|
573
573
|
} catch (ex) {
|
|
574
574
|
throw new DateTimeException(`Unable to obtain Month from TemporalAccessor: ${
|
|
575
|
-
temporal
|
|
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 ${
|
|
163
|
-
} is not valid for month ${
|
|
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
|
}
|
|
@@ -218,7 +218,7 @@ export class MonthDay extends TemporalAccessor {
|
|
|
218
218
|
return MonthDay.of(temporal.get(ChronoField.MONTH_OF_YEAR), temporal.get(ChronoField.DAY_OF_MONTH));
|
|
219
219
|
} catch (ex) {
|
|
220
220
|
throw new DateTimeException(`Unable to obtain MonthDay from TemporalAccessor: ${
|
|
221
|
-
temporal
|
|
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: ${
|
|
451
|
+
throw new UnsupportedTemporalTypeException(`Unsupported field: ${field}`);
|
|
452
452
|
}
|
|
453
453
|
return field.getFrom(this);
|
|
454
454
|
}
|
|
@@ -682,8 +682,8 @@ export class MonthDay extends TemporalAccessor {
|
|
|
682
682
|
*/
|
|
683
683
|
toString() {
|
|
684
684
|
return `--${
|
|
685
|
-
this._month < 10 ? '0' : ''
|
|
686
|
-
}${this._day < 10 ? '-0' : '-'
|
|
685
|
+
this._month < 10 ? '0' : ''}${this._month
|
|
686
|
+
}${this._day < 10 ? '-0' : '-'}${this._day}`;
|
|
687
687
|
}
|
|
688
688
|
|
|
689
689
|
/**
|
package/src/OffsetDateTime.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 {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';
|
|
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,
|
|
@@ -205,7 +205,7 @@ export class OffsetDateTime extends Temporal {
|
|
|
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: ${
|
|
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);
|
package/src/OffsetTime.js
CHANGED
|
@@ -4,21 +4,21 @@
|
|
|
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 {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';
|
|
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.
|
|
@@ -450,7 +450,7 @@ export class OffsetTime extends Temporal {
|
|
|
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: ${
|
|
453
|
+
throw new UnsupportedTemporalTypeException(`Unsupported unit: ${unit}`);
|
|
454
454
|
}
|
|
455
455
|
return unit.between(this, end);
|
|
456
456
|
}
|
package/src/Period.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 {MathUtil} from './MathUtil';
|
|
8
|
-
import {requireNonNull, requireInstance} from './assert';
|
|
9
|
-
import {DateTimeException, UnsupportedTemporalTypeException, ArithmeticException, DateTimeParseException} from './errors';
|
|
7
|
+
import { MathUtil } from './MathUtil';
|
|
8
|
+
import { requireNonNull, requireInstance } from './assert';
|
|
9
|
+
import { DateTimeException, UnsupportedTemporalTypeException, ArithmeticException, DateTimeParseException } from './errors';
|
|
10
10
|
|
|
11
|
-
import {IsoChronology} from './chrono/IsoChronology';
|
|
11
|
+
import { IsoChronology } from './chrono/IsoChronology';
|
|
12
12
|
|
|
13
|
-
import {ChronoUnit} from './temporal/ChronoUnit';
|
|
14
|
-
import {TemporalAmount} from './temporal/TemporalAmount';
|
|
13
|
+
import { ChronoUnit } from './temporal/ChronoUnit';
|
|
14
|
+
import { TemporalAmount } from './temporal/TemporalAmount';
|
|
15
15
|
|
|
16
|
-
import {LocalDate} from './LocalDate';
|
|
16
|
+
import { LocalDate } from './LocalDate';
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* The pattern for parsing.
|
|
@@ -214,7 +214,7 @@ export class Period extends TemporalAmount /* extends ChronoPeriod */ {
|
|
|
214
214
|
} else if (unit === ChronoUnit.DAYS) {
|
|
215
215
|
days = MathUtil.safeToInt(unitAmount);
|
|
216
216
|
} else {
|
|
217
|
-
throw new DateTimeException(`Unit must be Years, Months or Days, but was ${
|
|
217
|
+
throw new DateTimeException(`Unit must be Years, Months or Days, but was ${unit}`);
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
220
|
return Period.create(years, months, days);
|
|
@@ -393,7 +393,7 @@ export class Period extends TemporalAmount /* extends ChronoPeriod */ {
|
|
|
393
393
|
if (unit === ChronoUnit.DAYS) {
|
|
394
394
|
return this._days;
|
|
395
395
|
}
|
|
396
|
-
throw new UnsupportedTemporalTypeException(`Unsupported unit: ${
|
|
396
|
+
throw new UnsupportedTemporalTypeException(`Unsupported unit: ${unit}`);
|
|
397
397
|
}
|
|
398
398
|
|
|
399
399
|
//-----------------------------------------------------------------------
|
|
@@ -904,13 +904,13 @@ export class Period extends TemporalAmount /* extends ChronoPeriod */ {
|
|
|
904
904
|
} else {
|
|
905
905
|
let buf = 'P';
|
|
906
906
|
if (this._years !== 0) {
|
|
907
|
-
buf += `${
|
|
907
|
+
buf += `${this._years}Y`;
|
|
908
908
|
}
|
|
909
909
|
if (this._months !== 0) {
|
|
910
|
-
buf += `${
|
|
910
|
+
buf += `${this._months}M`;
|
|
911
911
|
}
|
|
912
912
|
if (this._days !== 0) {
|
|
913
|
-
buf += `${
|
|
913
|
+
buf += `${this._days}D`;
|
|
914
914
|
}
|
|
915
915
|
return buf;
|
|
916
916
|
}
|
package/src/StringUtil.js
CHANGED
package/src/Year.js
CHANGED
|
@@ -4,29 +4,29 @@
|
|
|
4
4
|
* @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {DateTimeException, UnsupportedTemporalTypeException} from './errors';
|
|
8
|
-
import {requireNonNull, requireInstance} from './assert';
|
|
9
|
-
import {MathUtil} from './MathUtil';
|
|
10
|
-
|
|
11
|
-
import {ChronoField} from './temporal/ChronoField';
|
|
12
|
-
import {ChronoUnit} from './temporal/ChronoUnit';
|
|
13
|
-
import {Clock} from './Clock';
|
|
14
|
-
import {DateTimeFormatter} from './format/DateTimeFormatter';
|
|
15
|
-
import {DateTimeFormatterBuilder} from './format/DateTimeFormatterBuilder';
|
|
16
|
-
import {IsoChronology} from './chrono/IsoChronology';
|
|
17
|
-
import {LocalDate} from './LocalDate';
|
|
18
|
-
import {Month} from './Month';
|
|
19
|
-
import {MonthDay} from './MonthDay';
|
|
20
|
-
import {SignStyle} from './format/SignStyle';
|
|
21
|
-
import {Temporal} from './temporal/Temporal';
|
|
22
|
-
import {TemporalAccessor} from './temporal/TemporalAccessor';
|
|
23
|
-
import {TemporalField} from './temporal/TemporalField';
|
|
24
|
-
import {TemporalQueries} from './temporal/TemporalQueries';
|
|
25
|
-
import {TemporalQuery, createTemporalQuery} from './temporal/TemporalQuery';
|
|
26
|
-
import {TemporalUnit} from './temporal/TemporalUnit';
|
|
27
|
-
import {YearConstants} from './YearConstants';
|
|
28
|
-
import {YearMonth} from './YearMonth';
|
|
29
|
-
import {ZoneId} from './ZoneId';
|
|
7
|
+
import { DateTimeException, UnsupportedTemporalTypeException } from './errors';
|
|
8
|
+
import { requireNonNull, requireInstance } from './assert';
|
|
9
|
+
import { MathUtil } from './MathUtil';
|
|
10
|
+
|
|
11
|
+
import { ChronoField } from './temporal/ChronoField';
|
|
12
|
+
import { ChronoUnit } from './temporal/ChronoUnit';
|
|
13
|
+
import { Clock } from './Clock';
|
|
14
|
+
import { DateTimeFormatter } from './format/DateTimeFormatter';
|
|
15
|
+
import { DateTimeFormatterBuilder } from './format/DateTimeFormatterBuilder';
|
|
16
|
+
import { IsoChronology } from './chrono/IsoChronology';
|
|
17
|
+
import { LocalDate } from './LocalDate';
|
|
18
|
+
import { Month } from './Month';
|
|
19
|
+
import { MonthDay } from './MonthDay';
|
|
20
|
+
import { SignStyle } from './format/SignStyle';
|
|
21
|
+
import { Temporal } from './temporal/Temporal';
|
|
22
|
+
import { TemporalAccessor } from './temporal/TemporalAccessor';
|
|
23
|
+
import { TemporalField } from './temporal/TemporalField';
|
|
24
|
+
import { TemporalQueries } from './temporal/TemporalQueries';
|
|
25
|
+
import { TemporalQuery, createTemporalQuery } from './temporal/TemporalQuery';
|
|
26
|
+
import { TemporalUnit } from './temporal/TemporalUnit';
|
|
27
|
+
import { YearConstants } from './YearConstants';
|
|
28
|
+
import { YearMonth } from './YearMonth';
|
|
29
|
+
import { ZoneId } from './ZoneId';
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
/**
|
|
@@ -209,7 +209,7 @@ export class Year extends Temporal {
|
|
|
209
209
|
return Year.of(temporal.get(ChronoField.YEAR));
|
|
210
210
|
} catch (ex) {
|
|
211
211
|
throw new DateTimeException(`Unable to obtain Year from TemporalAccessor: ${
|
|
212
|
-
temporal
|
|
212
|
+
temporal}, type ${temporal && temporal.constructor != null ? temporal.constructor.name : ''}`);
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
215
|
//-----------------------------------------------------------------------
|
|
@@ -371,7 +371,7 @@ export class Year extends Temporal {
|
|
|
371
371
|
if (this.isSupported(field)) {
|
|
372
372
|
return field.range();
|
|
373
373
|
} else if (field instanceof ChronoField) {
|
|
374
|
-
throw new UnsupportedTemporalTypeException(`Unsupported field: ${
|
|
374
|
+
throw new UnsupportedTemporalTypeException(`Unsupported field: ${field}`);
|
|
375
375
|
}
|
|
376
376
|
return super.range(field);
|
|
377
377
|
}
|
|
@@ -433,7 +433,7 @@ export class Year extends Temporal {
|
|
|
433
433
|
case ChronoField.YEAR: return this._year;
|
|
434
434
|
case ChronoField.ERA: return (this._year < 1 ? 0 : 1);
|
|
435
435
|
}
|
|
436
|
-
throw new UnsupportedTemporalTypeException(`Unsupported field: ${
|
|
436
|
+
throw new UnsupportedTemporalTypeException(`Unsupported field: ${field}`);
|
|
437
437
|
}
|
|
438
438
|
return field.getFrom(this);
|
|
439
439
|
}
|
|
@@ -515,7 +515,7 @@ export class Year extends Temporal {
|
|
|
515
515
|
case ChronoField.ERA:
|
|
516
516
|
return (this.getLong(ChronoField.ERA) === newValue ? this : Year.of(1 - this._year));
|
|
517
517
|
}
|
|
518
|
-
throw new UnsupportedTemporalTypeException(`Unsupported field: ${
|
|
518
|
+
throw new UnsupportedTemporalTypeException(`Unsupported field: ${field}`);
|
|
519
519
|
}
|
|
520
520
|
return field.adjustInto(this, newValue);
|
|
521
521
|
}
|
|
@@ -539,7 +539,7 @@ export class Year extends Temporal {
|
|
|
539
539
|
case ChronoUnit.MILLENNIA: return this.plusYears(MathUtil.safeMultiply(amountToAdd, 1000));
|
|
540
540
|
case ChronoUnit.ERAS: return this.with(ChronoField.ERA, MathUtil.safeAdd(this.getLong(ChronoField.ERA), amountToAdd));
|
|
541
541
|
}
|
|
542
|
-
throw new UnsupportedTemporalTypeException(`Unsupported unit: ${
|
|
542
|
+
throw new UnsupportedTemporalTypeException(`Unsupported unit: ${unit}`);
|
|
543
543
|
}
|
|
544
544
|
return unit.addTo(this, amountToAdd);
|
|
545
545
|
}
|
|
@@ -831,7 +831,7 @@ export class Year extends Temporal {
|
|
|
831
831
|
* @return {String} a string representation of this year, not null
|
|
832
832
|
*/
|
|
833
833
|
toString() {
|
|
834
|
-
return `${
|
|
834
|
+
return `${this._year}`;
|
|
835
835
|
}
|
|
836
836
|
|
|
837
837
|
/**
|
|
@@ -910,7 +910,7 @@ export class Year extends Temporal {
|
|
|
910
910
|
case ChronoUnit.ERAS:
|
|
911
911
|
return end.getLong(ChronoField.ERA) - this.getLong(ChronoField.ERA);
|
|
912
912
|
}
|
|
913
|
-
throw new UnsupportedTemporalTypeException(`Unsupported unit: ${
|
|
913
|
+
throw new UnsupportedTemporalTypeException(`Unsupported unit: ${unit}`);
|
|
914
914
|
}
|
|
915
915
|
return unit.between(this, end);
|
|
916
916
|
}
|
package/src/YearMonth.js
CHANGED
|
@@ -3,27 +3,27 @@
|
|
|
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 {ChronoUnit} from './temporal/ChronoUnit';
|
|
12
|
-
import {Clock} from './Clock';
|
|
13
|
-
import {DateTimeFormatterBuilder} from './format/DateTimeFormatterBuilder';
|
|
14
|
-
import {IsoChronology} from './chrono/IsoChronology';
|
|
15
|
-
import {LocalDate} from './LocalDate';
|
|
16
|
-
import {Month} from './Month';
|
|
17
|
-
import {SignStyle} from './format/SignStyle';
|
|
18
|
-
import {Temporal} from './temporal/Temporal';
|
|
19
|
-
import {TemporalField} from './temporal/TemporalField';
|
|
20
|
-
import {TemporalQueries} from './temporal/TemporalQueries';
|
|
21
|
-
import {TemporalQuery} from './temporal/TemporalQuery';
|
|
22
|
-
import {TemporalUnit} from './temporal/TemporalUnit';
|
|
23
|
-
import {createTemporalQuery} from './temporal/TemporalQuery';
|
|
24
|
-
import {ValueRange} from './temporal/ValueRange';
|
|
25
|
-
import {Year} from './Year';
|
|
26
|
-
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 { ChronoUnit } from './temporal/ChronoUnit';
|
|
12
|
+
import { Clock } from './Clock';
|
|
13
|
+
import { DateTimeFormatterBuilder } from './format/DateTimeFormatterBuilder';
|
|
14
|
+
import { IsoChronology } from './chrono/IsoChronology';
|
|
15
|
+
import { LocalDate } from './LocalDate';
|
|
16
|
+
import { Month } from './Month';
|
|
17
|
+
import { SignStyle } from './format/SignStyle';
|
|
18
|
+
import { Temporal } from './temporal/Temporal';
|
|
19
|
+
import { TemporalField } from './temporal/TemporalField';
|
|
20
|
+
import { TemporalQueries } from './temporal/TemporalQueries';
|
|
21
|
+
import { TemporalQuery } from './temporal/TemporalQuery';
|
|
22
|
+
import { TemporalUnit } from './temporal/TemporalUnit';
|
|
23
|
+
import { createTemporalQuery } from './temporal/TemporalQuery';
|
|
24
|
+
import { ValueRange } from './temporal/ValueRange';
|
|
25
|
+
import { Year } from './Year';
|
|
26
|
+
import { ZoneId } from './ZoneId';
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* A year-month in the ISO-8601 calendar system, such as `2007-12`.
|
|
@@ -199,7 +199,7 @@ export class YearMonth extends Temporal {
|
|
|
199
199
|
return YearMonth.of(temporal.get(ChronoField.YEAR), temporal.get(ChronoField.MONTH_OF_YEAR));
|
|
200
200
|
} catch (ex) {
|
|
201
201
|
throw new DateTimeException(`Unable to obtain YearMonth from TemporalAccessor: ${
|
|
202
|
-
temporal
|
|
202
|
+
temporal}, type ${temporal && temporal.constructor != null ? temporal.constructor.name : ''}`);
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
205
|
//-----------------------------------------------------------------------
|
|
@@ -418,7 +418,7 @@ export class YearMonth extends Temporal {
|
|
|
418
418
|
case ChronoField.YEAR: return this._year;
|
|
419
419
|
case ChronoField.ERA: return (this._year < 1 ? 0 : 1);
|
|
420
420
|
}
|
|
421
|
-
throw new UnsupportedTemporalTypeException(`Unsupported field: ${
|
|
421
|
+
throw new UnsupportedTemporalTypeException(`Unsupported field: ${field}`);
|
|
422
422
|
}
|
|
423
423
|
return field.getFrom(this);
|
|
424
424
|
}
|
|
@@ -604,7 +604,7 @@ export class YearMonth extends Temporal {
|
|
|
604
604
|
case ChronoField.YEAR: return this.withYear(newValue);
|
|
605
605
|
case ChronoField.ERA: return (this.getLong(ChronoField.ERA) === newValue ? this : this.withYear(1 - this._year));
|
|
606
606
|
}
|
|
607
|
-
throw new UnsupportedTemporalTypeException(`Unsupported field: ${
|
|
607
|
+
throw new UnsupportedTemporalTypeException(`Unsupported field: ${field}`);
|
|
608
608
|
}
|
|
609
609
|
return field.adjustInto(this, newValue);
|
|
610
610
|
}
|
|
@@ -659,7 +659,7 @@ export class YearMonth extends Temporal {
|
|
|
659
659
|
case ChronoUnit.MILLENNIA: return this.plusYears(MathUtil.safeMultiply(amountToAdd, 1000));
|
|
660
660
|
case ChronoUnit.ERAS: return this.with(ChronoField.ERA, MathUtil.safeAdd(this.getLong(ChronoField.ERA), amountToAdd));
|
|
661
661
|
}
|
|
662
|
-
throw new UnsupportedTemporalTypeException(`Unsupported unit: ${
|
|
662
|
+
throw new UnsupportedTemporalTypeException(`Unsupported unit: ${unit}`);
|
|
663
663
|
}
|
|
664
664
|
return unit.addTo(this, amountToAdd);
|
|
665
665
|
}
|
|
@@ -857,7 +857,7 @@ export class YearMonth extends Temporal {
|
|
|
857
857
|
case ChronoUnit.MILLENNIA: return monthsUntil / 12000;
|
|
858
858
|
case ChronoUnit.ERAS: return end.getLong(ChronoField.ERA) - this.getLong(ChronoField.ERA);
|
|
859
859
|
}
|
|
860
|
-
throw new UnsupportedTemporalTypeException(`Unsupported unit: ${
|
|
860
|
+
throw new UnsupportedTemporalTypeException(`Unsupported unit: ${unit}`);
|
|
861
861
|
}
|
|
862
862
|
return unit.between(this, end);
|
|
863
863
|
}
|