@js-joda/core 5.1.0 → 5.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 +3 -1
- package/dist/js-joda.cjs.js +13561 -0
- package/dist/js-joda.cjs.js.map +1 -0
- package/dist/js-joda.esm.js +79 -64
- package/dist/js-joda.esm.js.map +1 -1
- package/dist/js-joda.js +81 -67
- package/dist/js-joda.js.map +1 -1
- package/dist/js-joda.min.js +2 -2
- package/package.json +2 -2
- package/src/Instant.js +42 -1
- package/src/license-preamble.js +0 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@js-joda/core",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2.0",
|
|
4
4
|
"description": "a date and time library for javascript",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"sourceMap": false,
|
|
49
49
|
"instrument": false
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "d07153c38a3d0b2b29b8185e3daaac69c624d4a9"
|
|
52
52
|
}
|
package/src/Instant.js
CHANGED
|
@@ -172,6 +172,20 @@ export class Instant extends Temporal {
|
|
|
172
172
|
return Instant._create(secs, mos * 1000000);
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
+
/**
|
|
176
|
+
* Obtains an instance of {@link Instant} using microseconds from the
|
|
177
|
+
* epoch of 1970-01-01T00:00:00Z.
|
|
178
|
+
*
|
|
179
|
+
* @param {number} epochMicro - the number of microseconds from 1970-01-01T00:00:00Z
|
|
180
|
+
* @return {Instant} an instant, not null
|
|
181
|
+
* @throws DateTimeException if the instant exceeds the maximum or minimum instant
|
|
182
|
+
*/
|
|
183
|
+
static ofEpochMicro(epochMicro) {
|
|
184
|
+
const secs = MathUtil.floorDiv(epochMicro, 1000000);
|
|
185
|
+
const mos = MathUtil.floorMod(epochMicro, 1000000);
|
|
186
|
+
return Instant._create(secs, mos * 1000);
|
|
187
|
+
}
|
|
188
|
+
|
|
175
189
|
/**
|
|
176
190
|
* Obtains an instance of {@link Instant} from a temporal object.
|
|
177
191
|
*
|
|
@@ -525,7 +539,7 @@ export class Instant extends Temporal {
|
|
|
525
539
|
if (unit instanceof ChronoUnit) {
|
|
526
540
|
switch (unit) {
|
|
527
541
|
case ChronoUnit.NANOS: return this.plusNanos(amountToAdd);
|
|
528
|
-
case ChronoUnit.MICROS: return this.
|
|
542
|
+
case ChronoUnit.MICROS: return this.plusMicros(amountToAdd);
|
|
529
543
|
case ChronoUnit.MILLIS: return this.plusMillis(amountToAdd);
|
|
530
544
|
case ChronoUnit.SECONDS: return this.plusSeconds(amountToAdd);
|
|
531
545
|
case ChronoUnit.MINUTES: return this.plusSeconds(MathUtil.safeMultiply(amountToAdd, LocalTime.SECONDS_PER_MINUTE));
|
|
@@ -578,6 +592,19 @@ export class Instant extends Temporal {
|
|
|
578
592
|
return this._plus(0, nanosToAdd);
|
|
579
593
|
}
|
|
580
594
|
|
|
595
|
+
/**
|
|
596
|
+
* Returns a copy of this instant with the specified duration in microseconds added.
|
|
597
|
+
*
|
|
598
|
+
* This instance is immutable and unaffected by this method call.
|
|
599
|
+
*
|
|
600
|
+
* @param {number} microsToAdd - the microseconds to add, positive or negative
|
|
601
|
+
* @return {Instant} an {@link Instant} based on this instant with the specified microseconds added, not null
|
|
602
|
+
* @throws DateTimeException if the result exceeds the maximum or minimum instant
|
|
603
|
+
*/
|
|
604
|
+
plusMicros(microsToAdd) {
|
|
605
|
+
return this._plus(MathUtil.intDiv(microsToAdd, 1000000), MathUtil.intMod(microsToAdd, 1000000) * 1000);
|
|
606
|
+
}
|
|
607
|
+
|
|
581
608
|
/**
|
|
582
609
|
* Returns a copy of this instant with the specified duration added.
|
|
583
610
|
*
|
|
@@ -652,6 +679,20 @@ export class Instant extends Temporal {
|
|
|
652
679
|
return this.plusNanos(-1 * nanosToSubtract);
|
|
653
680
|
}
|
|
654
681
|
|
|
682
|
+
/**
|
|
683
|
+
* Returns a copy of this instant with the specified duration in microseconds subtracted.
|
|
684
|
+
*
|
|
685
|
+
* This instance is immutable and unaffected by this method call.
|
|
686
|
+
*
|
|
687
|
+
* @param {number} microsToSubtract the microseconds to subtract, positive or negative
|
|
688
|
+
* @return {Instant} an {@link Instant} based on this instant with the specified microseconds subtracted, not null
|
|
689
|
+
* @throws DateTimeException if the result exceeds the maximum or minimum instant
|
|
690
|
+
* @throws ArithmeticException if numeric overflow occurs
|
|
691
|
+
*/
|
|
692
|
+
minusMicros(microsToSubtract) {
|
|
693
|
+
return this.plusMicros(-1 * microsToSubtract);
|
|
694
|
+
}
|
|
695
|
+
|
|
655
696
|
//-------------------------------------------------------------------------
|
|
656
697
|
/**
|
|
657
698
|
* Queries this instant using the specified query.
|
package/src/license-preamble.js
DELETED