@barchart/portfolio-api-common 1.2.146 → 1.3.3
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/lib/processing/PositionGroup.js +12 -10
- package/lib/processing/PositionItem.js +32 -8
- package/package.json +2 -2
- package/test/SpecRunner.js +205 -83
|
@@ -691,9 +691,9 @@ module.exports = (() => {
|
|
|
691
691
|
updates.marketPrevious = updates.marketPrevious.add(translate(item, item.data.marketPrevious));
|
|
692
692
|
updates.marketPrevious2 = updates.marketPrevious2.add(translate(item, item.data.marketPrevious2));
|
|
693
693
|
|
|
694
|
+
updates.periodIncome = updates.periodIncome.add(translate(item, item.data.periodIncome));
|
|
694
695
|
updates.periodRealized = updates.periodRealized.add(translate(item, item.data.periodRealized));
|
|
695
696
|
updates.periodUnrealized = updates.periodUnrealized.add(translate(item, item.data.periodUnrealized));
|
|
696
|
-
updates.periodIncome = updates.periodIncome.add(translate(item, item.data.periodIncome));
|
|
697
697
|
|
|
698
698
|
if (item.position.instrument.type === InstrumentType.CASH) {
|
|
699
699
|
updates.cashTotal = updates.cashTotal.add(translate(item, item.data.market));
|
|
@@ -715,9 +715,9 @@ module.exports = (() => {
|
|
|
715
715
|
summaryTotalPrevious2: Decimal.ZERO,
|
|
716
716
|
marketPrevious: Decimal.ZERO,
|
|
717
717
|
marketPrevious2: Decimal.ZERO,
|
|
718
|
+
periodIncome: Decimal.ZERO,
|
|
718
719
|
periodRealized: Decimal.ZERO,
|
|
719
720
|
periodUnrealized: Decimal.ZERO,
|
|
720
|
-
periodIncome: Decimal.ZERO,
|
|
721
721
|
cashTotal: Decimal.ZERO,
|
|
722
722
|
totalDivisor: Decimal.ZERO,
|
|
723
723
|
periodDivisorCurrent: Decimal.ZERO,
|
|
@@ -734,9 +734,9 @@ module.exports = (() => {
|
|
|
734
734
|
actual.summaryTotalPrevious2 = updates.summaryTotalPrevious2;
|
|
735
735
|
actual.marketPrevious = updates.marketPrevious;
|
|
736
736
|
actual.marketPrevious2 = updates.marketPrevious2;
|
|
737
|
+
actual.periodIncome = updates.periodIncome;
|
|
737
738
|
actual.periodRealized = updates.periodRealized;
|
|
738
739
|
actual.periodUnrealized = updates.periodUnrealized;
|
|
739
|
-
actual.periodIncome = updates.periodIncome;
|
|
740
740
|
actual.cashTotal = updates.cashTotal;
|
|
741
741
|
actual.totalDivisor = updates.totalDivisor;
|
|
742
742
|
actual.periodDivisorCurrent = updates.periodDivisorCurrent;
|
|
@@ -755,9 +755,9 @@ module.exports = (() => {
|
|
|
755
755
|
format.summaryTotalPrevious2Negative = updates.summaryTotalPrevious2.getIsNegative();
|
|
756
756
|
format.marketPrevious = formatCurrency(updates.marketPrevious, currency);
|
|
757
757
|
format.marketPrevious2 = formatCurrency(updates.marketPrevious2, currency);
|
|
758
|
+
format.periodIncome = formatCurrency(updates.periodIncome, currency);
|
|
758
759
|
format.periodRealized = formatCurrency(updates.periodRealized, currency);
|
|
759
760
|
format.periodUnrealized = formatCurrency(updates.periodUnrealized, currency);
|
|
760
|
-
format.periodIncome = formatCurrency(updates.periodIncome, currency);
|
|
761
761
|
format.cashTotal = formatCurrency(updates.cashTotal, currency);
|
|
762
762
|
|
|
763
763
|
calculateRealizedPercent(group);
|
|
@@ -846,6 +846,7 @@ module.exports = (() => {
|
|
|
846
846
|
updates.unrealized = updates.unrealized.add(translate(item, item.data.unrealized));
|
|
847
847
|
updates.unrealizedToday = updates.unrealizedToday.add(translate(item, item.data.unrealizedToday));
|
|
848
848
|
updates.summaryTotalCurrent = updates.summaryTotalCurrent.add(translate(item, item.data.periodGain));
|
|
849
|
+
updates.periodUnrealized = updates.periodUnrealized.add(translate(item, item.data.periodUnrealized));
|
|
849
850
|
|
|
850
851
|
return updates;
|
|
851
852
|
}, {
|
|
@@ -854,7 +855,8 @@ module.exports = (() => {
|
|
|
854
855
|
marketDirection: unchanged,
|
|
855
856
|
unrealized: Decimal.ZERO,
|
|
856
857
|
unrealizedToday: Decimal.ZERO,
|
|
857
|
-
summaryTotalCurrent: Decimal.ZERO
|
|
858
|
+
summaryTotalCurrent: Decimal.ZERO,
|
|
859
|
+
periodUnrealized: Decimal.ZERO
|
|
858
860
|
});
|
|
859
861
|
} else {
|
|
860
862
|
updates = {
|
|
@@ -863,7 +865,8 @@ module.exports = (() => {
|
|
|
863
865
|
marketDirection: { up: item.data.marketChange.getIsPositive(), down: item.data.marketChange.getIsNegative() },
|
|
864
866
|
unrealized: actual.unrealized.add(translate(item, item.data.unrealizedChange)),
|
|
865
867
|
unrealizedToday: actual.unrealizedToday.add(translate(item, item.data.unrealizedTodayChange)),
|
|
866
|
-
summaryTotalCurrent: actual.summaryTotalCurrent.add(translate(item, item.data.periodGainChange))
|
|
868
|
+
summaryTotalCurrent: actual.summaryTotalCurrent.add(translate(item, item.data.periodGainChange)),
|
|
869
|
+
periodUnrealized: actual.periodUnrealized.add(translate(item, item.data.periodUnrealizedChange))
|
|
867
870
|
};
|
|
868
871
|
}
|
|
869
872
|
|
|
@@ -872,6 +875,7 @@ module.exports = (() => {
|
|
|
872
875
|
actual.unrealized = updates.unrealized;
|
|
873
876
|
actual.unrealizedToday = updates.unrealizedToday;
|
|
874
877
|
actual.summaryTotalCurrent = updates.summaryTotalCurrent;
|
|
878
|
+
actual.periodUnrealized = updates.periodUnrealized;
|
|
875
879
|
|
|
876
880
|
actual.total = updates.unrealized.add(actual.realized).add(actual.income);
|
|
877
881
|
actual.totalPercent = calculateGainPercent(actual.total, actual.totalDivisor);
|
|
@@ -910,6 +914,8 @@ module.exports = (() => {
|
|
|
910
914
|
format.summaryTotalCurrent = formatCurrency(actual.summaryTotalCurrent, currency);
|
|
911
915
|
format.summaryTotalCurrentNegative = actual.summaryTotalCurrent.getIsNegative();
|
|
912
916
|
|
|
917
|
+
format.periodUnrealized = formatCurrency(actual.periodUnrealized, currency);
|
|
918
|
+
|
|
913
919
|
format.total = formatCurrency(actual.total, currency);
|
|
914
920
|
format.totalNegative = actual.total.getIsNegative();
|
|
915
921
|
format.totalPercent = formatPercent(actual.totalPercent, 2);
|
|
@@ -922,10 +928,6 @@ module.exports = (() => {
|
|
|
922
928
|
|
|
923
929
|
actual.periodPercent = calculateGainPercent(actual.summaryTotalCurrent, actual.periodDivisorCurrent);
|
|
924
930
|
format.periodPercent = formatPercent(actual.periodPercent, 2);
|
|
925
|
-
|
|
926
|
-
if (group.single && item) {
|
|
927
|
-
actual.periodUnrealized = item.data.periodUnrealized;
|
|
928
|
-
}
|
|
929
931
|
}
|
|
930
932
|
|
|
931
933
|
function calculateMarketPercent(group, rates, parentGroup, portfolioGroup) {
|
|
@@ -75,7 +75,9 @@ module.exports = (() => {
|
|
|
75
75
|
|
|
76
76
|
this._data.periodIncome = null;
|
|
77
77
|
this._data.periodRealized = null;
|
|
78
|
+
|
|
78
79
|
this._data.periodUnrealized = null;
|
|
80
|
+
this._data.periodUnrealizedChange = null;
|
|
79
81
|
|
|
80
82
|
this._data.periodPrice = null;
|
|
81
83
|
this._data.periodPricePrevious = null;
|
|
@@ -420,14 +422,14 @@ module.exports = (() => {
|
|
|
420
422
|
data.marketPrevious2 = previousSummary2 === null ? Decimal.ZERO : previousSummary2.end.value;
|
|
421
423
|
data.quantityPrevious = previousSummary1 === null ? Decimal.ZERO : previousSummary1.end.open;
|
|
422
424
|
|
|
423
|
-
data.periodIncome = currentSummary !== null ? currentSummary.period.income : Decimal.ZERO;
|
|
424
|
-
data.periodRealized = currentSummary !== null ? currentSummary.period.realized : Decimal.ZERO;
|
|
425
|
-
data.periodUnrealized = currentSummary !== null ? currentSummary.period.unrealized : Decimal.ZERO;
|
|
426
|
-
|
|
427
425
|
data.periodGain = calculatePeriodGain(position.instrument.type, data.initiate, currentSummary, previousSummary1);
|
|
428
426
|
data.periodGainPrevious = calculatePeriodGain(position.instrument.type, data.initiate, previousSummary1, previousSummary2);
|
|
429
427
|
data.periodGainPrevious2 = calculatePeriodGain(position.instrument.type, data.initiate, previousSummary2, previousSummary3);
|
|
430
428
|
|
|
429
|
+
data.periodIncome = currentSummary !== null ? currentSummary.period.income : Decimal.ZERO;
|
|
430
|
+
data.periodRealized = currentSummary !== null ? currentSummary.period.realized : Decimal.ZERO;
|
|
431
|
+
data.periodUnrealized = calculatePeriodUnrealized(position.instrument.type, data.periodGain, data.periodRealized, data.periodIncome);
|
|
432
|
+
|
|
431
433
|
data.periodDivisor = calculatePeriodDivisor(position.instrument.type, data.initiate, currentSummary, previousSummary1);
|
|
432
434
|
data.periodDivisorPrevious = calculatePeriodDivisor(position.instrument.type, data.initiate, previousSummary1, previousSummary2);
|
|
433
435
|
data.periodDivisorPrevious2 = calculatePeriodDivisor(position.instrument.type, data.initiate, previousSummary2, previousSummary3);
|
|
@@ -555,16 +557,26 @@ module.exports = (() => {
|
|
|
555
557
|
|
|
556
558
|
data.periodGain = periodGain;
|
|
557
559
|
data.periodGainChange = periodGainChange;
|
|
560
|
+
|
|
561
|
+
let periodUnrealized = calculatePeriodUnrealized(position.instrument.type, data.periodGain, data.periodRealized, data.periodIncome);
|
|
562
|
+
let periodUnrealizedChange;
|
|
563
|
+
|
|
564
|
+
if (data.periodUnrealized !== null) {
|
|
565
|
+
periodUnrealizedChange = periodUnrealized.subtract(data.periodUnrealized);
|
|
566
|
+
} else {
|
|
567
|
+
periodUnrealizedChange = Decimal.ZERO;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
data.periodUnrealized = periodUnrealized;
|
|
571
|
+
data.periodUnrealizedChange = periodUnrealizedChange;
|
|
558
572
|
} else {
|
|
559
|
-
data.unrealized = Decimal.ZERO;
|
|
560
573
|
data.unrealizedChange = Decimal.ZERO;
|
|
561
|
-
|
|
574
|
+
data.periodUnrealizedChange = Decimal.ZERO;
|
|
562
575
|
data.periodGainChange = Decimal.ZERO;
|
|
563
576
|
}
|
|
564
577
|
} else {
|
|
565
|
-
data.unrealized = Decimal.ZERO;
|
|
566
578
|
data.unrealizedChange = Decimal.ZERO;
|
|
567
|
-
|
|
579
|
+
data.periodUnrealizedChange = Decimal.ZERO;
|
|
568
580
|
data.periodGainChange = Decimal.ZERO;
|
|
569
581
|
}
|
|
570
582
|
}
|
|
@@ -645,6 +657,18 @@ module.exports = (() => {
|
|
|
645
657
|
return returnRef;
|
|
646
658
|
}
|
|
647
659
|
|
|
660
|
+
function calculatePeriodUnrealized(type, periodGain, periodRealized, periodIncome) {
|
|
661
|
+
let returnRef;
|
|
662
|
+
|
|
663
|
+
if (type !== InstrumentType.CASH) {
|
|
664
|
+
returnRef = periodRealized.add(periodIncome).subtract(periodGain).opposite();
|
|
665
|
+
} else {
|
|
666
|
+
returnRef = Decimal.ZERO;
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
return returnRef;
|
|
670
|
+
}
|
|
671
|
+
|
|
648
672
|
function calculateTotalDivisor(type, direction, finalSummary, position) {
|
|
649
673
|
let returnRef;
|
|
650
674
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@barchart/portfolio-api-common",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.3",
|
|
4
4
|
"description": "Common classes used by the Portfolio system",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Bryan Ingle",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"scripts": {},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@barchart/common-js": "~3.
|
|
12
|
+
"@barchart/common-js": "~3.3.0",
|
|
13
13
|
"uuid": "3.1.0"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
package/test/SpecRunner.js
CHANGED
|
@@ -3213,9 +3213,9 @@ module.exports = (() => {
|
|
|
3213
3213
|
updates.marketPrevious = updates.marketPrevious.add(translate(item, item.data.marketPrevious));
|
|
3214
3214
|
updates.marketPrevious2 = updates.marketPrevious2.add(translate(item, item.data.marketPrevious2));
|
|
3215
3215
|
|
|
3216
|
+
updates.periodIncome = updates.periodIncome.add(translate(item, item.data.periodIncome));
|
|
3216
3217
|
updates.periodRealized = updates.periodRealized.add(translate(item, item.data.periodRealized));
|
|
3217
3218
|
updates.periodUnrealized = updates.periodUnrealized.add(translate(item, item.data.periodUnrealized));
|
|
3218
|
-
updates.periodIncome = updates.periodIncome.add(translate(item, item.data.periodIncome));
|
|
3219
3219
|
|
|
3220
3220
|
if (item.position.instrument.type === InstrumentType.CASH) {
|
|
3221
3221
|
updates.cashTotal = updates.cashTotal.add(translate(item, item.data.market));
|
|
@@ -3237,9 +3237,9 @@ module.exports = (() => {
|
|
|
3237
3237
|
summaryTotalPrevious2: Decimal.ZERO,
|
|
3238
3238
|
marketPrevious: Decimal.ZERO,
|
|
3239
3239
|
marketPrevious2: Decimal.ZERO,
|
|
3240
|
+
periodIncome: Decimal.ZERO,
|
|
3240
3241
|
periodRealized: Decimal.ZERO,
|
|
3241
3242
|
periodUnrealized: Decimal.ZERO,
|
|
3242
|
-
periodIncome: Decimal.ZERO,
|
|
3243
3243
|
cashTotal: Decimal.ZERO,
|
|
3244
3244
|
totalDivisor: Decimal.ZERO,
|
|
3245
3245
|
periodDivisorCurrent: Decimal.ZERO,
|
|
@@ -3256,9 +3256,9 @@ module.exports = (() => {
|
|
|
3256
3256
|
actual.summaryTotalPrevious2 = updates.summaryTotalPrevious2;
|
|
3257
3257
|
actual.marketPrevious = updates.marketPrevious;
|
|
3258
3258
|
actual.marketPrevious2 = updates.marketPrevious2;
|
|
3259
|
+
actual.periodIncome = updates.periodIncome;
|
|
3259
3260
|
actual.periodRealized = updates.periodRealized;
|
|
3260
3261
|
actual.periodUnrealized = updates.periodUnrealized;
|
|
3261
|
-
actual.periodIncome = updates.periodIncome;
|
|
3262
3262
|
actual.cashTotal = updates.cashTotal;
|
|
3263
3263
|
actual.totalDivisor = updates.totalDivisor;
|
|
3264
3264
|
actual.periodDivisorCurrent = updates.periodDivisorCurrent;
|
|
@@ -3277,9 +3277,9 @@ module.exports = (() => {
|
|
|
3277
3277
|
format.summaryTotalPrevious2Negative = updates.summaryTotalPrevious2.getIsNegative();
|
|
3278
3278
|
format.marketPrevious = formatCurrency(updates.marketPrevious, currency);
|
|
3279
3279
|
format.marketPrevious2 = formatCurrency(updates.marketPrevious2, currency);
|
|
3280
|
+
format.periodIncome = formatCurrency(updates.periodIncome, currency);
|
|
3280
3281
|
format.periodRealized = formatCurrency(updates.periodRealized, currency);
|
|
3281
3282
|
format.periodUnrealized = formatCurrency(updates.periodUnrealized, currency);
|
|
3282
|
-
format.periodIncome = formatCurrency(updates.periodIncome, currency);
|
|
3283
3283
|
format.cashTotal = formatCurrency(updates.cashTotal, currency);
|
|
3284
3284
|
|
|
3285
3285
|
calculateRealizedPercent(group);
|
|
@@ -3368,6 +3368,7 @@ module.exports = (() => {
|
|
|
3368
3368
|
updates.unrealized = updates.unrealized.add(translate(item, item.data.unrealized));
|
|
3369
3369
|
updates.unrealizedToday = updates.unrealizedToday.add(translate(item, item.data.unrealizedToday));
|
|
3370
3370
|
updates.summaryTotalCurrent = updates.summaryTotalCurrent.add(translate(item, item.data.periodGain));
|
|
3371
|
+
updates.periodUnrealized = updates.periodUnrealized.add(translate(item, item.data.periodUnrealized));
|
|
3371
3372
|
|
|
3372
3373
|
return updates;
|
|
3373
3374
|
}, {
|
|
@@ -3376,7 +3377,8 @@ module.exports = (() => {
|
|
|
3376
3377
|
marketDirection: unchanged,
|
|
3377
3378
|
unrealized: Decimal.ZERO,
|
|
3378
3379
|
unrealizedToday: Decimal.ZERO,
|
|
3379
|
-
summaryTotalCurrent: Decimal.ZERO
|
|
3380
|
+
summaryTotalCurrent: Decimal.ZERO,
|
|
3381
|
+
periodUnrealized: Decimal.ZERO
|
|
3380
3382
|
});
|
|
3381
3383
|
} else {
|
|
3382
3384
|
updates = {
|
|
@@ -3385,7 +3387,8 @@ module.exports = (() => {
|
|
|
3385
3387
|
marketDirection: { up: item.data.marketChange.getIsPositive(), down: item.data.marketChange.getIsNegative() },
|
|
3386
3388
|
unrealized: actual.unrealized.add(translate(item, item.data.unrealizedChange)),
|
|
3387
3389
|
unrealizedToday: actual.unrealizedToday.add(translate(item, item.data.unrealizedTodayChange)),
|
|
3388
|
-
summaryTotalCurrent: actual.summaryTotalCurrent.add(translate(item, item.data.periodGainChange))
|
|
3390
|
+
summaryTotalCurrent: actual.summaryTotalCurrent.add(translate(item, item.data.periodGainChange)),
|
|
3391
|
+
periodUnrealized: actual.periodUnrealized.add(translate(item, item.data.periodUnrealizedChange))
|
|
3389
3392
|
};
|
|
3390
3393
|
}
|
|
3391
3394
|
|
|
@@ -3394,6 +3397,7 @@ module.exports = (() => {
|
|
|
3394
3397
|
actual.unrealized = updates.unrealized;
|
|
3395
3398
|
actual.unrealizedToday = updates.unrealizedToday;
|
|
3396
3399
|
actual.summaryTotalCurrent = updates.summaryTotalCurrent;
|
|
3400
|
+
actual.periodUnrealized = updates.periodUnrealized;
|
|
3397
3401
|
|
|
3398
3402
|
actual.total = updates.unrealized.add(actual.realized).add(actual.income);
|
|
3399
3403
|
actual.totalPercent = calculateGainPercent(actual.total, actual.totalDivisor);
|
|
@@ -3432,6 +3436,8 @@ module.exports = (() => {
|
|
|
3432
3436
|
format.summaryTotalCurrent = formatCurrency(actual.summaryTotalCurrent, currency);
|
|
3433
3437
|
format.summaryTotalCurrentNegative = actual.summaryTotalCurrent.getIsNegative();
|
|
3434
3438
|
|
|
3439
|
+
format.periodUnrealized = formatCurrency(actual.periodUnrealized, currency);
|
|
3440
|
+
|
|
3435
3441
|
format.total = formatCurrency(actual.total, currency);
|
|
3436
3442
|
format.totalNegative = actual.total.getIsNegative();
|
|
3437
3443
|
format.totalPercent = formatPercent(actual.totalPercent, 2);
|
|
@@ -3444,10 +3450,6 @@ module.exports = (() => {
|
|
|
3444
3450
|
|
|
3445
3451
|
actual.periodPercent = calculateGainPercent(actual.summaryTotalCurrent, actual.periodDivisorCurrent);
|
|
3446
3452
|
format.periodPercent = formatPercent(actual.periodPercent, 2);
|
|
3447
|
-
|
|
3448
|
-
if (group.single && item) {
|
|
3449
|
-
actual.periodUnrealized = item.data.periodUnrealized;
|
|
3450
|
-
}
|
|
3451
3453
|
}
|
|
3452
3454
|
|
|
3453
3455
|
function calculateMarketPercent(group, rates, parentGroup, portfolioGroup) {
|
|
@@ -3615,7 +3617,9 @@ module.exports = (() => {
|
|
|
3615
3617
|
|
|
3616
3618
|
this._data.periodIncome = null;
|
|
3617
3619
|
this._data.periodRealized = null;
|
|
3620
|
+
|
|
3618
3621
|
this._data.periodUnrealized = null;
|
|
3622
|
+
this._data.periodUnrealizedChange = null;
|
|
3619
3623
|
|
|
3620
3624
|
this._data.periodPrice = null;
|
|
3621
3625
|
this._data.periodPricePrevious = null;
|
|
@@ -3960,14 +3964,14 @@ module.exports = (() => {
|
|
|
3960
3964
|
data.marketPrevious2 = previousSummary2 === null ? Decimal.ZERO : previousSummary2.end.value;
|
|
3961
3965
|
data.quantityPrevious = previousSummary1 === null ? Decimal.ZERO : previousSummary1.end.open;
|
|
3962
3966
|
|
|
3963
|
-
data.periodIncome = currentSummary !== null ? currentSummary.period.income : Decimal.ZERO;
|
|
3964
|
-
data.periodRealized = currentSummary !== null ? currentSummary.period.realized : Decimal.ZERO;
|
|
3965
|
-
data.periodUnrealized = currentSummary !== null ? currentSummary.period.unrealized : Decimal.ZERO;
|
|
3966
|
-
|
|
3967
3967
|
data.periodGain = calculatePeriodGain(position.instrument.type, data.initiate, currentSummary, previousSummary1);
|
|
3968
3968
|
data.periodGainPrevious = calculatePeriodGain(position.instrument.type, data.initiate, previousSummary1, previousSummary2);
|
|
3969
3969
|
data.periodGainPrevious2 = calculatePeriodGain(position.instrument.type, data.initiate, previousSummary2, previousSummary3);
|
|
3970
3970
|
|
|
3971
|
+
data.periodIncome = currentSummary !== null ? currentSummary.period.income : Decimal.ZERO;
|
|
3972
|
+
data.periodRealized = currentSummary !== null ? currentSummary.period.realized : Decimal.ZERO;
|
|
3973
|
+
data.periodUnrealized = calculatePeriodUnrealized(position.instrument.type, data.periodGain, data.periodRealized, data.periodIncome);
|
|
3974
|
+
|
|
3971
3975
|
data.periodDivisor = calculatePeriodDivisor(position.instrument.type, data.initiate, currentSummary, previousSummary1);
|
|
3972
3976
|
data.periodDivisorPrevious = calculatePeriodDivisor(position.instrument.type, data.initiate, previousSummary1, previousSummary2);
|
|
3973
3977
|
data.periodDivisorPrevious2 = calculatePeriodDivisor(position.instrument.type, data.initiate, previousSummary2, previousSummary3);
|
|
@@ -4095,16 +4099,26 @@ module.exports = (() => {
|
|
|
4095
4099
|
|
|
4096
4100
|
data.periodGain = periodGain;
|
|
4097
4101
|
data.periodGainChange = periodGainChange;
|
|
4102
|
+
|
|
4103
|
+
let periodUnrealized = calculatePeriodUnrealized(position.instrument.type, data.periodGain, data.periodRealized, data.periodIncome);
|
|
4104
|
+
let periodUnrealizedChange;
|
|
4105
|
+
|
|
4106
|
+
if (data.periodUnrealized !== null) {
|
|
4107
|
+
periodUnrealizedChange = periodUnrealized.subtract(data.periodUnrealized);
|
|
4108
|
+
} else {
|
|
4109
|
+
periodUnrealizedChange = Decimal.ZERO;
|
|
4110
|
+
}
|
|
4111
|
+
|
|
4112
|
+
data.periodUnrealized = periodUnrealized;
|
|
4113
|
+
data.periodUnrealizedChange = periodUnrealizedChange;
|
|
4098
4114
|
} else {
|
|
4099
|
-
data.unrealized = Decimal.ZERO;
|
|
4100
4115
|
data.unrealizedChange = Decimal.ZERO;
|
|
4101
|
-
|
|
4116
|
+
data.periodUnrealizedChange = Decimal.ZERO;
|
|
4102
4117
|
data.periodGainChange = Decimal.ZERO;
|
|
4103
4118
|
}
|
|
4104
4119
|
} else {
|
|
4105
|
-
data.unrealized = Decimal.ZERO;
|
|
4106
4120
|
data.unrealizedChange = Decimal.ZERO;
|
|
4107
|
-
|
|
4121
|
+
data.periodUnrealizedChange = Decimal.ZERO;
|
|
4108
4122
|
data.periodGainChange = Decimal.ZERO;
|
|
4109
4123
|
}
|
|
4110
4124
|
}
|
|
@@ -4185,6 +4199,18 @@ module.exports = (() => {
|
|
|
4185
4199
|
return returnRef;
|
|
4186
4200
|
}
|
|
4187
4201
|
|
|
4202
|
+
function calculatePeriodUnrealized(type, periodGain, periodRealized, periodIncome) {
|
|
4203
|
+
let returnRef;
|
|
4204
|
+
|
|
4205
|
+
if (type !== InstrumentType.CASH) {
|
|
4206
|
+
returnRef = periodRealized.add(periodIncome).subtract(periodGain).opposite();
|
|
4207
|
+
} else {
|
|
4208
|
+
returnRef = Decimal.ZERO;
|
|
4209
|
+
}
|
|
4210
|
+
|
|
4211
|
+
return returnRef;
|
|
4212
|
+
}
|
|
4213
|
+
|
|
4188
4214
|
function calculateTotalDivisor(type, direction, finalSummary, position) {
|
|
4189
4215
|
let returnRef;
|
|
4190
4216
|
|
|
@@ -14055,22 +14081,36 @@ moment.tz.load(require('./data/packed/latest.json'));
|
|
|
14055
14081
|
function createDate (y, m, d, h, M, s, ms) {
|
|
14056
14082
|
// can't just apply() to create a date:
|
|
14057
14083
|
// https://stackoverflow.com/q/181348
|
|
14058
|
-
var date
|
|
14059
|
-
|
|
14084
|
+
var date;
|
|
14060
14085
|
// the date constructor remaps years 0-99 to 1900-1999
|
|
14061
|
-
if (y < 100 && y >= 0
|
|
14062
|
-
|
|
14086
|
+
if (y < 100 && y >= 0) {
|
|
14087
|
+
// preserve leap years using a full 400 year cycle, then reset
|
|
14088
|
+
date = new Date(y + 400, m, d, h, M, s, ms);
|
|
14089
|
+
if (isFinite(date.getFullYear())) {
|
|
14090
|
+
date.setFullYear(y);
|
|
14091
|
+
}
|
|
14092
|
+
} else {
|
|
14093
|
+
date = new Date(y, m, d, h, M, s, ms);
|
|
14063
14094
|
}
|
|
14095
|
+
|
|
14064
14096
|
return date;
|
|
14065
14097
|
}
|
|
14066
14098
|
|
|
14067
14099
|
function createUTCDate (y) {
|
|
14068
|
-
var date
|
|
14069
|
-
|
|
14100
|
+
var date;
|
|
14070
14101
|
// the Date.UTC function remaps years 0-99 to 1900-1999
|
|
14071
|
-
if (y < 100 && y >= 0
|
|
14072
|
-
|
|
14102
|
+
if (y < 100 && y >= 0) {
|
|
14103
|
+
var args = Array.prototype.slice.call(arguments);
|
|
14104
|
+
// preserve leap years using a full 400 year cycle, then reset
|
|
14105
|
+
args[0] = y + 400;
|
|
14106
|
+
date = new Date(Date.UTC.apply(null, args));
|
|
14107
|
+
if (isFinite(date.getUTCFullYear())) {
|
|
14108
|
+
date.setUTCFullYear(y);
|
|
14109
|
+
}
|
|
14110
|
+
} else {
|
|
14111
|
+
date = new Date(Date.UTC.apply(null, arguments));
|
|
14073
14112
|
}
|
|
14113
|
+
|
|
14074
14114
|
return date;
|
|
14075
14115
|
}
|
|
14076
14116
|
|
|
@@ -14172,7 +14212,7 @@ moment.tz.load(require('./data/packed/latest.json'));
|
|
|
14172
14212
|
|
|
14173
14213
|
var defaultLocaleWeek = {
|
|
14174
14214
|
dow : 0, // Sunday is the first day of the week.
|
|
14175
|
-
doy : 6 // The week that contains Jan
|
|
14215
|
+
doy : 6 // The week that contains Jan 6th is the first week of the year.
|
|
14176
14216
|
};
|
|
14177
14217
|
|
|
14178
14218
|
function localeFirstDayOfWeek () {
|
|
@@ -14281,25 +14321,28 @@ moment.tz.load(require('./data/packed/latest.json'));
|
|
|
14281
14321
|
}
|
|
14282
14322
|
|
|
14283
14323
|
// LOCALES
|
|
14324
|
+
function shiftWeekdays (ws, n) {
|
|
14325
|
+
return ws.slice(n, 7).concat(ws.slice(0, n));
|
|
14326
|
+
}
|
|
14284
14327
|
|
|
14285
14328
|
var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_');
|
|
14286
14329
|
function localeWeekdays (m, format) {
|
|
14287
|
-
|
|
14288
|
-
|
|
14289
|
-
|
|
14290
|
-
|
|
14291
|
-
return isArray(this._weekdays) ? this._weekdays[m.day()] :
|
|
14292
|
-
this._weekdays[this._weekdays.isFormat.test(format) ? 'format' : 'standalone'][m.day()];
|
|
14330
|
+
var weekdays = isArray(this._weekdays) ? this._weekdays :
|
|
14331
|
+
this._weekdays[(m && m !== true && this._weekdays.isFormat.test(format)) ? 'format' : 'standalone'];
|
|
14332
|
+
return (m === true) ? shiftWeekdays(weekdays, this._week.dow)
|
|
14333
|
+
: (m) ? weekdays[m.day()] : weekdays;
|
|
14293
14334
|
}
|
|
14294
14335
|
|
|
14295
14336
|
var defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_');
|
|
14296
14337
|
function localeWeekdaysShort (m) {
|
|
14297
|
-
return (m) ? this._weekdaysShort
|
|
14338
|
+
return (m === true) ? shiftWeekdays(this._weekdaysShort, this._week.dow)
|
|
14339
|
+
: (m) ? this._weekdaysShort[m.day()] : this._weekdaysShort;
|
|
14298
14340
|
}
|
|
14299
14341
|
|
|
14300
14342
|
var defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_');
|
|
14301
14343
|
function localeWeekdaysMin (m) {
|
|
14302
|
-
return (m) ? this._weekdaysMin
|
|
14344
|
+
return (m === true) ? shiftWeekdays(this._weekdaysMin, this._week.dow)
|
|
14345
|
+
: (m) ? this._weekdaysMin[m.day()] : this._weekdaysMin;
|
|
14303
14346
|
}
|
|
14304
14347
|
|
|
14305
14348
|
function handleStrictParse$1(weekdayName, format, strict) {
|
|
@@ -15048,13 +15091,13 @@ moment.tz.load(require('./data/packed/latest.json'));
|
|
|
15048
15091
|
weekdayOverflow = true;
|
|
15049
15092
|
}
|
|
15050
15093
|
} else if (w.e != null) {
|
|
15051
|
-
// local weekday -- counting starts from
|
|
15094
|
+
// local weekday -- counting starts from beginning of week
|
|
15052
15095
|
weekday = w.e + dow;
|
|
15053
15096
|
if (w.e < 0 || w.e > 6) {
|
|
15054
15097
|
weekdayOverflow = true;
|
|
15055
15098
|
}
|
|
15056
15099
|
} else {
|
|
15057
|
-
// default to
|
|
15100
|
+
// default to beginning of week
|
|
15058
15101
|
weekday = dow;
|
|
15059
15102
|
}
|
|
15060
15103
|
}
|
|
@@ -15648,7 +15691,7 @@ moment.tz.load(require('./data/packed/latest.json'));
|
|
|
15648
15691
|
years = normalizedInput.year || 0,
|
|
15649
15692
|
quarters = normalizedInput.quarter || 0,
|
|
15650
15693
|
months = normalizedInput.month || 0,
|
|
15651
|
-
weeks = normalizedInput.week || 0,
|
|
15694
|
+
weeks = normalizedInput.week || normalizedInput.isoWeek || 0,
|
|
15652
15695
|
days = normalizedInput.day || 0,
|
|
15653
15696
|
hours = normalizedInput.hour || 0,
|
|
15654
15697
|
minutes = normalizedInput.minute || 0,
|
|
@@ -15952,7 +15995,7 @@ moment.tz.load(require('./data/packed/latest.json'));
|
|
|
15952
15995
|
ms : toInt(absRound(match[MILLISECOND] * 1000)) * sign // the millisecond decimal point is included in the match
|
|
15953
15996
|
};
|
|
15954
15997
|
} else if (!!(match = isoRegex.exec(input))) {
|
|
15955
|
-
sign = (match[1] === '-') ? -1 :
|
|
15998
|
+
sign = (match[1] === '-') ? -1 : 1;
|
|
15956
15999
|
duration = {
|
|
15957
16000
|
y : parseIso(match[2], sign),
|
|
15958
16001
|
M : parseIso(match[3], sign),
|
|
@@ -15994,7 +16037,7 @@ moment.tz.load(require('./data/packed/latest.json'));
|
|
|
15994
16037
|
}
|
|
15995
16038
|
|
|
15996
16039
|
function positiveMomentsDifference(base, other) {
|
|
15997
|
-
var res = {
|
|
16040
|
+
var res = {};
|
|
15998
16041
|
|
|
15999
16042
|
res.months = other.month() - base.month() +
|
|
16000
16043
|
(other.year() - base.year()) * 12;
|
|
@@ -16103,7 +16146,7 @@ moment.tz.load(require('./data/packed/latest.json'));
|
|
|
16103
16146
|
if (!(this.isValid() && localInput.isValid())) {
|
|
16104
16147
|
return false;
|
|
16105
16148
|
}
|
|
16106
|
-
units = normalizeUnits(
|
|
16149
|
+
units = normalizeUnits(units) || 'millisecond';
|
|
16107
16150
|
if (units === 'millisecond') {
|
|
16108
16151
|
return this.valueOf() > localInput.valueOf();
|
|
16109
16152
|
} else {
|
|
@@ -16116,7 +16159,7 @@ moment.tz.load(require('./data/packed/latest.json'));
|
|
|
16116
16159
|
if (!(this.isValid() && localInput.isValid())) {
|
|
16117
16160
|
return false;
|
|
16118
16161
|
}
|
|
16119
|
-
units = normalizeUnits(
|
|
16162
|
+
units = normalizeUnits(units) || 'millisecond';
|
|
16120
16163
|
if (units === 'millisecond') {
|
|
16121
16164
|
return this.valueOf() < localInput.valueOf();
|
|
16122
16165
|
} else {
|
|
@@ -16125,9 +16168,14 @@ moment.tz.load(require('./data/packed/latest.json'));
|
|
|
16125
16168
|
}
|
|
16126
16169
|
|
|
16127
16170
|
function isBetween (from, to, units, inclusivity) {
|
|
16171
|
+
var localFrom = isMoment(from) ? from : createLocal(from),
|
|
16172
|
+
localTo = isMoment(to) ? to : createLocal(to);
|
|
16173
|
+
if (!(this.isValid() && localFrom.isValid() && localTo.isValid())) {
|
|
16174
|
+
return false;
|
|
16175
|
+
}
|
|
16128
16176
|
inclusivity = inclusivity || '()';
|
|
16129
|
-
return (inclusivity[0] === '(' ? this.isAfter(
|
|
16130
|
-
(inclusivity[1] === ')' ? this.isBefore(
|
|
16177
|
+
return (inclusivity[0] === '(' ? this.isAfter(localFrom, units) : !this.isBefore(localFrom, units)) &&
|
|
16178
|
+
(inclusivity[1] === ')' ? this.isBefore(localTo, units) : !this.isAfter(localTo, units));
|
|
16131
16179
|
}
|
|
16132
16180
|
|
|
16133
16181
|
function isSame (input, units) {
|
|
@@ -16136,7 +16184,7 @@ moment.tz.load(require('./data/packed/latest.json'));
|
|
|
16136
16184
|
if (!(this.isValid() && localInput.isValid())) {
|
|
16137
16185
|
return false;
|
|
16138
16186
|
}
|
|
16139
|
-
units = normalizeUnits(units || 'millisecond'
|
|
16187
|
+
units = normalizeUnits(units) || 'millisecond';
|
|
16140
16188
|
if (units === 'millisecond') {
|
|
16141
16189
|
return this.valueOf() === localInput.valueOf();
|
|
16142
16190
|
} else {
|
|
@@ -16146,11 +16194,11 @@ moment.tz.load(require('./data/packed/latest.json'));
|
|
|
16146
16194
|
}
|
|
16147
16195
|
|
|
16148
16196
|
function isSameOrAfter (input, units) {
|
|
16149
|
-
return this.isSame(input, units) || this.isAfter(input,units);
|
|
16197
|
+
return this.isSame(input, units) || this.isAfter(input, units);
|
|
16150
16198
|
}
|
|
16151
16199
|
|
|
16152
16200
|
function isSameOrBefore (input, units) {
|
|
16153
|
-
return this.isSame(input, units) || this.isBefore(input,units);
|
|
16201
|
+
return this.isSame(input, units) || this.isBefore(input, units);
|
|
16154
16202
|
}
|
|
16155
16203
|
|
|
16156
16204
|
function diff (input, units, asFloat) {
|
|
@@ -16327,62 +16375,130 @@ moment.tz.load(require('./data/packed/latest.json'));
|
|
|
16327
16375
|
return this._locale;
|
|
16328
16376
|
}
|
|
16329
16377
|
|
|
16378
|
+
var MS_PER_SECOND = 1000;
|
|
16379
|
+
var MS_PER_MINUTE = 60 * MS_PER_SECOND;
|
|
16380
|
+
var MS_PER_HOUR = 60 * MS_PER_MINUTE;
|
|
16381
|
+
var MS_PER_400_YEARS = (365 * 400 + 97) * 24 * MS_PER_HOUR;
|
|
16382
|
+
|
|
16383
|
+
// actual modulo - handles negative numbers (for dates before 1970):
|
|
16384
|
+
function mod$1(dividend, divisor) {
|
|
16385
|
+
return (dividend % divisor + divisor) % divisor;
|
|
16386
|
+
}
|
|
16387
|
+
|
|
16388
|
+
function localStartOfDate(y, m, d) {
|
|
16389
|
+
// the date constructor remaps years 0-99 to 1900-1999
|
|
16390
|
+
if (y < 100 && y >= 0) {
|
|
16391
|
+
// preserve leap years using a full 400 year cycle, then reset
|
|
16392
|
+
return new Date(y + 400, m, d) - MS_PER_400_YEARS;
|
|
16393
|
+
} else {
|
|
16394
|
+
return new Date(y, m, d).valueOf();
|
|
16395
|
+
}
|
|
16396
|
+
}
|
|
16397
|
+
|
|
16398
|
+
function utcStartOfDate(y, m, d) {
|
|
16399
|
+
// Date.UTC remaps years 0-99 to 1900-1999
|
|
16400
|
+
if (y < 100 && y >= 0) {
|
|
16401
|
+
// preserve leap years using a full 400 year cycle, then reset
|
|
16402
|
+
return Date.UTC(y + 400, m, d) - MS_PER_400_YEARS;
|
|
16403
|
+
} else {
|
|
16404
|
+
return Date.UTC(y, m, d);
|
|
16405
|
+
}
|
|
16406
|
+
}
|
|
16407
|
+
|
|
16330
16408
|
function startOf (units) {
|
|
16409
|
+
var time;
|
|
16331
16410
|
units = normalizeUnits(units);
|
|
16332
|
-
|
|
16333
|
-
|
|
16411
|
+
if (units === undefined || units === 'millisecond' || !this.isValid()) {
|
|
16412
|
+
return this;
|
|
16413
|
+
}
|
|
16414
|
+
|
|
16415
|
+
var startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
|
|
16416
|
+
|
|
16334
16417
|
switch (units) {
|
|
16335
16418
|
case 'year':
|
|
16336
|
-
this.
|
|
16337
|
-
|
|
16419
|
+
time = startOfDate(this.year(), 0, 1);
|
|
16420
|
+
break;
|
|
16338
16421
|
case 'quarter':
|
|
16422
|
+
time = startOfDate(this.year(), this.month() - this.month() % 3, 1);
|
|
16423
|
+
break;
|
|
16339
16424
|
case 'month':
|
|
16340
|
-
this.
|
|
16341
|
-
|
|
16425
|
+
time = startOfDate(this.year(), this.month(), 1);
|
|
16426
|
+
break;
|
|
16342
16427
|
case 'week':
|
|
16428
|
+
time = startOfDate(this.year(), this.month(), this.date() - this.weekday());
|
|
16429
|
+
break;
|
|
16343
16430
|
case 'isoWeek':
|
|
16431
|
+
time = startOfDate(this.year(), this.month(), this.date() - (this.isoWeekday() - 1));
|
|
16432
|
+
break;
|
|
16344
16433
|
case 'day':
|
|
16345
16434
|
case 'date':
|
|
16346
|
-
this.
|
|
16347
|
-
|
|
16435
|
+
time = startOfDate(this.year(), this.month(), this.date());
|
|
16436
|
+
break;
|
|
16348
16437
|
case 'hour':
|
|
16349
|
-
this.
|
|
16350
|
-
|
|
16438
|
+
time = this._d.valueOf();
|
|
16439
|
+
time -= mod$1(time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE), MS_PER_HOUR);
|
|
16440
|
+
break;
|
|
16351
16441
|
case 'minute':
|
|
16352
|
-
this.
|
|
16353
|
-
|
|
16442
|
+
time = this._d.valueOf();
|
|
16443
|
+
time -= mod$1(time, MS_PER_MINUTE);
|
|
16444
|
+
break;
|
|
16354
16445
|
case 'second':
|
|
16355
|
-
this.
|
|
16356
|
-
|
|
16357
|
-
|
|
16358
|
-
// weeks are a special case
|
|
16359
|
-
if (units === 'week') {
|
|
16360
|
-
this.weekday(0);
|
|
16361
|
-
}
|
|
16362
|
-
if (units === 'isoWeek') {
|
|
16363
|
-
this.isoWeekday(1);
|
|
16364
|
-
}
|
|
16365
|
-
|
|
16366
|
-
// quarters are also special
|
|
16367
|
-
if (units === 'quarter') {
|
|
16368
|
-
this.month(Math.floor(this.month() / 3) * 3);
|
|
16446
|
+
time = this._d.valueOf();
|
|
16447
|
+
time -= mod$1(time, MS_PER_SECOND);
|
|
16448
|
+
break;
|
|
16369
16449
|
}
|
|
16370
16450
|
|
|
16451
|
+
this._d.setTime(time);
|
|
16452
|
+
hooks.updateOffset(this, true);
|
|
16371
16453
|
return this;
|
|
16372
16454
|
}
|
|
16373
16455
|
|
|
16374
16456
|
function endOf (units) {
|
|
16457
|
+
var time;
|
|
16375
16458
|
units = normalizeUnits(units);
|
|
16376
|
-
if (units === undefined || units === 'millisecond') {
|
|
16459
|
+
if (units === undefined || units === 'millisecond' || !this.isValid()) {
|
|
16377
16460
|
return this;
|
|
16378
16461
|
}
|
|
16379
16462
|
|
|
16380
|
-
|
|
16381
|
-
|
|
16382
|
-
|
|
16463
|
+
var startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
|
|
16464
|
+
|
|
16465
|
+
switch (units) {
|
|
16466
|
+
case 'year':
|
|
16467
|
+
time = startOfDate(this.year() + 1, 0, 1) - 1;
|
|
16468
|
+
break;
|
|
16469
|
+
case 'quarter':
|
|
16470
|
+
time = startOfDate(this.year(), this.month() - this.month() % 3 + 3, 1) - 1;
|
|
16471
|
+
break;
|
|
16472
|
+
case 'month':
|
|
16473
|
+
time = startOfDate(this.year(), this.month() + 1, 1) - 1;
|
|
16474
|
+
break;
|
|
16475
|
+
case 'week':
|
|
16476
|
+
time = startOfDate(this.year(), this.month(), this.date() - this.weekday() + 7) - 1;
|
|
16477
|
+
break;
|
|
16478
|
+
case 'isoWeek':
|
|
16479
|
+
time = startOfDate(this.year(), this.month(), this.date() - (this.isoWeekday() - 1) + 7) - 1;
|
|
16480
|
+
break;
|
|
16481
|
+
case 'day':
|
|
16482
|
+
case 'date':
|
|
16483
|
+
time = startOfDate(this.year(), this.month(), this.date() + 1) - 1;
|
|
16484
|
+
break;
|
|
16485
|
+
case 'hour':
|
|
16486
|
+
time = this._d.valueOf();
|
|
16487
|
+
time += MS_PER_HOUR - mod$1(time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE), MS_PER_HOUR) - 1;
|
|
16488
|
+
break;
|
|
16489
|
+
case 'minute':
|
|
16490
|
+
time = this._d.valueOf();
|
|
16491
|
+
time += MS_PER_MINUTE - mod$1(time, MS_PER_MINUTE) - 1;
|
|
16492
|
+
break;
|
|
16493
|
+
case 'second':
|
|
16494
|
+
time = this._d.valueOf();
|
|
16495
|
+
time += MS_PER_SECOND - mod$1(time, MS_PER_SECOND) - 1;
|
|
16496
|
+
break;
|
|
16383
16497
|
}
|
|
16384
16498
|
|
|
16385
|
-
|
|
16499
|
+
this._d.setTime(time);
|
|
16500
|
+
hooks.updateOffset(this, true);
|
|
16501
|
+
return this;
|
|
16386
16502
|
}
|
|
16387
16503
|
|
|
16388
16504
|
function valueOf () {
|
|
@@ -17088,10 +17204,14 @@ moment.tz.load(require('./data/packed/latest.json'));
|
|
|
17088
17204
|
|
|
17089
17205
|
units = normalizeUnits(units);
|
|
17090
17206
|
|
|
17091
|
-
if (units === 'month' || units === 'year') {
|
|
17092
|
-
days
|
|
17207
|
+
if (units === 'month' || units === 'quarter' || units === 'year') {
|
|
17208
|
+
days = this._days + milliseconds / 864e5;
|
|
17093
17209
|
months = this._months + daysToMonths(days);
|
|
17094
|
-
|
|
17210
|
+
switch (units) {
|
|
17211
|
+
case 'month': return months;
|
|
17212
|
+
case 'quarter': return months / 3;
|
|
17213
|
+
case 'year': return months / 12;
|
|
17214
|
+
}
|
|
17095
17215
|
} else {
|
|
17096
17216
|
// handle milliseconds separately because of floating point math errors (issue #1867)
|
|
17097
17217
|
days = this._days + Math.round(monthsToDays(this._months));
|
|
@@ -17134,6 +17254,7 @@ moment.tz.load(require('./data/packed/latest.json'));
|
|
|
17134
17254
|
var asDays = makeAs('d');
|
|
17135
17255
|
var asWeeks = makeAs('w');
|
|
17136
17256
|
var asMonths = makeAs('M');
|
|
17257
|
+
var asQuarters = makeAs('Q');
|
|
17137
17258
|
var asYears = makeAs('y');
|
|
17138
17259
|
|
|
17139
17260
|
function clone$1 () {
|
|
@@ -17325,6 +17446,7 @@ moment.tz.load(require('./data/packed/latest.json'));
|
|
|
17325
17446
|
proto$2.asDays = asDays;
|
|
17326
17447
|
proto$2.asWeeks = asWeeks;
|
|
17327
17448
|
proto$2.asMonths = asMonths;
|
|
17449
|
+
proto$2.asQuarters = asQuarters;
|
|
17328
17450
|
proto$2.asYears = asYears;
|
|
17329
17451
|
proto$2.valueOf = valueOf$1;
|
|
17330
17452
|
proto$2._bubble = bubble;
|
|
@@ -17369,7 +17491,7 @@ moment.tz.load(require('./data/packed/latest.json'));
|
|
|
17369
17491
|
// Side effect imports
|
|
17370
17492
|
|
|
17371
17493
|
|
|
17372
|
-
hooks.version = '2.
|
|
17494
|
+
hooks.version = '2.24.0';
|
|
17373
17495
|
|
|
17374
17496
|
setHookCallback(createLocal);
|
|
17375
17497
|
|
|
@@ -17410,7 +17532,7 @@ moment.tz.load(require('./data/packed/latest.json'));
|
|
|
17410
17532
|
TIME: 'HH:mm', // <input type="time" />
|
|
17411
17533
|
TIME_SECONDS: 'HH:mm:ss', // <input type="time" step="1" />
|
|
17412
17534
|
TIME_MS: 'HH:mm:ss.SSS', // <input type="time" step="0.001" />
|
|
17413
|
-
WEEK: '
|
|
17535
|
+
WEEK: 'GGGG-[W]WW', // <input type="week" />
|
|
17414
17536
|
MONTH: 'YYYY-MM' // <input type="month" />
|
|
17415
17537
|
};
|
|
17416
17538
|
|