@js-joda/core 6.1.0 → 6.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/dist/js-joda.cjs.js +1227 -1199
- package/dist/js-joda.cjs.js.map +1 -1
- package/dist/js-joda.esm.js +1227 -1199
- package/dist/js-joda.esm.js.map +1 -1
- package/dist/js-joda.js +1227 -1199
- package/dist/js-joda.js.map +1 -1
- package/dist/js-joda.min.js +2 -2
- package/package.json +2 -2
- package/src/Duration.js +12 -4
- package/src/Instant.js +10 -2
- package/src/format/DateTimeBuilder.js +29 -5
- package/src/format/DateTimeFormatter.js +6 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@js-joda/core",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.2.0",
|
|
4
4
|
"description": "a date and time library for javascript",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"sourceMap": false,
|
|
48
48
|
"instrument": false
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "bb36ea96b26ee93408068c8ad8ebe8b094e96a10"
|
|
51
51
|
}
|
package/src/Duration.js
CHANGED
|
@@ -893,10 +893,18 @@ export class Duration extends TemporalAmount /*implements TemporalAmount, Compar
|
|
|
893
893
|
if (divisor === 1) {
|
|
894
894
|
return this;
|
|
895
895
|
}
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
896
|
+
// Give both components the same sign before truncating the quotient.
|
|
897
|
+
// Otherwise the positive nano adjustment of a negative duration is
|
|
898
|
+
// truncated separately and can move the result away from zero.
|
|
899
|
+
let seconds = this._seconds;
|
|
900
|
+
let nanos = this._nanos;
|
|
901
|
+
if (seconds < 0 && nanos > 0) {
|
|
902
|
+
seconds += 1;
|
|
903
|
+
nanos -= LocalTime.NANOS_PER_SECOND;
|
|
904
|
+
}
|
|
905
|
+
const secs = MathUtil.intDiv(seconds, divisor);
|
|
906
|
+
const remainder = MathUtil.intMod(seconds, divisor);
|
|
907
|
+
const nos = MathUtil.intDiv(remainder * LocalTime.NANOS_PER_SECOND + nanos, divisor);
|
|
900
908
|
return Duration.ofSeconds(secs, nos);
|
|
901
909
|
}
|
|
902
910
|
|
package/src/Instant.js
CHANGED
|
@@ -823,9 +823,17 @@ export class Instant extends Temporal {
|
|
|
823
823
|
* @private
|
|
824
824
|
*/
|
|
825
825
|
_microsUntil(end) {
|
|
826
|
-
|
|
826
|
+
let secsDiff = MathUtil.safeSubtract(end.epochSecond(), this.epochSecond());
|
|
827
|
+
let nanosDiff = end.nano() - this.nano();
|
|
828
|
+
if (secsDiff > 0 && nanosDiff < 0) {
|
|
829
|
+
secsDiff--;
|
|
830
|
+
nanosDiff += LocalTime.NANOS_PER_SECOND;
|
|
831
|
+
} else if (secsDiff < 0 && nanosDiff > 0) {
|
|
832
|
+
secsDiff++;
|
|
833
|
+
nanosDiff -= LocalTime.NANOS_PER_SECOND;
|
|
834
|
+
}
|
|
827
835
|
const totalMicros = MathUtil.safeMultiply(secsDiff, 1000000);
|
|
828
|
-
return MathUtil.safeAdd(totalMicros, MathUtil.intDiv(
|
|
836
|
+
return MathUtil.safeAdd(totalMicros, MathUtil.intDiv(nanosDiff, 1000));
|
|
829
837
|
}
|
|
830
838
|
|
|
831
839
|
/**
|
|
@@ -14,6 +14,7 @@ import { ResolverStyle } from './ResolverStyle';
|
|
|
14
14
|
import { IsoChronology } from '../chrono/IsoChronology';
|
|
15
15
|
import { ChronoLocalDate } from '../chrono/ChronoLocalDate';
|
|
16
16
|
import { ChronoField } from '../temporal/ChronoField';
|
|
17
|
+
import { IsoFields } from '../temporal/IsoFields';
|
|
17
18
|
import { TemporalAccessor } from '../temporal/TemporalAccessor';
|
|
18
19
|
import { TemporalQueries } from '../temporal/TemporalQueries';
|
|
19
20
|
|
|
@@ -146,13 +147,11 @@ export class DateTimeBuilder extends TemporalAccessor {
|
|
|
146
147
|
}
|
|
147
148
|
// handle standard fields
|
|
148
149
|
// this._mergeInstantFields();
|
|
150
|
+
if (this._resolveFields(resolverStyle)) {
|
|
151
|
+
// this._mergeInstantFields();
|
|
152
|
+
}
|
|
149
153
|
this._mergeDate(resolverStyle);
|
|
150
154
|
this._mergeTime(resolverStyle);
|
|
151
|
-
//if (resolveFields(resolverStyle)) {
|
|
152
|
-
// mergeInstantFields();
|
|
153
|
-
// mergeDate(resolverStyle);
|
|
154
|
-
// mergeTime(resolverStyle);
|
|
155
|
-
//}
|
|
156
155
|
this._resolveTimeInferZeroes(resolverStyle);
|
|
157
156
|
//this._crossCheck();
|
|
158
157
|
if (this.excessDays != null && this.excessDays.isZero() === false && this.date != null && this.time != null) {
|
|
@@ -164,6 +163,31 @@ export class DateTimeBuilder extends TemporalAccessor {
|
|
|
164
163
|
return this;
|
|
165
164
|
}
|
|
166
165
|
|
|
166
|
+
/**
|
|
167
|
+
* Resolves the date fields that are not {@link ChronoField}s by delegating to their own
|
|
168
|
+
* `resolve()`, the step java.time performs generically. As parsed values are held in a
|
|
169
|
+
* name-keyed map, the ISO fields that define a `resolve()` (week-of-week-based-year and
|
|
170
|
+
* day-of-quarter) are handled here. They do not depend on one another, so one pass is
|
|
171
|
+
* sufficient. Returns whether a date was produced.
|
|
172
|
+
*
|
|
173
|
+
* @param {ResolverStyle} resolverStyle
|
|
174
|
+
* @return {boolean}
|
|
175
|
+
* @private
|
|
176
|
+
*/
|
|
177
|
+
_resolveFields(resolverStyle) {
|
|
178
|
+
let resolved = false;
|
|
179
|
+
for (const field of [IsoFields.WEEK_OF_WEEK_BASED_YEAR, IsoFields.DAY_OF_QUARTER]) {
|
|
180
|
+
if (this.fieldValues.containsKey(field)) {
|
|
181
|
+
const date = field.resolve(this.fieldValues, this, resolverStyle);
|
|
182
|
+
if (date != null) {
|
|
183
|
+
this._checkDate(date);
|
|
184
|
+
resolved = true;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return resolved;
|
|
189
|
+
}
|
|
190
|
+
|
|
167
191
|
/**
|
|
168
192
|
*
|
|
169
193
|
* @param {ResolverStyle} resolverStyle
|
|
@@ -21,6 +21,7 @@ import { ResolverStyle } from './ResolverStyle';
|
|
|
21
21
|
|
|
22
22
|
import { IsoChronology } from '../chrono/IsoChronology';
|
|
23
23
|
import { ChronoField } from '../temporal/ChronoField';
|
|
24
|
+
import { IsoFields } from '../temporal/IsoFields';
|
|
24
25
|
import { createTemporalQuery } from '../temporal/TemporalQuery';
|
|
25
26
|
|
|
26
27
|
/**
|
|
@@ -696,12 +697,13 @@ export function _init() {
|
|
|
696
697
|
.toFormatter(ResolverStyle.STRICT);
|
|
697
698
|
|
|
698
699
|
DateTimeFormatter.ISO_WEEK_DATE = new DateTimeFormatterBuilder()
|
|
699
|
-
.
|
|
700
|
+
.parseCaseInsensitive()
|
|
701
|
+
.appendValue(IsoFields.WEEK_BASED_YEAR, 4, 10, SignStyle.EXCEEDS_PAD)
|
|
700
702
|
.appendLiteral('-W')
|
|
701
|
-
.appendValue(
|
|
703
|
+
.appendValue(IsoFields.WEEK_OF_WEEK_BASED_YEAR, 2)
|
|
702
704
|
.appendLiteral('-')
|
|
703
|
-
.appendValue(ChronoField.DAY_OF_WEEK)
|
|
704
|
-
.toFormatter(ResolverStyle.STRICT);
|
|
705
|
+
.appendValue(ChronoField.DAY_OF_WEEK, 1)
|
|
706
|
+
.toFormatter(ResolverStyle.STRICT).withChronology(IsoChronology.INSTANCE);
|
|
705
707
|
|
|
706
708
|
DateTimeFormatter.ISO_DATE = new DateTimeFormatterBuilder()
|
|
707
709
|
.parseCaseInsensitive()
|