@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.
- package/CHANGELOG.md +32 -1
- package/README.md +43 -36
- package/dist/js-joda.d.ts +241 -179
- package/dist/js-joda.esm.js +11524 -10214
- package/dist/js-joda.js +11524 -10214
- package/dist/js-joda.js.map +1 -1
- package/dist/js-joda.min.js +2 -2
- package/package.json +10 -40
- package/src/Clock.js +8 -9
- package/src/DayOfWeek.js +14 -14
- package/src/Duration.js +15 -15
- package/src/Instant.js +40 -74
- package/src/LocalDate.js +71 -93
- package/src/LocalDateTime.js +25 -68
- package/src/LocalTime.js +27 -72
- package/src/MathUtil.js +3 -3
- package/src/Month.js +13 -13
- package/src/MonthDay.js +25 -25
- package/src/OffsetDateTime.js +29 -29
- package/src/OffsetTime.js +32 -32
- package/src/Period.js +12 -12
- package/src/StringUtil.js +1 -1
- package/src/Year.js +33 -115
- package/src/YearMonth.js +31 -113
- package/src/ZoneId.js +7 -7
- package/src/ZoneIdFactory.js +14 -14
- package/src/ZoneOffset.js +23 -23
- package/src/ZoneRegion.js +2 -2
- package/src/ZonedDateTime.js +31 -74
- package/src/_init.js +24 -24
- package/src/assert.js +31 -4
- package/src/chrono/ChronoLocalDate.js +8 -8
- package/src/chrono/ChronoLocalDateTime.js +10 -10
- package/src/chrono/ChronoZonedDateTime.js +8 -8
- package/src/chrono/IsoChronology.js +13 -13
- package/src/convert.js +12 -8
- package/src/errors.js +3 -3
- package/src/format/DateTimeBuilder.js +17 -17
- package/src/format/DateTimeFormatter.js +45 -24
- 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 +10 -10
- package/src/format/parser/NumberPrinterParser.js +18 -18
- 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/js-joda.js +5 -0
- package/src/temporal/ChronoField.js +5 -5
- package/src/temporal/ChronoUnit.js +6 -6
- package/src/temporal/IsoFields.js +12 -12
- package/src/temporal/NativeJsTemporal.js +11 -11
- package/src/temporal/Temporal.js +45 -38
- package/src/temporal/TemporalAccessor.js +14 -4
- 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 +4 -2
- package/src/temporal/TemporalUnit.js +1 -1
- package/src/temporal/ValueRange.js +15 -15
- package/src/use.js +6 -1
- 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/src/temporal/DefaultInterfaceTemporal.js +0 -118
|
@@ -4,24 +4,24 @@
|
|
|
4
4
|
* @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {requireNonNull} from '../assert';
|
|
8
|
-
import {DateTimeException} from '../errors';
|
|
9
|
-
import {MathUtil} from '../MathUtil';
|
|
7
|
+
import { requireNonNull } from '../assert';
|
|
8
|
+
import { DateTimeException } from '../errors';
|
|
9
|
+
import { MathUtil } from '../MathUtil';
|
|
10
10
|
|
|
11
|
-
import {EnumMap} from './EnumMap';
|
|
12
|
-
import {ResolverStyle} from './ResolverStyle';
|
|
11
|
+
import { EnumMap } from './EnumMap';
|
|
12
|
+
import { ResolverStyle } from './ResolverStyle';
|
|
13
13
|
|
|
14
|
-
import {IsoChronology} from '../chrono/IsoChronology';
|
|
15
|
-
import {ChronoLocalDate} from '../chrono/ChronoLocalDate';
|
|
16
|
-
import {ChronoField} from '../temporal/ChronoField';
|
|
17
|
-
import {TemporalAccessor} from '../temporal/TemporalAccessor';
|
|
18
|
-
import {TemporalQueries} from '../temporal/TemporalQueries';
|
|
14
|
+
import { IsoChronology } from '../chrono/IsoChronology';
|
|
15
|
+
import { ChronoLocalDate } from '../chrono/ChronoLocalDate';
|
|
16
|
+
import { ChronoField } from '../temporal/ChronoField';
|
|
17
|
+
import { TemporalAccessor } from '../temporal/TemporalAccessor';
|
|
18
|
+
import { TemporalQueries } from '../temporal/TemporalQueries';
|
|
19
19
|
|
|
20
|
-
import {LocalTime} from '../LocalTime';
|
|
21
|
-
import {LocalDate} from '../LocalDate';
|
|
22
|
-
import {Period} from '../Period';
|
|
20
|
+
import { LocalTime } from '../LocalTime';
|
|
21
|
+
import { LocalDate } from '../LocalDate';
|
|
22
|
+
import { Period } from '../Period';
|
|
23
23
|
|
|
24
|
-
import {ZoneOffset} from '../ZoneOffset';
|
|
24
|
+
import { ZoneOffset } from '../ZoneOffset';
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* Builder that can holds date and time fields and related date and time objects.
|
|
@@ -114,7 +114,7 @@ export class DateTimeBuilder extends TemporalAccessor {
|
|
|
114
114
|
requireNonNull(field, 'field');
|
|
115
115
|
const old = this.getFieldValue0(field); // check first for better error message
|
|
116
116
|
if (old != null && old !== value) {
|
|
117
|
-
throw new DateTimeException(
|
|
117
|
+
throw new DateTimeException(`Conflict found: ${field} ${old} differs from ${field} ${value}: ${this}`);
|
|
118
118
|
}
|
|
119
119
|
return this._putFieldValue0(field, value);
|
|
120
120
|
}
|
|
@@ -205,7 +205,7 @@ export class DateTimeBuilder extends TemporalAccessor {
|
|
|
205
205
|
}
|
|
206
206
|
const val2 = this.fieldValues.get(field);
|
|
207
207
|
if (val1 !== val2) {
|
|
208
|
-
throw new DateTimeException(
|
|
208
|
+
throw new DateTimeException(`Conflict found: Field ${field} ${val1} differs from ${field} ${val2} derived from ${date}`);
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
211
|
}
|
|
@@ -503,7 +503,7 @@ export class DateTimeBuilder extends TemporalAccessor {
|
|
|
503
503
|
if (this.time != null && this.time.isSupported(field)) {
|
|
504
504
|
return this.time.getLong(field);
|
|
505
505
|
}
|
|
506
|
-
throw new DateTimeException(
|
|
506
|
+
throw new DateTimeException(`Field not found: ${field}`);
|
|
507
507
|
}
|
|
508
508
|
return value;
|
|
509
509
|
}
|
|
@@ -4,24 +4,24 @@
|
|
|
4
4
|
* @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {assert, requireNonNull} from '../assert';
|
|
7
|
+
import { assert, requireNonNull } from '../assert';
|
|
8
8
|
|
|
9
|
-
import {DateTimeParseException, NullPointerException} from '../errors';
|
|
9
|
+
import { DateTimeParseException, NullPointerException } from '../errors';
|
|
10
10
|
|
|
11
|
-
import {Period} from '../Period';
|
|
11
|
+
import { Period } from '../Period';
|
|
12
12
|
|
|
13
|
-
import {ParsePosition} from './ParsePosition';
|
|
14
|
-
import {DateTimeBuilder} from './DateTimeBuilder';
|
|
15
|
-
import {DateTimeParseContext} from './DateTimeParseContext';
|
|
16
|
-
import {DateTimePrintContext} from './DateTimePrintContext';
|
|
17
|
-
import {DateTimeFormatterBuilder} from './DateTimeFormatterBuilder';
|
|
18
|
-
import {SignStyle} from './SignStyle';
|
|
19
|
-
import {StringBuilder} from './StringBuilder';
|
|
20
|
-
import {ResolverStyle} from './ResolverStyle';
|
|
13
|
+
import { ParsePosition } from './ParsePosition';
|
|
14
|
+
import { DateTimeBuilder } from './DateTimeBuilder';
|
|
15
|
+
import { DateTimeParseContext } from './DateTimeParseContext';
|
|
16
|
+
import { DateTimePrintContext } from './DateTimePrintContext';
|
|
17
|
+
import { DateTimeFormatterBuilder } from './DateTimeFormatterBuilder';
|
|
18
|
+
import { SignStyle } from './SignStyle';
|
|
19
|
+
import { StringBuilder } from './StringBuilder';
|
|
20
|
+
import { ResolverStyle } from './ResolverStyle';
|
|
21
21
|
|
|
22
|
-
import {IsoChronology} from '../chrono/IsoChronology';
|
|
23
|
-
import {ChronoField} from '../temporal/ChronoField';
|
|
24
|
-
import {createTemporalQuery} from '../temporal/TemporalQuery';
|
|
22
|
+
import { IsoChronology } from '../chrono/IsoChronology';
|
|
23
|
+
import { ChronoField } from '../temporal/ChronoField';
|
|
24
|
+
import { createTemporalQuery } from '../temporal/TemporalQuery';
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
*
|
|
@@ -502,11 +502,11 @@ export class DateTimeFormatter {
|
|
|
502
502
|
_createError(text, ex) {
|
|
503
503
|
let abbr = '';
|
|
504
504
|
if (text.length > 64) {
|
|
505
|
-
abbr = text.substring(0, 64)
|
|
505
|
+
abbr = `${text.substring(0, 64)}...`;
|
|
506
506
|
} else {
|
|
507
507
|
abbr = text;
|
|
508
508
|
}
|
|
509
|
-
return new DateTimeParseException(
|
|
509
|
+
return new DateTimeParseException(`Text '${abbr}' could not be parsed: ${ex.message}`, text, 0, ex);
|
|
510
510
|
}
|
|
511
511
|
|
|
512
512
|
|
|
@@ -529,16 +529,16 @@ export class DateTimeFormatter {
|
|
|
529
529
|
if (result == null || pos.getErrorIndex() >= 0 || (position == null && pos.getIndex() < text.length)) {
|
|
530
530
|
let abbr = '';
|
|
531
531
|
if (text.length > 64) {
|
|
532
|
-
abbr = text.substr(0, 64).toString()
|
|
532
|
+
abbr = `${text.substr(0, 64).toString()}...`;
|
|
533
533
|
} else {
|
|
534
534
|
abbr = text;
|
|
535
535
|
}
|
|
536
536
|
if (pos.getErrorIndex() >= 0) {
|
|
537
|
-
throw new DateTimeParseException(
|
|
538
|
-
|
|
537
|
+
throw new DateTimeParseException(`Text '${abbr}' could not be parsed at index ${
|
|
538
|
+
pos.getErrorIndex()}`, text, pos.getErrorIndex());
|
|
539
539
|
} else {
|
|
540
|
-
throw new DateTimeParseException(
|
|
541
|
-
|
|
540
|
+
throw new DateTimeParseException(`Text '${abbr}' could not be parsed, unparsed text found at index ${
|
|
541
|
+
pos.getIndex()}`, text, pos.getIndex());
|
|
542
542
|
}
|
|
543
543
|
}
|
|
544
544
|
return result.toBuilder();
|
|
@@ -703,10 +703,31 @@ export function _init() {
|
|
|
703
703
|
.appendValue(ChronoField.DAY_OF_WEEK)
|
|
704
704
|
.toFormatter(ResolverStyle.STRICT);
|
|
705
705
|
|
|
706
|
+
DateTimeFormatter.ISO_DATE = new DateTimeFormatterBuilder()
|
|
707
|
+
.parseCaseInsensitive()
|
|
708
|
+
.append(DateTimeFormatter.ISO_LOCAL_DATE)
|
|
709
|
+
.optionalStart()
|
|
710
|
+
.appendOffsetId()
|
|
711
|
+
.optionalEnd()
|
|
712
|
+
.toFormatter(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE);
|
|
713
|
+
|
|
714
|
+
DateTimeFormatter.ISO_TIME = new DateTimeFormatterBuilder()
|
|
715
|
+
.parseCaseInsensitive()
|
|
716
|
+
.append(DateTimeFormatter.ISO_LOCAL_TIME)
|
|
717
|
+
.optionalStart()
|
|
718
|
+
.appendOffsetId()
|
|
719
|
+
.optionalEnd()
|
|
720
|
+
.toFormatter(ResolverStyle.STRICT);
|
|
721
|
+
|
|
722
|
+
DateTimeFormatter.ISO_DATE_TIME = new DateTimeFormatterBuilder()
|
|
723
|
+
.append(DateTimeFormatter.ISO_LOCAL_DATE_TIME)
|
|
724
|
+
.optionalStart()
|
|
725
|
+
.appendOffsetId()
|
|
726
|
+
.optionalEnd()
|
|
727
|
+
.toFormatter(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE);
|
|
728
|
+
|
|
706
729
|
// TODO:
|
|
707
|
-
//
|
|
708
|
-
// ISO_TIME - https://www.threeten.org/threetenbp/apidocs/org/threeten/bp/format/DateTimeFormatter.html#ISO_TIME
|
|
709
|
-
// ISO_DATE_TIME - https://www.threeten.org/threetenbp/apidocs/org/threeten/bp/format/DateTimeFormatter.html#ISO_DATE_TIME
|
|
730
|
+
// RFC_1123_DATE_TIME - https://www.threeten.org/threetenbp/apidocs/org/threeten/bp/format/DateTimeFormatter.html#RFC_1123_DATE_TIME
|
|
710
731
|
|
|
711
732
|
DateTimeFormatter.PARSED_EXCESS_DAYS = createTemporalQuery('PARSED_EXCESS_DAYS', (temporal) => {
|
|
712
733
|
if (temporal instanceof DateTimeBuilder) {
|
|
@@ -4,33 +4,33 @@
|
|
|
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 {IllegalArgumentException, IllegalStateException} from '../errors';
|
|
9
|
-
import {MathUtil} from '../MathUtil';
|
|
10
|
-
|
|
11
|
-
import {LocalDate} from '../LocalDate';
|
|
12
|
-
import {LocalDateTime} from '../LocalDateTime';
|
|
13
|
-
import {ZoneOffset} from '../ZoneOffset';
|
|
14
|
-
import {ChronoLocalDate} from '../chrono/ChronoLocalDate';
|
|
15
|
-
import {ChronoField} from '../temporal/ChronoField';
|
|
16
|
-
import {IsoFields} from '../temporal/IsoFields';
|
|
17
|
-
import {TemporalQueries} from '../temporal/TemporalQueries';
|
|
18
|
-
|
|
19
|
-
import {DateTimeFormatter} from './DateTimeFormatter';
|
|
20
|
-
import {DecimalStyle} from './DecimalStyle';
|
|
21
|
-
import {SignStyle} from './SignStyle';
|
|
22
|
-
import {TextStyle} from './TextStyle';
|
|
23
|
-
import {ResolverStyle} from './ResolverStyle';
|
|
24
|
-
|
|
25
|
-
import {CharLiteralPrinterParser} from './parser/CharLiteralPrinterParser';
|
|
26
|
-
import {CompositePrinterParser} from './parser/CompositePrinterParser';
|
|
27
|
-
import {FractionPrinterParser} from './parser/FractionPrinterParser';
|
|
28
|
-
import {NumberPrinterParser, ReducedPrinterParser} from './parser/NumberPrinterParser';
|
|
29
|
-
import {OffsetIdPrinterParser} from './parser/OffsetIdPrinterParser';
|
|
30
|
-
import {PadPrinterParserDecorator} from './parser/PadPrinterParserDecorator';
|
|
31
|
-
import {SettingsParser} from './parser/SettingsParser';
|
|
32
|
-
import {StringLiteralPrinterParser} from './parser/StringLiteralPrinterParser';
|
|
33
|
-
import {ZoneIdPrinterParser} from './parser/ZoneIdPrinterParser';
|
|
7
|
+
import { assert, requireNonNull, requireInstance } from '../assert';
|
|
8
|
+
import { IllegalArgumentException, IllegalStateException } from '../errors';
|
|
9
|
+
import { MathUtil } from '../MathUtil';
|
|
10
|
+
|
|
11
|
+
import { LocalDate } from '../LocalDate';
|
|
12
|
+
import { LocalDateTime } from '../LocalDateTime';
|
|
13
|
+
import { ZoneOffset } from '../ZoneOffset';
|
|
14
|
+
import { ChronoLocalDate } from '../chrono/ChronoLocalDate';
|
|
15
|
+
import { ChronoField } from '../temporal/ChronoField';
|
|
16
|
+
import { IsoFields } from '../temporal/IsoFields';
|
|
17
|
+
import { TemporalQueries } from '../temporal/TemporalQueries';
|
|
18
|
+
|
|
19
|
+
import { DateTimeFormatter } from './DateTimeFormatter';
|
|
20
|
+
import { DecimalStyle } from './DecimalStyle';
|
|
21
|
+
import { SignStyle } from './SignStyle';
|
|
22
|
+
import { TextStyle } from './TextStyle';
|
|
23
|
+
import { ResolverStyle } from './ResolverStyle';
|
|
24
|
+
|
|
25
|
+
import { CharLiteralPrinterParser } from './parser/CharLiteralPrinterParser';
|
|
26
|
+
import { CompositePrinterParser } from './parser/CompositePrinterParser';
|
|
27
|
+
import { FractionPrinterParser } from './parser/FractionPrinterParser';
|
|
28
|
+
import { NumberPrinterParser, ReducedPrinterParser } from './parser/NumberPrinterParser';
|
|
29
|
+
import { OffsetIdPrinterParser } from './parser/OffsetIdPrinterParser';
|
|
30
|
+
import { PadPrinterParserDecorator } from './parser/PadPrinterParserDecorator';
|
|
31
|
+
import { SettingsParser } from './parser/SettingsParser';
|
|
32
|
+
import { StringLiteralPrinterParser } from './parser/StringLiteralPrinterParser';
|
|
33
|
+
import { ZoneIdPrinterParser } from './parser/ZoneIdPrinterParser';
|
|
34
34
|
|
|
35
35
|
const MAX_WIDTH = 15; // can't parse all numbers with more then 15 digits in javascript
|
|
36
36
|
|
|
@@ -546,7 +546,7 @@ export class DateTimeFormatterBuilder {
|
|
|
546
546
|
*/
|
|
547
547
|
appendInstant(fractionalDigits=-2) {
|
|
548
548
|
if (fractionalDigits < -2 || fractionalDigits > 9) {
|
|
549
|
-
throw new IllegalArgumentException(
|
|
549
|
+
throw new IllegalArgumentException(`Invalid fractional digits: ${fractionalDigits}`);
|
|
550
550
|
}
|
|
551
551
|
this._appendInternal(new InstantPrinterParser(fractionalDigits));
|
|
552
552
|
return this;
|
|
@@ -813,19 +813,19 @@ export class DateTimeFormatterBuilder {
|
|
|
813
813
|
// empty implementations of locale functionality, be implemented/overridden by js-joda-locale
|
|
814
814
|
|
|
815
815
|
appendZoneText() {
|
|
816
|
-
throw new IllegalArgumentException('Pattern using (localized) text not implemented, use js-joda
|
|
816
|
+
throw new IllegalArgumentException('Pattern using (localized) text not implemented, use @js-joda/locale plugin!');
|
|
817
817
|
}
|
|
818
818
|
|
|
819
819
|
appendText() {
|
|
820
|
-
throw new IllegalArgumentException('Pattern using (localized) text not implemented, use js-joda
|
|
820
|
+
throw new IllegalArgumentException('Pattern using (localized) text not implemented, use @js-joda/locale plugin!');
|
|
821
821
|
}
|
|
822
822
|
|
|
823
823
|
appendLocalizedOffset() {
|
|
824
|
-
throw new IllegalArgumentException('Pattern using (localized) text not implemented, use js-joda
|
|
824
|
+
throw new IllegalArgumentException('Pattern using (localized) text not implemented, use @js-joda/locale plugin!');
|
|
825
825
|
}
|
|
826
826
|
|
|
827
827
|
appendWeekField() {
|
|
828
|
-
throw new IllegalArgumentException('Pattern using (localized) text not implemented, use js-joda
|
|
828
|
+
throw new IllegalArgumentException('Pattern using (localized) text not implemented, use @js-joda/locale plugin!');
|
|
829
829
|
}
|
|
830
830
|
|
|
831
831
|
//-----------------------------------------------------------------------
|
|
@@ -879,7 +879,7 @@ export class DateTimeFormatterBuilder {
|
|
|
879
879
|
}
|
|
880
880
|
if (pad === 0) {
|
|
881
881
|
throw new IllegalArgumentException(
|
|
882
|
-
|
|
882
|
+
`Pad letter 'p' must be followed by valid pad pattern: ${pattern}`);
|
|
883
883
|
}
|
|
884
884
|
this.padNext(pad); // pad and continue parsing
|
|
885
885
|
}
|
|
@@ -889,7 +889,7 @@ export class DateTimeFormatterBuilder {
|
|
|
889
889
|
this._parseField(cur, count, field);
|
|
890
890
|
} else if (cur === 'z') {
|
|
891
891
|
if (count > 4) {
|
|
892
|
-
throw new IllegalArgumentException(
|
|
892
|
+
throw new IllegalArgumentException(`Too many pattern letters: ${cur}`);
|
|
893
893
|
} else if (count === 4) {
|
|
894
894
|
this.appendZoneText(TextStyle.FULL);
|
|
895
895
|
} else {
|
|
@@ -897,7 +897,7 @@ export class DateTimeFormatterBuilder {
|
|
|
897
897
|
}
|
|
898
898
|
} else if (cur === 'V') {
|
|
899
899
|
if (count !== 2) {
|
|
900
|
-
throw new IllegalArgumentException(
|
|
900
|
+
throw new IllegalArgumentException(`Pattern letter count must be 2: ${cur}`);
|
|
901
901
|
}
|
|
902
902
|
this.appendZoneId();
|
|
903
903
|
} else if (cur === 'Z') {
|
|
@@ -908,7 +908,7 @@ export class DateTimeFormatterBuilder {
|
|
|
908
908
|
} else if (count === 5) {
|
|
909
909
|
this.appendOffset('+HH:MM:ss', 'Z');
|
|
910
910
|
} else {
|
|
911
|
-
throw new IllegalArgumentException(
|
|
911
|
+
throw new IllegalArgumentException(`Too many pattern letters: ${cur}`);
|
|
912
912
|
}
|
|
913
913
|
} else if (cur === 'O') {
|
|
914
914
|
if (count === 1) {
|
|
@@ -916,33 +916,33 @@ export class DateTimeFormatterBuilder {
|
|
|
916
916
|
} else if (count === 4) {
|
|
917
917
|
this.appendLocalizedOffset(TextStyle.FULL);
|
|
918
918
|
} else {
|
|
919
|
-
throw new IllegalArgumentException(
|
|
919
|
+
throw new IllegalArgumentException(`Pattern letter count must be 1 or 4: ${cur}`);
|
|
920
920
|
}
|
|
921
921
|
} else if (cur === 'X') {
|
|
922
922
|
if (count > 5) {
|
|
923
|
-
throw new IllegalArgumentException(
|
|
923
|
+
throw new IllegalArgumentException(`Too many pattern letters: ${cur}`);
|
|
924
924
|
}
|
|
925
925
|
this.appendOffset(OffsetIdPrinterParser.PATTERNS[count + (count === 1 ? 0 : 1)], 'Z');
|
|
926
926
|
} else if (cur === 'x') {
|
|
927
927
|
if (count > 5) {
|
|
928
|
-
throw new IllegalArgumentException(
|
|
928
|
+
throw new IllegalArgumentException(`Too many pattern letters: ${cur}`);
|
|
929
929
|
}
|
|
930
930
|
const zero = (count === 1 ? '+00' : (count % 2 === 0 ? '+0000' : '+00:00'));
|
|
931
931
|
this.appendOffset(OffsetIdPrinterParser.PATTERNS[count + (count === 1 ? 0 : 1)], zero);
|
|
932
932
|
} else if (cur === 'W') {
|
|
933
933
|
if (count > 1) {
|
|
934
|
-
throw new IllegalArgumentException(
|
|
934
|
+
throw new IllegalArgumentException(`Too many pattern letters: ${cur}`);
|
|
935
935
|
}
|
|
936
936
|
this.appendWeekField('W', count);
|
|
937
937
|
} else if (cur === 'w') {
|
|
938
938
|
if (count > 2) {
|
|
939
|
-
throw new IllegalArgumentException(
|
|
939
|
+
throw new IllegalArgumentException(`Too many pattern letters: ${cur}`);
|
|
940
940
|
}
|
|
941
941
|
this.appendWeekField('w', count);
|
|
942
942
|
} else if (cur === 'Y') {
|
|
943
943
|
this.appendWeekField('Y', count);
|
|
944
944
|
} else {
|
|
945
|
-
throw new IllegalArgumentException(
|
|
945
|
+
throw new IllegalArgumentException(`Unknown pattern letter: ${cur}`);
|
|
946
946
|
}
|
|
947
947
|
pos--;
|
|
948
948
|
|
|
@@ -959,7 +959,7 @@ export class DateTimeFormatterBuilder {
|
|
|
959
959
|
}
|
|
960
960
|
}
|
|
961
961
|
if (pos >= pattern.length) {
|
|
962
|
-
throw new IllegalArgumentException(
|
|
962
|
+
throw new IllegalArgumentException(`Pattern ends with an incomplete string literal: ${pattern}`);
|
|
963
963
|
}
|
|
964
964
|
const str = pattern.substring(start + 1, pos);
|
|
965
965
|
if (str.length === 0) {
|
|
@@ -978,7 +978,7 @@ export class DateTimeFormatterBuilder {
|
|
|
978
978
|
this.optionalEnd();
|
|
979
979
|
|
|
980
980
|
} else if (cur === '{' || cur === '}' || cur === '#') {
|
|
981
|
-
throw new IllegalArgumentException(
|
|
981
|
+
throw new IllegalArgumentException(`Pattern includes reserved character: '${cur}'`);
|
|
982
982
|
} else {
|
|
983
983
|
this.appendLiteral(cur);
|
|
984
984
|
}
|
|
@@ -1016,7 +1016,7 @@ export class DateTimeFormatterBuilder {
|
|
|
1016
1016
|
this.appendText(field, TextStyle.NARROW);
|
|
1017
1017
|
break;
|
|
1018
1018
|
default:
|
|
1019
|
-
throw new IllegalArgumentException(
|
|
1019
|
+
throw new IllegalArgumentException(`Too many pattern letters: ${cur}`);
|
|
1020
1020
|
}
|
|
1021
1021
|
break;
|
|
1022
1022
|
case 'L':
|
|
@@ -1038,7 +1038,7 @@ export class DateTimeFormatterBuilder {
|
|
|
1038
1038
|
this.appendText(field, TextStyle.NARROW_STANDALONE);
|
|
1039
1039
|
break;
|
|
1040
1040
|
default:
|
|
1041
|
-
throw new IllegalArgumentException(
|
|
1041
|
+
throw new IllegalArgumentException(`Too many pattern letters: ${cur}`);
|
|
1042
1042
|
}
|
|
1043
1043
|
break;
|
|
1044
1044
|
case 'e':
|
|
@@ -1057,7 +1057,7 @@ export class DateTimeFormatterBuilder {
|
|
|
1057
1057
|
this.appendText(field, TextStyle.NARROW);
|
|
1058
1058
|
break;
|
|
1059
1059
|
default:
|
|
1060
|
-
throw new IllegalArgumentException(
|
|
1060
|
+
throw new IllegalArgumentException(`Too many pattern letters: ${cur}`);
|
|
1061
1061
|
}
|
|
1062
1062
|
// eslint-disable-next-line no-unreachable
|
|
1063
1063
|
break;
|
|
@@ -1067,7 +1067,7 @@ export class DateTimeFormatterBuilder {
|
|
|
1067
1067
|
this.appendWeekField('c', count);
|
|
1068
1068
|
break;
|
|
1069
1069
|
case 2:
|
|
1070
|
-
throw new IllegalArgumentException(
|
|
1070
|
+
throw new IllegalArgumentException(`Invalid number of pattern letters: ${cur}`);
|
|
1071
1071
|
case 3:
|
|
1072
1072
|
this.appendText(field, TextStyle.SHORT_STANDALONE);
|
|
1073
1073
|
break;
|
|
@@ -1078,7 +1078,7 @@ export class DateTimeFormatterBuilder {
|
|
|
1078
1078
|
this.appendText(field, TextStyle.NARROW_STANDALONE);
|
|
1079
1079
|
break;
|
|
1080
1080
|
default:
|
|
1081
|
-
throw new IllegalArgumentException(
|
|
1081
|
+
throw new IllegalArgumentException(`Too many pattern letters: ${cur}`);
|
|
1082
1082
|
}
|
|
1083
1083
|
// eslint-disable-next-line no-unreachable
|
|
1084
1084
|
break;
|
|
@@ -1086,7 +1086,7 @@ export class DateTimeFormatterBuilder {
|
|
|
1086
1086
|
if (count === 1) {
|
|
1087
1087
|
this.appendText(field, TextStyle.SHORT);
|
|
1088
1088
|
} else {
|
|
1089
|
-
throw new IllegalArgumentException(
|
|
1089
|
+
throw new IllegalArgumentException(`Too many pattern letters: ${cur}`);
|
|
1090
1090
|
}
|
|
1091
1091
|
// eslint-disable-next-line no-unreachable
|
|
1092
1092
|
break;
|
|
@@ -1105,7 +1105,7 @@ export class DateTimeFormatterBuilder {
|
|
|
1105
1105
|
this.appendText(field, TextStyle.NARROW);
|
|
1106
1106
|
break;
|
|
1107
1107
|
default:
|
|
1108
|
-
throw new IllegalArgumentException(
|
|
1108
|
+
throw new IllegalArgumentException(`Too many pattern letters: ${cur}`);
|
|
1109
1109
|
}
|
|
1110
1110
|
// eslint-disable-next-line no-unreachable
|
|
1111
1111
|
break;
|
|
@@ -1116,7 +1116,7 @@ export class DateTimeFormatterBuilder {
|
|
|
1116
1116
|
if (count === 1) {
|
|
1117
1117
|
this.appendValue(field);
|
|
1118
1118
|
} else {
|
|
1119
|
-
throw new IllegalArgumentException(
|
|
1119
|
+
throw new IllegalArgumentException(`Too many pattern letters: ${cur}`);
|
|
1120
1120
|
}
|
|
1121
1121
|
break;
|
|
1122
1122
|
case 'd':
|
|
@@ -1131,7 +1131,7 @@ export class DateTimeFormatterBuilder {
|
|
|
1131
1131
|
} else if (count === 2) {
|
|
1132
1132
|
this.appendValue(field, count);
|
|
1133
1133
|
} else {
|
|
1134
|
-
throw new IllegalArgumentException(
|
|
1134
|
+
throw new IllegalArgumentException(`Too many pattern letters: ${cur}`);
|
|
1135
1135
|
}
|
|
1136
1136
|
break;
|
|
1137
1137
|
case 'D':
|
|
@@ -1140,7 +1140,7 @@ export class DateTimeFormatterBuilder {
|
|
|
1140
1140
|
} else if (count <= 3) {
|
|
1141
1141
|
this.appendValue(field, count);
|
|
1142
1142
|
} else {
|
|
1143
|
-
throw new IllegalArgumentException(
|
|
1143
|
+
throw new IllegalArgumentException(`Too many pattern letters: ${cur}`);
|
|
1144
1144
|
}
|
|
1145
1145
|
break;
|
|
1146
1146
|
default:
|
|
@@ -1210,7 +1210,7 @@ export class DateTimeFormatterBuilder {
|
|
|
1210
1210
|
*/
|
|
1211
1211
|
_padNext2(padWidth, padChar) {
|
|
1212
1212
|
if (padWidth < 1) {
|
|
1213
|
-
throw new IllegalArgumentException(
|
|
1213
|
+
throw new IllegalArgumentException(`The pad width must be at least one but was ${padWidth}`);
|
|
1214
1214
|
}
|
|
1215
1215
|
this._active._padNextWidth = padWidth;
|
|
1216
1216
|
this._active._padNextChar = padChar;
|
|
@@ -1441,7 +1441,7 @@ class InstantPrinterParser {
|
|
|
1441
1441
|
}
|
|
1442
1442
|
if (hi < 0) {
|
|
1443
1443
|
if (ldt.year() === -10000) {
|
|
1444
|
-
buf.replace(pos, pos + 2,
|
|
1444
|
+
buf.replace(pos, pos + 2, `${hi - 1}`);
|
|
1445
1445
|
} else if (lo === 0) {
|
|
1446
1446
|
buf.insert(pos, hi);
|
|
1447
1447
|
} else {
|
|
@@ -1454,11 +1454,11 @@ class InstantPrinterParser {
|
|
|
1454
1454
|
if (inNano !== 0) {
|
|
1455
1455
|
buf.append('.');
|
|
1456
1456
|
if (MathUtil.intMod(inNano, 1000000) === 0) {
|
|
1457
|
-
buf.append((
|
|
1457
|
+
buf.append((`${MathUtil.intDiv(inNano, 1000000) + 1000}`).substring(1));
|
|
1458
1458
|
} else if (MathUtil.intMod(inNano, 1000) === 0) {
|
|
1459
|
-
buf.append((
|
|
1459
|
+
buf.append((`${MathUtil.intDiv(inNano, 1000) + 1000000}`).substring(1));
|
|
1460
1460
|
} else {
|
|
1461
|
-
buf.append((
|
|
1461
|
+
buf.append((`${(inNano) + 1000000000}`).substring(1));
|
|
1462
1462
|
}
|
|
1463
1463
|
}
|
|
1464
1464
|
} else if (this.fractionalDigits > 0 || (this.fractionalDigits === -1 && inNano > 0)) {
|
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
* @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {assert, requireNonNull} from '../assert';
|
|
7
|
+
import { assert, requireNonNull } from '../assert';
|
|
8
8
|
|
|
9
|
-
import {DateTimeBuilder} from './DateTimeBuilder';
|
|
10
|
-
import {EnumMap} from './EnumMap';
|
|
9
|
+
import { DateTimeBuilder } from './DateTimeBuilder';
|
|
10
|
+
import { EnumMap } from './EnumMap';
|
|
11
11
|
|
|
12
|
-
import {IsoChronology} from '../chrono/IsoChronology';
|
|
13
|
-
import {Temporal} from '../temporal/Temporal';
|
|
14
|
-
import {TemporalQueries} from '../temporal/TemporalQueries';
|
|
12
|
+
import { IsoChronology } from '../chrono/IsoChronology';
|
|
13
|
+
import { Temporal } from '../temporal/Temporal';
|
|
14
|
+
import { TemporalQueries } from '../temporal/TemporalQueries';
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* @private
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {DateTimeException} from '../errors';
|
|
7
|
+
import { DateTimeException } from '../errors';
|
|
8
8
|
|
|
9
|
-
import {DateTimeFormatter} from './DateTimeFormatter';
|
|
9
|
+
import { DateTimeFormatter } from './DateTimeFormatter';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* @private
|
|
@@ -72,7 +72,7 @@ export class DateTimePrintContext{
|
|
|
72
72
|
getValueQuery(query) {
|
|
73
73
|
const result = this._temporal.query(query);
|
|
74
74
|
if (result == null && this._optional === 0) {
|
|
75
|
-
throw new DateTimeException(
|
|
75
|
+
throw new DateTimeException(`Unable to extract value: ${this._temporal}`);
|
|
76
76
|
}
|
|
77
77
|
return result;
|
|
78
78
|
}
|
|
@@ -98,7 +98,7 @@ export class DecimalStyle {
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
toString() {
|
|
101
|
-
return
|
|
101
|
+
return `DecimalStyle[${this._zeroDigit}${this._positiveSign}${this._negativeSign}${this._decimalSeparator}]`;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
static of(){
|
package/src/format/SignStyle.js
CHANGED
package/src/format/TextStyle.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {IllegalArgumentException} from '../../errors';
|
|
7
|
+
import { IllegalArgumentException } from '../../errors';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Prints or parses a char literal.
|
|
@@ -14,7 +14,7 @@ export class CharLiteralPrinterParser {
|
|
|
14
14
|
|
|
15
15
|
constructor(literal) {
|
|
16
16
|
if (literal.length > 1) {
|
|
17
|
-
throw new IllegalArgumentException(
|
|
17
|
+
throw new IllegalArgumentException(`invalid literal, too long: "${literal}"`);
|
|
18
18
|
}
|
|
19
19
|
this._literal = literal;
|
|
20
20
|
}
|
|
@@ -40,7 +40,7 @@ export class CharLiteralPrinterParser {
|
|
|
40
40
|
if (this._literal === '\'') {
|
|
41
41
|
return "''";
|
|
42
42
|
}
|
|
43
|
-
return
|
|
43
|
+
return `'${this._literal}'`;
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|