@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/ZoneId.js
CHANGED
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
* @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {abstractMethodFail} from './assert';
|
|
8
|
-
import {DateTimeException} from './errors';
|
|
7
|
+
import { abstractMethodFail } from './assert';
|
|
8
|
+
import { DateTimeException } from './errors';
|
|
9
9
|
|
|
10
|
-
import {StringUtil} from './StringUtil';
|
|
10
|
+
import { StringUtil } from './StringUtil';
|
|
11
11
|
|
|
12
|
-
import {Instant} from './Instant';
|
|
12
|
+
import { Instant } from './Instant';
|
|
13
13
|
|
|
14
14
|
export class ZoneId {
|
|
15
15
|
/**
|
|
@@ -80,7 +80,7 @@ export class ZoneId {
|
|
|
80
80
|
*/
|
|
81
81
|
static of(zoneId) {
|
|
82
82
|
// Find implementation at {@link ZoneIdFactory}
|
|
83
|
-
throw new DateTimeException(`not supported operation${
|
|
83
|
+
throw new DateTimeException(`not supported operation${zoneId}`);
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
/**
|
|
@@ -98,7 +98,7 @@ export class ZoneId {
|
|
|
98
98
|
*/
|
|
99
99
|
static ofOffset(prefix, offset) {
|
|
100
100
|
// Find implementation at {@link ZoneIdFactory}
|
|
101
|
-
throw new DateTimeException(`not supported operation${
|
|
101
|
+
throw new DateTimeException(`not supported operation${prefix}${offset}`);
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
|
|
@@ -120,7 +120,7 @@ export class ZoneId {
|
|
|
120
120
|
*/
|
|
121
121
|
static from(temporal) {
|
|
122
122
|
// Find implementation at {@link ZoneIdFactory}
|
|
123
|
-
throw new DateTimeException(`not supported operation${
|
|
123
|
+
throw new DateTimeException(`not supported operation${temporal}`);
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
//-----------------------------------------------------------------------
|
package/src/ZoneIdFactory.js
CHANGED
|
@@ -4,17 +4,17 @@
|
|
|
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, IllegalArgumentException} from './errors';
|
|
9
|
-
import {StringUtil} from './StringUtil';
|
|
7
|
+
import { requireNonNull } from './assert';
|
|
8
|
+
import { DateTimeException, IllegalArgumentException } from './errors';
|
|
9
|
+
import { StringUtil } from './StringUtil';
|
|
10
10
|
|
|
11
|
-
import {ZoneOffset} from './ZoneOffset';
|
|
12
|
-
import {ZoneRegion} from './ZoneRegion';
|
|
13
|
-
import {ZoneId} from './ZoneId';
|
|
11
|
+
import { ZoneOffset } from './ZoneOffset';
|
|
12
|
+
import { ZoneRegion } from './ZoneRegion';
|
|
13
|
+
import { ZoneId } from './ZoneId';
|
|
14
14
|
|
|
15
|
-
import {TemporalQueries} from './temporal/TemporalQueries';
|
|
16
|
-
import {SystemDefaultZoneId} from './zone/SystemDefaultZoneId';
|
|
17
|
-
import {ZoneRulesProvider} from './zone/ZoneRulesProvider';
|
|
15
|
+
import { TemporalQueries } from './temporal/TemporalQueries';
|
|
16
|
+
import { SystemDefaultZoneId } from './zone/SystemDefaultZoneId';
|
|
17
|
+
import { ZoneRulesProvider } from './zone/ZoneRulesProvider';
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* @see {@link ZoneId}
|
|
@@ -96,7 +96,7 @@ export class ZoneIdFactory {
|
|
|
96
96
|
return ZoneOffset.UTC;
|
|
97
97
|
}
|
|
98
98
|
if (zoneId.length === 1) {
|
|
99
|
-
throw new DateTimeException(`Invalid zone: ${
|
|
99
|
+
throw new DateTimeException(`Invalid zone: ${zoneId}`);
|
|
100
100
|
}
|
|
101
101
|
if (StringUtil.startsWith(zoneId, '+') || StringUtil.startsWith(zoneId, '-')) {
|
|
102
102
|
return ZoneOffset.of(zoneId);
|
|
@@ -117,7 +117,7 @@ export class ZoneIdFactory {
|
|
|
117
117
|
if (offset.totalSeconds() === 0) {
|
|
118
118
|
return new ZoneRegion('UT', offset.rules());
|
|
119
119
|
}
|
|
120
|
-
return new ZoneRegion(`UT${
|
|
120
|
+
return new ZoneRegion(`UT${offset.id()}`, offset.rules());
|
|
121
121
|
}
|
|
122
122
|
// javascript special case
|
|
123
123
|
if(zoneId === 'SYSTEM'){
|
|
@@ -151,7 +151,7 @@ export class ZoneIdFactory {
|
|
|
151
151
|
}
|
|
152
152
|
return new ZoneRegion(prefix + offset.id(), offset.rules());
|
|
153
153
|
}
|
|
154
|
-
throw new IllegalArgumentException(`Invalid prefix, must be GMT, UTC or UT: ${
|
|
154
|
+
throw new IllegalArgumentException(`Invalid prefix, must be GMT, UTC or UT: ${prefix}`);
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
|
|
@@ -176,7 +176,7 @@ export class ZoneIdFactory {
|
|
|
176
176
|
const obj = temporal.query(TemporalQueries.zone());
|
|
177
177
|
if (obj == null) {
|
|
178
178
|
throw new DateTimeException(`Unable to obtain ZoneId from TemporalAccessor: ${
|
|
179
|
-
temporal
|
|
179
|
+
temporal}, type ${temporal.constructor != null ? temporal.constructor.name : ''}`);
|
|
180
180
|
}
|
|
181
181
|
return obj;
|
|
182
182
|
}
|
package/src/ZoneOffset.js
CHANGED
|
@@ -4,17 +4,17 @@
|
|
|
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 {LocalTime} from './LocalTime';
|
|
12
|
-
import {ZoneId} from './ZoneId';
|
|
11
|
+
import { LocalTime } from './LocalTime';
|
|
12
|
+
import { ZoneId } from './ZoneId';
|
|
13
13
|
|
|
14
|
-
import {ChronoField} from './temporal/ChronoField';
|
|
15
|
-
import {TemporalQueries} from './temporal/TemporalQueries';
|
|
14
|
+
import { ChronoField } from './temporal/ChronoField';
|
|
15
|
+
import { TemporalQueries } from './temporal/TemporalQueries';
|
|
16
16
|
|
|
17
|
-
import {ZoneRules} from './zone/ZoneRules';
|
|
17
|
+
import { ZoneRules } from './zone/ZoneRules';
|
|
18
18
|
|
|
19
19
|
const SECONDS_CACHE = {};
|
|
20
20
|
const ID_CACHE = {};
|
|
@@ -74,9 +74,9 @@ export class ZoneOffset extends ZoneId {
|
|
|
74
74
|
const absTotalSeconds = Math.abs(totalSeconds);
|
|
75
75
|
const absHours = MathUtil.intDiv(absTotalSeconds, LocalTime.SECONDS_PER_HOUR);
|
|
76
76
|
const absMinutes = MathUtil.intMod(MathUtil.intDiv(absTotalSeconds, LocalTime.SECONDS_PER_MINUTE), LocalTime.MINUTES_PER_HOUR);
|
|
77
|
-
let buf = `${
|
|
78
|
-
}${absHours < 10 ? '0' : ''
|
|
79
|
-
}${absMinutes < 10 ? ':0' : ':'
|
|
77
|
+
let buf = `${totalSeconds < 0 ? '-' : '+'
|
|
78
|
+
}${absHours < 10 ? '0' : ''}${absHours
|
|
79
|
+
}${absMinutes < 10 ? ':0' : ':'}${absMinutes}`;
|
|
80
80
|
const absSeconds = MathUtil.intMod(absTotalSeconds, LocalTime.SECONDS_PER_MINUTE);
|
|
81
81
|
if (absSeconds !== 0) {
|
|
82
82
|
buf += (absSeconds < 10 ? ':0' : ':') + (absSeconds);
|
|
@@ -106,7 +106,7 @@ export class ZoneOffset extends ZoneId {
|
|
|
106
106
|
*/
|
|
107
107
|
static _validate(hours, minutes, seconds) {
|
|
108
108
|
if (hours < -18 || hours > 18) {
|
|
109
|
-
throw new DateTimeException(`Zone offset hours not in valid range: value ${
|
|
109
|
+
throw new DateTimeException(`Zone offset hours not in valid range: value ${hours
|
|
110
110
|
} is not in the range -18 to 18`);
|
|
111
111
|
}
|
|
112
112
|
if (hours > 0) {
|
|
@@ -122,11 +122,11 @@ export class ZoneOffset extends ZoneId {
|
|
|
122
122
|
}
|
|
123
123
|
if (Math.abs(minutes) > 59) {
|
|
124
124
|
throw new DateTimeException(`Zone offset minutes not in valid range: abs(value) ${
|
|
125
|
-
Math.abs(minutes)
|
|
125
|
+
Math.abs(minutes)} is not in the range 0 to 59`);
|
|
126
126
|
}
|
|
127
127
|
if (Math.abs(seconds) > 59) {
|
|
128
128
|
throw new DateTimeException(`Zone offset seconds not in valid range: abs(value) ${
|
|
129
|
-
Math.abs(seconds)
|
|
129
|
+
Math.abs(seconds)} is not in the range 0 to 59`);
|
|
130
130
|
}
|
|
131
131
|
if (Math.abs(hours) === 18 && (Math.abs(minutes) > 0 || Math.abs(seconds) > 0)) {
|
|
132
132
|
throw new DateTimeException('Zone offset not in valid range: -18:00 to +18:00');
|
|
@@ -176,7 +176,7 @@ export class ZoneOffset extends ZoneId {
|
|
|
176
176
|
let hours, minutes, seconds;
|
|
177
177
|
switch (offsetId.length) {
|
|
178
178
|
case 2:
|
|
179
|
-
offsetId = `${offsetId[0]
|
|
179
|
+
offsetId = `${offsetId[0]}0${offsetId[1]}`; // fallthru
|
|
180
180
|
// eslint-disable-next-line no-fallthrough
|
|
181
181
|
case 3:
|
|
182
182
|
hours = ZoneOffset._parseNumber(offsetId, 1, false);
|
|
@@ -204,11 +204,11 @@ export class ZoneOffset extends ZoneId {
|
|
|
204
204
|
seconds = ZoneOffset._parseNumber(offsetId, 7, true);
|
|
205
205
|
break;
|
|
206
206
|
default:
|
|
207
|
-
throw new DateTimeException(`Invalid ID for ZoneOffset, invalid format: ${
|
|
207
|
+
throw new DateTimeException(`Invalid ID for ZoneOffset, invalid format: ${offsetId}`);
|
|
208
208
|
}
|
|
209
209
|
const first = offsetId[0];
|
|
210
210
|
if (first !== '+' && first !== '-') {
|
|
211
|
-
throw new DateTimeException(`Invalid ID for ZoneOffset, plus/minus not found when expected: ${
|
|
211
|
+
throw new DateTimeException(`Invalid ID for ZoneOffset, plus/minus not found when expected: ${offsetId}`);
|
|
212
212
|
}
|
|
213
213
|
if (first === '-') {
|
|
214
214
|
return ZoneOffset.ofHoursMinutesSeconds(-hours, -minutes, -seconds);
|
|
@@ -227,12 +227,12 @@ export class ZoneOffset extends ZoneId {
|
|
|
227
227
|
*/
|
|
228
228
|
static _parseNumber(offsetId, pos, precededByColon) {
|
|
229
229
|
if (precededByColon && offsetId[pos - 1] !== ':') {
|
|
230
|
-
throw new DateTimeException(`Invalid ID for ZoneOffset, colon not found when expected: ${
|
|
230
|
+
throw new DateTimeException(`Invalid ID for ZoneOffset, colon not found when expected: ${offsetId}`);
|
|
231
231
|
}
|
|
232
232
|
const ch1 = offsetId[pos];
|
|
233
233
|
const ch2 = offsetId[pos + 1];
|
|
234
234
|
if (ch1 < '0' || ch1 > '9' || ch2 < '0' || ch2 > '9') {
|
|
235
|
-
throw new DateTimeException(`Invalid ID for ZoneOffset, non numeric characters found: ${
|
|
235
|
+
throw new DateTimeException(`Invalid ID for ZoneOffset, non numeric characters found: ${offsetId}`);
|
|
236
236
|
}
|
|
237
237
|
return (ch1.charCodeAt(0) - 48) * 10 + (ch2.charCodeAt(0) - 48);
|
|
238
238
|
}
|
|
@@ -362,7 +362,7 @@ export class ZoneOffset extends ZoneId {
|
|
|
362
362
|
if (field === ChronoField.OFFSET_SECONDS) {
|
|
363
363
|
return this._totalSeconds;
|
|
364
364
|
} else if (field instanceof ChronoField) {
|
|
365
|
-
throw new DateTimeException(`Unsupported field: ${
|
|
365
|
+
throw new DateTimeException(`Unsupported field: ${field}`);
|
|
366
366
|
}
|
|
367
367
|
return field.getFrom(this);
|
|
368
368
|
}
|
package/src/ZoneRegion.js
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
import {ZoneId} from './ZoneId';
|
|
9
|
-
import {ZoneRulesProvider} from './zone/ZoneRulesProvider';
|
|
8
|
+
import { ZoneId } from './ZoneId';
|
|
9
|
+
import { ZoneRulesProvider } from './zone/ZoneRulesProvider';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* A geographical region where the same time-zone rules apply.
|
package/src/ZonedDateTime.js
CHANGED
|
@@ -4,25 +4,25 @@
|
|
|
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, IllegalArgumentException} from './errors';
|
|
9
|
-
import {MathUtil} from './MathUtil';
|
|
10
|
-
|
|
11
|
-
import {Clock} from './Clock';
|
|
12
|
-
import {Instant} from './Instant';
|
|
13
|
-
import {LocalDate} from './LocalDate';
|
|
14
|
-
import {LocalDateTime} from './LocalDateTime';
|
|
15
|
-
import {LocalTime} from './LocalTime';
|
|
16
|
-
import {OffsetDateTime} from './OffsetDateTime';
|
|
17
|
-
import {ZoneId} from './ZoneId';
|
|
18
|
-
import {ZoneOffset} from './ZoneOffset';
|
|
19
|
-
|
|
20
|
-
import {ChronoZonedDateTime} from './chrono/ChronoZonedDateTime';
|
|
21
|
-
import {DateTimeFormatter} from './format/DateTimeFormatter';
|
|
22
|
-
import {ChronoField} from './temporal/ChronoField';
|
|
23
|
-
import {ChronoUnit} from './temporal/ChronoUnit';
|
|
24
|
-
import {createTemporalQuery} from './temporal/TemporalQuery';
|
|
25
|
-
import {TemporalQueries} from './temporal/TemporalQueries';
|
|
7
|
+
import { requireNonNull } from './assert';
|
|
8
|
+
import { DateTimeException, IllegalArgumentException } from './errors';
|
|
9
|
+
import { MathUtil } from './MathUtil';
|
|
10
|
+
|
|
11
|
+
import { Clock } from './Clock';
|
|
12
|
+
import { Instant } from './Instant';
|
|
13
|
+
import { LocalDate } from './LocalDate';
|
|
14
|
+
import { LocalDateTime } from './LocalDateTime';
|
|
15
|
+
import { LocalTime } from './LocalTime';
|
|
16
|
+
import { OffsetDateTime } from './OffsetDateTime';
|
|
17
|
+
import { ZoneId } from './ZoneId';
|
|
18
|
+
import { ZoneOffset } from './ZoneOffset';
|
|
19
|
+
|
|
20
|
+
import { ChronoZonedDateTime } from './chrono/ChronoZonedDateTime';
|
|
21
|
+
import { DateTimeFormatter } from './format/DateTimeFormatter';
|
|
22
|
+
import { ChronoField } from './temporal/ChronoField';
|
|
23
|
+
import { ChronoUnit } from './temporal/ChronoUnit';
|
|
24
|
+
import { createTemporalQuery } from './temporal/TemporalQuery';
|
|
25
|
+
import { TemporalQueries } from './temporal/TemporalQueries';
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* A date-time with a time-zone in the ISO-8601 calendar system,
|
|
@@ -378,12 +378,12 @@ export class ZonedDateTime extends ChronoZonedDateTime {
|
|
|
378
378
|
if (trans != null && trans.isGap()) {
|
|
379
379
|
// error message says daylight savings for simplicity
|
|
380
380
|
// even though there are other kinds of gaps
|
|
381
|
-
throw new DateTimeException(`LocalDateTime ${
|
|
382
|
-
} does not exist in zone ${
|
|
381
|
+
throw new DateTimeException(`LocalDateTime ${localDateTime
|
|
382
|
+
} does not exist in zone ${zone
|
|
383
383
|
} due to a gap in the local time-line, typically caused by daylight savings`);
|
|
384
384
|
}
|
|
385
|
-
throw new DateTimeException(`ZoneOffset "${
|
|
386
|
-
localDateTime
|
|
385
|
+
throw new DateTimeException(`ZoneOffset "${offset}" is not valid for LocalDateTime "${
|
|
386
|
+
localDateTime}" in zone "${zone}"`);
|
|
387
387
|
}
|
|
388
388
|
return new ZonedDateTime(localDateTime, offset, zone);
|
|
389
389
|
}
|
|
@@ -1931,7 +1931,7 @@ export class ZonedDateTime extends ChronoZonedDateTime {
|
|
|
1931
1931
|
toString() {
|
|
1932
1932
|
let str = this._dateTime.toString() + this._offset.toString();
|
|
1933
1933
|
if (this._offset !== this._zone) {
|
|
1934
|
-
str += `[${
|
|
1934
|
+
str += `[${this._zone.toString()}]`;
|
|
1935
1935
|
}
|
|
1936
1936
|
return str;
|
|
1937
1937
|
}
|
package/src/_init.js
CHANGED
|
@@ -3,31 +3,31 @@
|
|
|
3
3
|
* @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {_init as ZoneOffsetInit} from './ZoneOffset';
|
|
7
|
-
import {_init as DayOfWeekInit} from './DayOfWeek';
|
|
8
|
-
import {_init as DurationInit} from './Duration';
|
|
9
|
-
import {_init as InstantInit} from './Instant';
|
|
10
|
-
import {_init as LocalDateInit} from './LocalDate';
|
|
11
|
-
import {_init as LocalTimeInit} from './LocalTime';
|
|
12
|
-
import {_init as LocalDateTimeInit} from './LocalDateTime';
|
|
13
|
-
import {_init as MonthInit} from './Month';
|
|
14
|
-
import {_init as MonthDayInit} from './MonthDay';
|
|
15
|
-
import {_init as OffsetDateTimeInit} from './OffsetDateTime';
|
|
16
|
-
import {_init as OffsetTimeInit} from './OffsetTime';
|
|
17
|
-
import {_init as PeriodInit} from './Period';
|
|
18
|
-
import {_init as YearInit} from './Year';
|
|
19
|
-
import {_init as YearConstantsInit} from './YearConstants';
|
|
20
|
-
import {_init as YearMonthInit} from './YearMonth';
|
|
21
|
-
import {_init as ZonedDateTimeInit} from './ZonedDateTime';
|
|
22
|
-
import {_init as IsoChronologyInit} from './chrono/IsoChronology';
|
|
23
|
-
import {_init as DateTimeFormatterInit} from './format/DateTimeFormatter';
|
|
24
|
-
import {_init as ChronoFieldInit} from './temporal/ChronoField';
|
|
25
|
-
import {_init as ChronoUnitInit} from './temporal/ChronoUnit';
|
|
26
|
-
import {_init as IsoFieldsInit} from './temporal/IsoFields';
|
|
27
|
-
import {_init as DateTimeFormatterBuilderInit} from './format/DateTimeFormatterBuilder';
|
|
6
|
+
import { _init as ZoneOffsetInit } from './ZoneOffset';
|
|
7
|
+
import { _init as DayOfWeekInit } from './DayOfWeek';
|
|
8
|
+
import { _init as DurationInit } from './Duration';
|
|
9
|
+
import { _init as InstantInit } from './Instant';
|
|
10
|
+
import { _init as LocalDateInit } from './LocalDate';
|
|
11
|
+
import { _init as LocalTimeInit } from './LocalTime';
|
|
12
|
+
import { _init as LocalDateTimeInit } from './LocalDateTime';
|
|
13
|
+
import { _init as MonthInit } from './Month';
|
|
14
|
+
import { _init as MonthDayInit } from './MonthDay';
|
|
15
|
+
import { _init as OffsetDateTimeInit } from './OffsetDateTime';
|
|
16
|
+
import { _init as OffsetTimeInit } from './OffsetTime';
|
|
17
|
+
import { _init as PeriodInit } from './Period';
|
|
18
|
+
import { _init as YearInit } from './Year';
|
|
19
|
+
import { _init as YearConstantsInit } from './YearConstants';
|
|
20
|
+
import { _init as YearMonthInit } from './YearMonth';
|
|
21
|
+
import { _init as ZonedDateTimeInit } from './ZonedDateTime';
|
|
22
|
+
import { _init as IsoChronologyInit } from './chrono/IsoChronology';
|
|
23
|
+
import { _init as DateTimeFormatterInit } from './format/DateTimeFormatter';
|
|
24
|
+
import { _init as ChronoFieldInit } from './temporal/ChronoField';
|
|
25
|
+
import { _init as ChronoUnitInit } from './temporal/ChronoUnit';
|
|
26
|
+
import { _init as IsoFieldsInit } from './temporal/IsoFields';
|
|
27
|
+
import { _init as DateTimeFormatterBuilderInit } from './format/DateTimeFormatterBuilder';
|
|
28
28
|
|
|
29
|
-
import {_init as TemporalQueriesInit} from './temporal/TemporalQueriesFactory';
|
|
30
|
-
import {_init as ZoneIdInit} from './ZoneIdFactory';
|
|
29
|
+
import { _init as TemporalQueriesInit } from './temporal/TemporalQueriesFactory';
|
|
30
|
+
import { _init as ZoneIdInit } from './ZoneIdFactory';
|
|
31
31
|
|
|
32
32
|
let isInit = false;
|
|
33
33
|
|
package/src/assert.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @copyright (c) 2016, Philipp Thürwächter & Pattrick Hüper
|
|
3
3
|
* @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
|
|
4
4
|
*/
|
|
5
|
-
import {NullPointerException, IllegalArgumentException} from './errors';
|
|
5
|
+
import { NullPointerException, IllegalArgumentException } from './errors';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @private
|
|
@@ -30,7 +30,7 @@ export function assert(assertion, msg, error) {
|
|
|
30
30
|
*/
|
|
31
31
|
export function requireNonNull(value, parameterName) {
|
|
32
32
|
if (value == null) {
|
|
33
|
-
throw new NullPointerException(`${parameterName
|
|
33
|
+
throw new NullPointerException(`${parameterName} must not be null`);
|
|
34
34
|
}
|
|
35
35
|
return value;
|
|
36
36
|
}
|
|
@@ -45,7 +45,7 @@ export function requireNonNull(value, parameterName) {
|
|
|
45
45
|
*/
|
|
46
46
|
export function requireInstance(value, _class, parameterName) {
|
|
47
47
|
if (!(value instanceof _class)) {
|
|
48
|
-
throw new IllegalArgumentException(`${parameterName
|
|
48
|
+
throw new IllegalArgumentException(`${parameterName} must be an instance of ${_class.name ? _class.name : _class}${value && value.constructor && value.constructor.name ? `, but is ${value.constructor.name}` : ''}`);
|
|
49
49
|
}
|
|
50
50
|
return value;
|
|
51
51
|
}
|
|
@@ -56,5 +56,5 @@ export function requireInstance(value, _class, parameterName) {
|
|
|
56
56
|
* @param methodName
|
|
57
57
|
*/
|
|
58
58
|
export function abstractMethodFail(methodName){
|
|
59
|
-
throw new TypeError(`abstract method "${
|
|
59
|
+
throw new TypeError(`abstract method "${methodName}" is not implemented`);
|
|
60
60
|
}
|
|
@@ -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 {requireNonNull, requireInstance} from '../assert';
|
|
7
|
+
import { requireNonNull, requireInstance } from '../assert';
|
|
8
8
|
|
|
9
|
-
import {ChronoField} from '../temporal/ChronoField';
|
|
10
|
-
import {ChronoUnit} from '../temporal/ChronoUnit';
|
|
11
|
-
import {DateTimeFormatter} from '../format/DateTimeFormatter';
|
|
12
|
-
import {TemporalQueries} from '../temporal/TemporalQueries';
|
|
13
|
-
import {Temporal} from '../temporal/Temporal';
|
|
9
|
+
import { ChronoField } from '../temporal/ChronoField';
|
|
10
|
+
import { ChronoUnit } from '../temporal/ChronoUnit';
|
|
11
|
+
import { DateTimeFormatter } from '../format/DateTimeFormatter';
|
|
12
|
+
import { TemporalQueries } from '../temporal/TemporalQueries';
|
|
13
|
+
import { Temporal } from '../temporal/Temporal';
|
|
14
14
|
|
|
15
|
-
import {LocalDate} from '../LocalDate';
|
|
15
|
+
import { LocalDate } from '../LocalDate';
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* A date without time-of-day or time-zone in an arbitrary chronology, intended
|
|
@@ -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 {requireNonNull, requireInstance} from '../assert';
|
|
8
|
-
import {MathUtil} from '../MathUtil';
|
|
7
|
+
import { requireNonNull, requireInstance } from '../assert';
|
|
8
|
+
import { MathUtil } from '../MathUtil';
|
|
9
9
|
|
|
10
|
-
import {LocalDate} from '../LocalDate';
|
|
11
|
-
import {Instant} from '../Instant';
|
|
12
|
-
import {ZoneOffset} from '../ZoneOffset';
|
|
13
|
-
import {ChronoUnit} from '../temporal/ChronoUnit';
|
|
14
|
-
import {ChronoField} from '../temporal/ChronoField';
|
|
15
|
-
import {Temporal} from '../temporal/Temporal';
|
|
16
|
-
import {TemporalQueries} from '../temporal/TemporalQueries';
|
|
10
|
+
import { LocalDate } from '../LocalDate';
|
|
11
|
+
import { Instant } from '../Instant';
|
|
12
|
+
import { ZoneOffset } from '../ZoneOffset';
|
|
13
|
+
import { ChronoUnit } from '../temporal/ChronoUnit';
|
|
14
|
+
import { ChronoField } from '../temporal/ChronoField';
|
|
15
|
+
import { Temporal } from '../temporal/Temporal';
|
|
16
|
+
import { TemporalQueries } from '../temporal/TemporalQueries';
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* A date-time without a time-zone in an arbitrary chronology, intended
|
|
@@ -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 {requireNonNull} from '../assert';
|
|
8
|
-
import {Instant} from '../Instant';
|
|
9
|
-
import {LocalDate} from '../LocalDate';
|
|
10
|
-
import {MathUtil} from '../MathUtil';
|
|
7
|
+
import { requireNonNull } from '../assert';
|
|
8
|
+
import { Instant } from '../Instant';
|
|
9
|
+
import { LocalDate } from '../LocalDate';
|
|
10
|
+
import { MathUtil } from '../MathUtil';
|
|
11
11
|
|
|
12
|
-
import {ChronoUnit} from '../temporal/ChronoUnit';
|
|
13
|
-
import {Temporal} from '../temporal/Temporal';
|
|
14
|
-
import {TemporalQueries} from '../temporal/TemporalQueries';
|
|
12
|
+
import { ChronoUnit } from '../temporal/ChronoUnit';
|
|
13
|
+
import { Temporal } from '../temporal/Temporal';
|
|
14
|
+
import { TemporalQueries } from '../temporal/TemporalQueries';
|
|
15
15
|
|
|
16
16
|
export class ChronoZonedDateTime extends Temporal {
|
|
17
17
|
query(query) {
|
|
@@ -4,19 +4,19 @@
|
|
|
4
4
|
* @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {Enum} from '../Enum';
|
|
8
|
-
import {requireNonNull} from '../assert';
|
|
9
|
-
import {DateTimeException} from '../errors';
|
|
10
|
-
import {MathUtil} from '../MathUtil';
|
|
7
|
+
import { Enum } from '../Enum';
|
|
8
|
+
import { requireNonNull } from '../assert';
|
|
9
|
+
import { DateTimeException } from '../errors';
|
|
10
|
+
import { MathUtil } from '../MathUtil';
|
|
11
11
|
|
|
12
|
-
import {DayOfWeek} from '../DayOfWeek';
|
|
13
|
-
import {LocalDate} from '../LocalDate';
|
|
14
|
-
import {Month} from '../Month';
|
|
15
|
-
import {Year} from '../Year';
|
|
12
|
+
import { DayOfWeek } from '../DayOfWeek';
|
|
13
|
+
import { LocalDate } from '../LocalDate';
|
|
14
|
+
import { Month } from '../Month';
|
|
15
|
+
import { Year } from '../Year';
|
|
16
16
|
|
|
17
|
-
import {ChronoField} from '../temporal/ChronoField';
|
|
18
|
-
import {ResolverStyle} from '../format/ResolverStyle';
|
|
19
|
-
import {TemporalAdjusters} from '../temporal/TemporalAdjusters';
|
|
17
|
+
import { ChronoField } from '../temporal/ChronoField';
|
|
18
|
+
import { ResolverStyle } from '../format/ResolverStyle';
|
|
19
|
+
import { TemporalAdjusters } from '../temporal/TemporalAdjusters';
|
|
20
20
|
|
|
21
21
|
export class IsoChronology extends Enum{
|
|
22
22
|
/**
|
|
@@ -56,7 +56,7 @@ export class IsoChronology extends Enum{
|
|
|
56
56
|
requireNonNull(field, 'field');
|
|
57
57
|
const current = fieldValues.get(field);
|
|
58
58
|
if (current != null && current !== value) {
|
|
59
|
-
throw new DateTimeException(`Invalid state, field: ${
|
|
59
|
+
throw new DateTimeException(`Invalid state, field: ${field} ${current} conflicts with ${field} ${value}`);
|
|
60
60
|
}
|
|
61
61
|
fieldValues.put(field, value);
|
|
62
62
|
}
|
|
@@ -102,7 +102,7 @@ export class IsoChronology extends Enum{
|
|
|
102
102
|
} else if (era === 0) {
|
|
103
103
|
this._updateResolveMap(fieldValues, ChronoField.YEAR, MathUtil.safeSubtract(1, yoeLong));
|
|
104
104
|
} else {
|
|
105
|
-
throw new DateTimeException(`Invalid value for era: ${
|
|
105
|
+
throw new DateTimeException(`Invalid value for era: ${era}`);
|
|
106
106
|
}
|
|
107
107
|
} else if (fieldValues.containsKey(ChronoField.ERA)) {
|
|
108
108
|
ChronoField.ERA.checkValidValue(fieldValues.get(ChronoField.ERA)); // always validated
|
package/src/convert.js
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
* @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {IllegalArgumentException} from './errors';
|
|
6
|
+
import { IllegalArgumentException } from './errors';
|
|
7
7
|
|
|
8
|
-
import {LocalDate} from './LocalDate';
|
|
9
|
-
import {LocalDateTime} from './LocalDateTime';
|
|
10
|
-
import {ZonedDateTime} from './ZonedDateTime';
|
|
11
|
-
import {ZoneId} from './ZoneId';
|
|
12
|
-
import {Instant} from './Instant';
|
|
8
|
+
import { LocalDate } from './LocalDate';
|
|
9
|
+
import { LocalDateTime } from './LocalDateTime';
|
|
10
|
+
import { ZonedDateTime } from './ZonedDateTime';
|
|
11
|
+
import { ZoneId } from './ZoneId';
|
|
12
|
+
import { Instant } from './Instant';
|
|
13
13
|
|
|
14
14
|
class ToNativeJsConverter {
|
|
15
15
|
/**
|
|
@@ -36,7 +36,7 @@ class ToNativeJsConverter {
|
|
|
36
36
|
zonedDateTime = temporal.withZoneSameInstant(zone);
|
|
37
37
|
}
|
|
38
38
|
} else {
|
|
39
|
-
throw new IllegalArgumentException(`unsupported instance for convert operation:${
|
|
39
|
+
throw new IllegalArgumentException(`unsupported instance for convert operation:${temporal}`);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
this.instant = zonedDateTime.toInstant();
|
package/src/errors.js
CHANGED
|
@@ -33,16 +33,16 @@ export const NullPointerException = createErrorType('NullPointerException');
|
|
|
33
33
|
function messageWithCause(message, cause = null) {
|
|
34
34
|
let msg = message || this.name;
|
|
35
35
|
if (cause !== null && cause instanceof Error) {
|
|
36
|
-
msg += `\n-------\nCaused by: ${
|
|
36
|
+
msg += `\n-------\nCaused by: ${cause.stack}\n-------\n`;
|
|
37
37
|
}
|
|
38
38
|
this.message = msg;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
function messageForDateTimeParseException(message, text = '', index = 0, cause = null) {
|
|
42
42
|
let msg = message || this.name;
|
|
43
|
-
msg += `: ${
|
|
43
|
+
msg += `: ${text}, at index: ${index}`;
|
|
44
44
|
if (cause !== null && cause instanceof Error) {
|
|
45
|
-
msg += `\n-------\nCaused by: ${
|
|
45
|
+
msg += `\n-------\nCaused by: ${cause.stack}\n-------\n`;
|
|
46
46
|
}
|
|
47
47
|
this.message = msg;
|
|
48
48
|
this.parsedString = () => {
|
|
@@ -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(`Conflict found: ${
|
|
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(`Conflict found: Field ${
|
|
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(`Field not found: ${
|
|
506
|
+
throw new DateTimeException(`Field not found: ${field}`);
|
|
507
507
|
}
|
|
508
508
|
return value;
|
|
509
509
|
}
|