@js-joda/core 1.12.0 → 3.2.0
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 +58 -1
- package/dist/js-joda.d.ts +2377 -1635
- package/dist/js-joda.esm.js +1678 -653
- package/dist/js-joda.js +1681 -654
- package/dist/js-joda.js.map +1 -1
- package/dist/js-joda.min.js +2 -2
- package/package.json +24 -21
- package/src/DayOfWeek.js +3 -3
- package/src/Duration.js +4 -4
- package/src/Instant.js +12 -54
- package/src/LocalDate.js +26 -75
- package/src/LocalDateTime.js +10 -62
- package/src/LocalTime.js +8 -61
- package/src/Month.js +4 -4
- package/src/MonthDay.js +1 -2
- package/src/OffsetDateTime.js +757 -0
- package/src/OffsetTime.js +621 -0
- package/src/Period.js +1 -1
- package/src/Year.js +73 -57
- package/src/YearMonth.js +10 -68
- package/src/ZonedDateTime.js +11 -52
- package/src/_init.js +4 -0
- package/src/chrono/ChronoLocalDate.js +2 -2
- package/src/chrono/ChronoLocalDateTime.js +2 -2
- package/src/chrono/ChronoZonedDateTime.js +2 -2
- package/src/errors.js +6 -6
- package/src/format/DateTimeBuilder.js +2 -2
- package/src/format/DateTimeFormatter.js +3 -3
- package/src/js-joda.js +6 -0
- package/src/temporal/ChronoField.js +241 -133
- package/src/temporal/ChronoUnit.js +72 -229
- package/src/temporal/DefaultInterfaceTemporal.js +118 -0
- package/src/temporal/IsoFields.js +35 -32
- package/src/temporal/Temporal.js +284 -1
- package/src/temporal/TemporalField.js +225 -1
- package/src/temporal/TemporalUnit.js +18 -19
- package/src/temporal/ValueRange.js +1 -0
package/src/LocalTime.js
CHANGED
|
@@ -280,7 +280,7 @@ export class LocalTime extends Temporal /** implements Temporal, TemporalAdjuste
|
|
|
280
280
|
const _second = MathUtil.safeToInt(second);
|
|
281
281
|
const _nanoOfSecond = MathUtil.safeToInt(nanoOfSecond);
|
|
282
282
|
LocalTime._validate(_hour, _minute, _second, _nanoOfSecond);
|
|
283
|
-
if (
|
|
283
|
+
if (_minute === 0 && _second === 0 && _nanoOfSecond === 0) {
|
|
284
284
|
if (!LocalTime.HOURS[_hour]) {
|
|
285
285
|
this._hour = _hour;
|
|
286
286
|
this._minute = _minute;
|
|
@@ -500,24 +500,6 @@ export class LocalTime extends Temporal /** implements Temporal, TemporalAdjuste
|
|
|
500
500
|
return this._nano;
|
|
501
501
|
}
|
|
502
502
|
|
|
503
|
-
/**
|
|
504
|
-
* function overloading for {@link LocalDate.with}
|
|
505
|
-
*
|
|
506
|
-
* if called with 1 (or less) arguments {@link LocalTime.withTemporalAdjuster} is called.
|
|
507
|
-
* Otherwise {@link LocalTime.with2} is called.
|
|
508
|
-
*
|
|
509
|
-
* @param {!(TemporalAdjuster|ChronoField)} adjusterOrField
|
|
510
|
-
* @param {number} newValue - only required if called with 2 arguments
|
|
511
|
-
* @return {LocalTime}
|
|
512
|
-
*/
|
|
513
|
-
with(adjusterOrField, newValue){
|
|
514
|
-
if(arguments.length < 2){
|
|
515
|
-
return this.withTemporalAdjuster(adjusterOrField);
|
|
516
|
-
} else {
|
|
517
|
-
return this.with2(adjusterOrField, newValue);
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
|
|
521
503
|
/**
|
|
522
504
|
* Returns an adjusted copy of this time.
|
|
523
505
|
*
|
|
@@ -539,7 +521,7 @@ export class LocalTime extends Temporal /** implements Temporal, TemporalAdjuste
|
|
|
539
521
|
* @throws {DateTimeException} if the adjustment cannot be made
|
|
540
522
|
* @throws {ArithmeticException} if numeric overflow occurs
|
|
541
523
|
*/
|
|
542
|
-
|
|
524
|
+
withAdjuster(adjuster) {
|
|
543
525
|
requireNonNull(adjuster, 'adjuster');
|
|
544
526
|
// optimizations
|
|
545
527
|
if (adjuster instanceof LocalTime) {
|
|
@@ -629,7 +611,7 @@ export class LocalTime extends Temporal /** implements Temporal, TemporalAdjuste
|
|
|
629
611
|
* @throws {DateTimeException} if the field cannot be set
|
|
630
612
|
* @throws {ArithmeticException} if numeric overflow occurs
|
|
631
613
|
*/
|
|
632
|
-
|
|
614
|
+
withFieldValue(field, newValue) {
|
|
633
615
|
requireNonNull(field, 'field');
|
|
634
616
|
requireInstance(field, TemporalField, 'field');
|
|
635
617
|
if (field instanceof ChronoField) {
|
|
@@ -760,24 +742,6 @@ export class LocalTime extends Temporal /** implements Temporal, TemporalAdjuste
|
|
|
760
742
|
|
|
761
743
|
//-----------------------------------------------------------------------
|
|
762
744
|
|
|
763
|
-
/**
|
|
764
|
-
* function overloading for {@link LocalDate.plus}
|
|
765
|
-
*
|
|
766
|
-
* if called with 1 (or less) arguments {@link LocalTime.plus1} is called.
|
|
767
|
-
* Otherwise {@link LocalTime.plus2} is called.
|
|
768
|
-
*
|
|
769
|
-
* @param {!(TemporalAmount|number)} amount
|
|
770
|
-
* @param {ChronoUnit} unit - only required if called with 2 arguments
|
|
771
|
-
* @return {LocalTime}
|
|
772
|
-
*/
|
|
773
|
-
plus(amount, unit){
|
|
774
|
-
if(arguments.length < 2){
|
|
775
|
-
return this.plus1(amount);
|
|
776
|
-
} else {
|
|
777
|
-
return this.plus2(amount, unit);
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
|
|
781
745
|
/**
|
|
782
746
|
* Returns a copy of this date with the specified period added.
|
|
783
747
|
*
|
|
@@ -794,7 +758,7 @@ export class LocalTime extends Temporal /** implements Temporal, TemporalAdjuste
|
|
|
794
758
|
* @throws {DateTimeException} if the addition cannot be made
|
|
795
759
|
* @throws {ArithmeticException} if numeric overflow occurs
|
|
796
760
|
*/
|
|
797
|
-
|
|
761
|
+
plusAmount(amount) {
|
|
798
762
|
requireNonNull(amount, 'amount');
|
|
799
763
|
return amount.addTo(this);
|
|
800
764
|
}
|
|
@@ -814,7 +778,7 @@ export class LocalTime extends Temporal /** implements Temporal, TemporalAdjuste
|
|
|
814
778
|
* @return {LocalTime} a {@link LocalTime} based on this time with the specified period added, not null
|
|
815
779
|
* @throws {DateTimeException} if the unit cannot be added to this type
|
|
816
780
|
*/
|
|
817
|
-
|
|
781
|
+
plusAmountUnit(amountToAdd, unit) {
|
|
818
782
|
requireNonNull(unit, 'unit');
|
|
819
783
|
if (unit instanceof ChronoUnit) {
|
|
820
784
|
switch (unit) {
|
|
@@ -932,23 +896,6 @@ export class LocalTime extends Temporal /** implements Temporal, TemporalAdjuste
|
|
|
932
896
|
}
|
|
933
897
|
|
|
934
898
|
//-----------------------------------------------------------------------
|
|
935
|
-
/**
|
|
936
|
-
* function overloading for {@link LocalDate.minus}
|
|
937
|
-
*
|
|
938
|
-
* if called with 1 (or less) arguments {@link LocalTime.minus1} is called.
|
|
939
|
-
* Otherwise {@link LocalTime.minus2} is called.
|
|
940
|
-
*
|
|
941
|
-
* @param {!(TemporalAmount|number)} amount
|
|
942
|
-
* @param {ChronoUnit} unit - only required if called with 2 arguments
|
|
943
|
-
* @return {LocalTime}
|
|
944
|
-
*/
|
|
945
|
-
minus(amount, unit){
|
|
946
|
-
if(arguments.length < 2){
|
|
947
|
-
return this.minus1(amount);
|
|
948
|
-
} else {
|
|
949
|
-
return this.minus2(amount, unit);
|
|
950
|
-
}
|
|
951
|
-
}
|
|
952
899
|
|
|
953
900
|
/**
|
|
954
901
|
* Returns a copy of this time with the specified period subtracted.
|
|
@@ -967,7 +914,7 @@ export class LocalTime extends Temporal /** implements Temporal, TemporalAdjuste
|
|
|
967
914
|
* @throws {ArithmeticException} if numeric overflow occurs
|
|
968
915
|
*/
|
|
969
916
|
|
|
970
|
-
|
|
917
|
+
minusAmount(amount) {
|
|
971
918
|
requireNonNull(amount, 'amount');
|
|
972
919
|
return amount.subtractFrom(this);
|
|
973
920
|
}
|
|
@@ -987,9 +934,9 @@ export class LocalTime extends Temporal /** implements Temporal, TemporalAdjuste
|
|
|
987
934
|
* @return {LocalTime} a {@link LocalTime} based on this time with the specified period subtracted, not null
|
|
988
935
|
* @throws {DateTimeException} if the unit cannot be added to this type
|
|
989
936
|
*/
|
|
990
|
-
|
|
937
|
+
minusAmountUnit(amountToSubtract, unit) {
|
|
991
938
|
requireNonNull(unit, 'unit');
|
|
992
|
-
return this.
|
|
939
|
+
return this.plusAmountUnit(-1 * amountToSubtract, unit);
|
|
993
940
|
}
|
|
994
941
|
|
|
995
942
|
//-----------------------------------------------------------------------
|
package/src/Month.js
CHANGED
|
@@ -11,7 +11,7 @@ import {ChronoField} from './temporal/ChronoField';
|
|
|
11
11
|
import {ChronoUnit} from './temporal/ChronoUnit';
|
|
12
12
|
import {DateTimeException, IllegalArgumentException, UnsupportedTemporalTypeException} from './errors';
|
|
13
13
|
import {IsoChronology} from './chrono/IsoChronology';
|
|
14
|
-
import {
|
|
14
|
+
import {TemporalAccessor} from './temporal/TemporalAccessor';
|
|
15
15
|
import {TemporalQueries} from './temporal/TemporalQueries';
|
|
16
16
|
|
|
17
17
|
/**
|
|
@@ -36,8 +36,8 @@ import {TemporalQueries} from './temporal/TemporalQueries';
|
|
|
36
36
|
* Month.JULY, Month.AUGUST, Month.SEPTEMBER, Month.OCTOBER, Month.NOVEMBER, Month.DECEMBER
|
|
37
37
|
*
|
|
38
38
|
*/
|
|
39
|
-
export class Month extends
|
|
40
|
-
|
|
39
|
+
export class Month extends TemporalAccessor {
|
|
40
|
+
|
|
41
41
|
/**
|
|
42
42
|
*
|
|
43
43
|
* @param {number} ordinal
|
|
@@ -87,7 +87,7 @@ export class Month extends Temporal {
|
|
|
87
87
|
* @return {string} the text value of the day-of-week, not null
|
|
88
88
|
*/
|
|
89
89
|
// eslint-disable-next-line no-unused-vars
|
|
90
|
-
|
|
90
|
+
displayName(style, locale) {
|
|
91
91
|
// TODO:
|
|
92
92
|
throw new IllegalArgumentException('Pattern using (localized) text not implemented yet!');
|
|
93
93
|
}
|
package/src/MonthDay.js
CHANGED
|
@@ -14,7 +14,6 @@ import {DateTimeFormatterBuilder} from './format/DateTimeFormatterBuilder';
|
|
|
14
14
|
import {IsoChronology} from './chrono/IsoChronology';
|
|
15
15
|
import {LocalDate} from './LocalDate';
|
|
16
16
|
import {Month} from './Month';
|
|
17
|
-
import {Temporal} from './temporal/Temporal';
|
|
18
17
|
import {TemporalAccessor} from './temporal/TemporalAccessor';
|
|
19
18
|
import {TemporalQuery, createTemporalQuery} from './temporal/TemporalQuery';
|
|
20
19
|
import {TemporalQueries} from './temporal/TemporalQueries';
|
|
@@ -52,7 +51,7 @@ import {ZoneId} from './ZoneId';
|
|
|
52
51
|
*
|
|
53
52
|
* This class is immutable and thread-safe.
|
|
54
53
|
*/
|
|
55
|
-
export class MonthDay extends
|
|
54
|
+
export class MonthDay extends TemporalAccessor {
|
|
56
55
|
/**
|
|
57
56
|
* function overloading for {@link MonthDay.now}
|
|
58
57
|
*
|