@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
|
@@ -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(`Text '${
|
|
509
|
+
return new DateTimeParseException(`Text '${abbr}' could not be parsed: ${ex.message}`, text, 0, ex);
|
|
510
510
|
}
|
|
511
511
|
|
|
512
512
|
|
|
@@ -529,15 +529,15 @@ 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(`Text '${
|
|
537
|
+
throw new DateTimeParseException(`Text '${abbr}' could not be parsed at index ${
|
|
538
538
|
pos.getErrorIndex()}`, text, pos.getErrorIndex());
|
|
539
539
|
} else {
|
|
540
|
-
throw new DateTimeParseException(`Text '${
|
|
540
|
+
throw new DateTimeParseException(`Text '${abbr}' could not be parsed, unparsed text found at index ${
|
|
541
541
|
pos.getIndex()}`, text, pos.getIndex());
|
|
542
542
|
}
|
|
543
543
|
}
|
|
@@ -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(`Invalid fractional digits: ${
|
|
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
|
-
`Pad letter 'p' must be followed by valid pad pattern: ${
|
|
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(`Too many pattern letters: ${
|
|
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(`Pattern letter count must be 2: ${
|
|
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(`Too many pattern letters: ${
|
|
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(`Pattern letter count must be 1 or 4: ${
|
|
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(`Too many pattern letters: ${
|
|
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(`Too many pattern letters: ${
|
|
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(`Too many pattern letters: ${
|
|
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(`Too many pattern letters: ${
|
|
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(`Unknown pattern letter: ${
|
|
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(`Pattern ends with an incomplete string literal: ${
|
|
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(`Pattern includes reserved character: '${
|
|
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(`Too many pattern letters: ${
|
|
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(`Too many pattern letters: ${
|
|
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(`Too many pattern letters: ${
|
|
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(`Invalid number of pattern letters: ${
|
|
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(`Too many pattern letters: ${
|
|
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(`Too many pattern letters: ${
|
|
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(`Too many pattern letters: ${
|
|
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(`Too many pattern letters: ${
|
|
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(`Too many pattern letters: ${
|
|
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(`Too many pattern letters: ${
|
|
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(`The pad width must be at least one but was ${
|
|
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(`Unable to extract value: ${
|
|
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 `DecimalStyle[${
|
|
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(`invalid literal, too long: "${
|
|
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
|
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {requireNonNull} from '../../assert';
|
|
8
|
-
import {IllegalArgumentException} from '../../errors';
|
|
9
|
-
import {MathUtil} from '../../MathUtil';
|
|
7
|
+
import { requireNonNull } from '../../assert';
|
|
8
|
+
import { IllegalArgumentException } from '../../errors';
|
|
9
|
+
import { MathUtil } from '../../MathUtil';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* TODO optimize FractionPrinterParser, fix documentation
|
|
@@ -27,17 +27,17 @@ export class FractionPrinterParser {
|
|
|
27
27
|
constructor(field, minWidth, maxWidth, decimalPoint) {
|
|
28
28
|
requireNonNull(field, 'field');
|
|
29
29
|
if (field.range().isFixed() === false) {
|
|
30
|
-
throw new IllegalArgumentException(`Field must have a fixed set of values: ${
|
|
30
|
+
throw new IllegalArgumentException(`Field must have a fixed set of values: ${field}`);
|
|
31
31
|
}
|
|
32
32
|
if (minWidth < 0 || minWidth > 9) {
|
|
33
|
-
throw new IllegalArgumentException(`Minimum width must be from 0 to 9 inclusive but was ${
|
|
33
|
+
throw new IllegalArgumentException(`Minimum width must be from 0 to 9 inclusive but was ${minWidth}`);
|
|
34
34
|
}
|
|
35
35
|
if (maxWidth < 1 || maxWidth > 9) {
|
|
36
|
-
throw new IllegalArgumentException(`Maximum width must be from 1 to 9 inclusive but was ${
|
|
36
|
+
throw new IllegalArgumentException(`Maximum width must be from 1 to 9 inclusive but was ${maxWidth}`);
|
|
37
37
|
}
|
|
38
38
|
if (maxWidth < minWidth) {
|
|
39
39
|
throw new IllegalArgumentException(`Maximum width must exceed or equal the minimum width but ${
|
|
40
|
-
maxWidth
|
|
40
|
+
maxWidth} < ${minWidth}`);
|
|
41
41
|
}
|
|
42
42
|
this.field = field;
|
|
43
43
|
this.minWidth = minWidth;
|
|
@@ -132,7 +132,7 @@ export class FractionPrinterParser {
|
|
|
132
132
|
const _range = range.maximum() - _min + 1;
|
|
133
133
|
const _value = value - _min;
|
|
134
134
|
const _scaled = MathUtil.intDiv((_value * 1000000000), _range);
|
|
135
|
-
let fraction = `${
|
|
135
|
+
let fraction = `${_scaled}`;
|
|
136
136
|
while(fraction.length < 9){
|
|
137
137
|
fraction = zeroDigit + fraction;
|
|
138
138
|
}
|
|
@@ -156,7 +156,7 @@ export class FractionPrinterParser {
|
|
|
156
156
|
|
|
157
157
|
toString() {
|
|
158
158
|
const decimal = (this.decimalPoint ? ',DecimalPoint' : '');
|
|
159
|
-
return `Fraction(${
|
|
159
|
+
return `Fraction(${this.field},${this.minWidth},${this.maxWidth}${decimal})`;
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
|
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
* @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {assert} from '../../assert';
|
|
8
|
-
import {ArithmeticException, DateTimeException, IllegalArgumentException} from '../../errors';
|
|
9
|
-
import {MathUtil} from '../../MathUtil';
|
|
7
|
+
import { assert } from '../../assert';
|
|
8
|
+
import { ArithmeticException, DateTimeException, IllegalArgumentException } from '../../errors';
|
|
9
|
+
import { MathUtil } from '../../MathUtil';
|
|
10
10
|
|
|
11
|
-
import {IsoChronology} from '../../chrono/IsoChronology';
|
|
11
|
+
import { IsoChronology } from '../../chrono/IsoChronology';
|
|
12
12
|
|
|
13
|
-
import {SignStyle} from '../SignStyle';
|
|
13
|
+
import { SignStyle } from '../SignStyle';
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
const MAX_WIDTH = 15; // can't parse all numbers with more then 15 digits in javascript
|
|
@@ -79,11 +79,11 @@ export class NumberPrinterParser {
|
|
|
79
79
|
}
|
|
80
80
|
const value = this._getValue(context, contextValue);
|
|
81
81
|
const symbols = context.symbols();
|
|
82
|
-
let str = `${
|
|
82
|
+
let str = `${Math.abs(value)}`;
|
|
83
83
|
if (str.length > this._maxWidth) {
|
|
84
|
-
throw new DateTimeException(`Field ${
|
|
85
|
-
} cannot be printed as the value ${
|
|
86
|
-
} exceeds the maximum print width of ${
|
|
84
|
+
throw new DateTimeException(`Field ${this._field
|
|
85
|
+
} cannot be printed as the value ${value
|
|
86
|
+
} exceeds the maximum print width of ${this._maxWidth}`);
|
|
87
87
|
}
|
|
88
88
|
str = symbols.convertNumberToI18N(str);
|
|
89
89
|
|
|
@@ -106,8 +106,8 @@ export class NumberPrinterParser {
|
|
|
106
106
|
buf.append(symbols.negativeSign());
|
|
107
107
|
break;
|
|
108
108
|
case SignStyle.NOT_NEGATIVE:
|
|
109
|
-
throw new DateTimeException(`Field ${
|
|
110
|
-
} cannot be printed as the value ${
|
|
109
|
+
throw new DateTimeException(`Field ${this._field
|
|
110
|
+
} cannot be printed as the value ${value
|
|
111
111
|
} cannot be negative according to the SignStyle`);
|
|
112
112
|
}
|
|
113
113
|
}
|
|
@@ -230,12 +230,12 @@ export class NumberPrinterParser {
|
|
|
230
230
|
|
|
231
231
|
toString() {
|
|
232
232
|
if (this._minWidth === 1 && this._maxWidth === MAX_WIDTH && this._signStyle === SignStyle.NORMAL) {
|
|
233
|
-
return `Value(${
|
|
233
|
+
return `Value(${this._field})`;
|
|
234
234
|
}
|
|
235
235
|
if (this._minWidth === this._maxWidth && this._signStyle === SignStyle.NOT_NEGATIVE) {
|
|
236
|
-
return `Value(${
|
|
236
|
+
return `Value(${this._field},${this._minWidth})`;
|
|
237
237
|
}
|
|
238
|
-
return `Value(${
|
|
238
|
+
return `Value(${this._field},${this._minWidth},${this._maxWidth},${this._signStyle})`;
|
|
239
239
|
}
|
|
240
240
|
|
|
241
241
|
}
|
|
@@ -258,10 +258,10 @@ export class ReducedPrinterParser extends NumberPrinterParser {
|
|
|
258
258
|
constructor(field, width, maxWidth, baseValue, baseDate) {
|
|
259
259
|
super(field, width, maxWidth, SignStyle.NOT_NEGATIVE);
|
|
260
260
|
if (width < 1 || width > 10) {
|
|
261
|
-
throw new IllegalArgumentException(`The width must be from 1 to 10 inclusive but was ${
|
|
261
|
+
throw new IllegalArgumentException(`The width must be from 1 to 10 inclusive but was ${width}`);
|
|
262
262
|
}
|
|
263
263
|
if (maxWidth < 1 || maxWidth > 10) {
|
|
264
|
-
throw new IllegalArgumentException(`The maxWidth must be from 1 to 10 inclusive but was ${
|
|
264
|
+
throw new IllegalArgumentException(`The maxWidth must be from 1 to 10 inclusive but was ${maxWidth}`);
|
|
265
265
|
}
|
|
266
266
|
if (maxWidth < width) {
|
|
267
267
|
throw new IllegalArgumentException('The maxWidth must be greater than the width');
|
|
@@ -361,7 +361,7 @@ export class ReducedPrinterParser extends NumberPrinterParser {
|
|
|
361
361
|
}
|
|
362
362
|
|
|
363
363
|
toString() {
|
|
364
|
-
return `ReducedValue(${
|
|
364
|
+
return `ReducedValue(${this._field},${this._minWidth},${this._maxWidth},${this._baseDate != null ? this._baseDate : this._baseValue})`;
|
|
365
365
|
}
|
|
366
366
|
}
|
|
367
367
|
|