@barchart/portfolio-api-common 1.2.141 → 1.2.142

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.
@@ -755,6 +755,14 @@ module.exports = (() => {
755
755
 
756
756
  calculateUnrealizedPercent(group);
757
757
 
758
+ actual.periodPercent = calculatePeriodPercent(actual.summaryTotalCurrent, actual.periodDivisorCurrent);
759
+ actual.periodPercentPrevious = calculatePeriodPercent(actual.summaryTotalPrevious, actual.periodDivisorPrevious);
760
+ actual.periodPercentPrevious2 = calculatePeriodPercent(actual.summaryTotalPrevious2, actual.periodDivisorPrevious2);
761
+
762
+ format.periodPercent = formatPercent(actual.periodPercent, 2);
763
+ format.periodPercentPrevious = formatPercent(actual.periodPercentPrevious, 2);
764
+ format.periodPercentPrevious2 = formatPercent(actual.periodPercentPrevious2, 2);
765
+
758
766
  const groupItems = group._items;
759
767
 
760
768
  if (group.single && groupItems.length === 1) {
@@ -762,28 +770,20 @@ module.exports = (() => {
762
770
 
763
771
  actual.quantity = item.data.quantity;
764
772
  actual.quantityPrevious = item.data.quantityPrevious;
765
-
766
- actual.basisPrice = item.data.basisPrice;
767
-
768
- actual.periodPrice = item.data.periodPrice;
769
- actual.periodPricePrevious = item.data.periodPricePrevious;
770
773
 
771
774
  format.quantity = formatDecimal(actual.quantity, 2);
772
775
  format.quantityPrevious = formatDecimal(actual.quantityPrevious, 2);
773
776
 
777
+ actual.basisPrice = item.data.basisPrice;
778
+
774
779
  format.basisPrice = formatCurrency(actual.basisPrice, currency);
775
780
 
781
+ actual.periodPrice = item.data.periodPrice;
782
+ actual.periodPricePrevious = item.data.periodPricePrevious;
783
+
776
784
  format.periodPrice = formatCurrency(actual.periodPrice, currency);
777
785
  format.periodPricePrevious = formatCurrency(actual.periodPricePrevious, currency);
778
786
 
779
- actual.periodPercent = calculatePeriodPercent(actual.summaryTotalCurrent, actual.periodDivisorCurrent);
780
- actual.periodPercentPrevious = calculatePeriodPercent(actual.summaryTotalPrevious, actual.periodDivisorPrevious);
781
- actual.periodPercentPrevious2 = calculatePeriodPercent(actual.summaryTotalPrevious2, actual.periodDivisorPrevious2);
782
-
783
- format.periodPercent = formatPercent(actual.periodPercent, 2);
784
- format.periodPercentPrevious = formatPercent(actual.periodPercentPrevious, 2);
785
- format.periodPercentPrevious2 = formatPercent(actual.periodPercentPrevious2, 2);
786
-
787
787
  format.invalid = definition.type === PositionLevelType.POSITION && item.invalid;
788
788
  format.locked = definition.type === PositionLevelType.POSITION && item.data.locked;
789
789
  }
@@ -908,11 +908,11 @@ module.exports = (() => {
908
908
 
909
909
  calculateUnrealizedPercent(group);
910
910
 
911
+ actual.periodPercent = calculatePeriodPercent(actual.summaryTotalCurrent, actual.periodDivisorCurrent);
912
+ format.periodPercent = formatPercent(actual.periodPercent, 2);
913
+
911
914
  if (group.single && item) {
912
915
  actual.periodUnrealized = item.data.periodUnrealized;
913
-
914
- actual.periodPercent = calculatePeriodPercent(actual.summaryTotalCurrent, actual.periodDivisorCurrent);
915
- format.periodPercent = formatPercent(actual.periodPercent, 2);
916
916
  }
917
917
  }
918
918
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.2.141",
3
+ "version": "1.2.142",
4
4
  "description": "Common classes used by the Portfolio system",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",
@@ -3277,6 +3277,14 @@ module.exports = (() => {
3277
3277
 
3278
3278
  calculateUnrealizedPercent(group);
3279
3279
 
3280
+ actual.periodPercent = calculatePeriodPercent(actual.summaryTotalCurrent, actual.periodDivisorCurrent);
3281
+ actual.periodPercentPrevious = calculatePeriodPercent(actual.summaryTotalPrevious, actual.periodDivisorPrevious);
3282
+ actual.periodPercentPrevious2 = calculatePeriodPercent(actual.summaryTotalPrevious2, actual.periodDivisorPrevious2);
3283
+
3284
+ format.periodPercent = formatPercent(actual.periodPercent, 2);
3285
+ format.periodPercentPrevious = formatPercent(actual.periodPercentPrevious, 2);
3286
+ format.periodPercentPrevious2 = formatPercent(actual.periodPercentPrevious2, 2);
3287
+
3280
3288
  const groupItems = group._items;
3281
3289
 
3282
3290
  if (group.single && groupItems.length === 1) {
@@ -3284,28 +3292,20 @@ module.exports = (() => {
3284
3292
 
3285
3293
  actual.quantity = item.data.quantity;
3286
3294
  actual.quantityPrevious = item.data.quantityPrevious;
3287
-
3288
- actual.basisPrice = item.data.basisPrice;
3289
-
3290
- actual.periodPrice = item.data.periodPrice;
3291
- actual.periodPricePrevious = item.data.periodPricePrevious;
3292
3295
 
3293
3296
  format.quantity = formatDecimal(actual.quantity, 2);
3294
3297
  format.quantityPrevious = formatDecimal(actual.quantityPrevious, 2);
3295
3298
 
3299
+ actual.basisPrice = item.data.basisPrice;
3300
+
3296
3301
  format.basisPrice = formatCurrency(actual.basisPrice, currency);
3297
3302
 
3303
+ actual.periodPrice = item.data.periodPrice;
3304
+ actual.periodPricePrevious = item.data.periodPricePrevious;
3305
+
3298
3306
  format.periodPrice = formatCurrency(actual.periodPrice, currency);
3299
3307
  format.periodPricePrevious = formatCurrency(actual.periodPricePrevious, currency);
3300
3308
 
3301
- actual.periodPercent = calculatePeriodPercent(actual.summaryTotalCurrent, actual.periodDivisorCurrent);
3302
- actual.periodPercentPrevious = calculatePeriodPercent(actual.summaryTotalPrevious, actual.periodDivisorPrevious);
3303
- actual.periodPercentPrevious2 = calculatePeriodPercent(actual.summaryTotalPrevious2, actual.periodDivisorPrevious2);
3304
-
3305
- format.periodPercent = formatPercent(actual.periodPercent, 2);
3306
- format.periodPercentPrevious = formatPercent(actual.periodPercentPrevious, 2);
3307
- format.periodPercentPrevious2 = formatPercent(actual.periodPercentPrevious2, 2);
3308
-
3309
3309
  format.invalid = definition.type === PositionLevelType.POSITION && item.invalid;
3310
3310
  format.locked = definition.type === PositionLevelType.POSITION && item.data.locked;
3311
3311
  }
@@ -3430,11 +3430,11 @@ module.exports = (() => {
3430
3430
 
3431
3431
  calculateUnrealizedPercent(group);
3432
3432
 
3433
+ actual.periodPercent = calculatePeriodPercent(actual.summaryTotalCurrent, actual.periodDivisorCurrent);
3434
+ format.periodPercent = formatPercent(actual.periodPercent, 2);
3435
+
3433
3436
  if (group.single && item) {
3434
3437
  actual.periodUnrealized = item.data.periodUnrealized;
3435
-
3436
- actual.periodPercent = calculatePeriodPercent(actual.summaryTotalCurrent, actual.periodDivisorCurrent);
3437
- format.periodPercent = formatPercent(actual.periodPercent, 2);
3438
3438
  }
3439
3439
  }
3440
3440
 
@@ -13997,22 +13997,36 @@ moment.tz.load(require('./data/packed/latest.json'));
13997
13997
  function createDate (y, m, d, h, M, s, ms) {
13998
13998
  // can't just apply() to create a date:
13999
13999
  // https://stackoverflow.com/q/181348
14000
- var date = new Date(y, m, d, h, M, s, ms);
14001
-
14000
+ var date;
14002
14001
  // the date constructor remaps years 0-99 to 1900-1999
14003
- if (y < 100 && y >= 0 && isFinite(date.getFullYear())) {
14004
- date.setFullYear(y);
14002
+ if (y < 100 && y >= 0) {
14003
+ // preserve leap years using a full 400 year cycle, then reset
14004
+ date = new Date(y + 400, m, d, h, M, s, ms);
14005
+ if (isFinite(date.getFullYear())) {
14006
+ date.setFullYear(y);
14007
+ }
14008
+ } else {
14009
+ date = new Date(y, m, d, h, M, s, ms);
14005
14010
  }
14011
+
14006
14012
  return date;
14007
14013
  }
14008
14014
 
14009
14015
  function createUTCDate (y) {
14010
- var date = new Date(Date.UTC.apply(null, arguments));
14011
-
14016
+ var date;
14012
14017
  // the Date.UTC function remaps years 0-99 to 1900-1999
14013
- if (y < 100 && y >= 0 && isFinite(date.getUTCFullYear())) {
14014
- date.setUTCFullYear(y);
14018
+ if (y < 100 && y >= 0) {
14019
+ var args = Array.prototype.slice.call(arguments);
14020
+ // preserve leap years using a full 400 year cycle, then reset
14021
+ args[0] = y + 400;
14022
+ date = new Date(Date.UTC.apply(null, args));
14023
+ if (isFinite(date.getUTCFullYear())) {
14024
+ date.setUTCFullYear(y);
14025
+ }
14026
+ } else {
14027
+ date = new Date(Date.UTC.apply(null, arguments));
14015
14028
  }
14029
+
14016
14030
  return date;
14017
14031
  }
14018
14032
 
@@ -14114,7 +14128,7 @@ moment.tz.load(require('./data/packed/latest.json'));
14114
14128
 
14115
14129
  var defaultLocaleWeek = {
14116
14130
  dow : 0, // Sunday is the first day of the week.
14117
- doy : 6 // The week that contains Jan 1st is the first week of the year.
14131
+ doy : 6 // The week that contains Jan 6th is the first week of the year.
14118
14132
  };
14119
14133
 
14120
14134
  function localeFirstDayOfWeek () {
@@ -14223,25 +14237,28 @@ moment.tz.load(require('./data/packed/latest.json'));
14223
14237
  }
14224
14238
 
14225
14239
  // LOCALES
14240
+ function shiftWeekdays (ws, n) {
14241
+ return ws.slice(n, 7).concat(ws.slice(0, n));
14242
+ }
14226
14243
 
14227
14244
  var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_');
14228
14245
  function localeWeekdays (m, format) {
14229
- if (!m) {
14230
- return isArray(this._weekdays) ? this._weekdays :
14231
- this._weekdays['standalone'];
14232
- }
14233
- return isArray(this._weekdays) ? this._weekdays[m.day()] :
14234
- this._weekdays[this._weekdays.isFormat.test(format) ? 'format' : 'standalone'][m.day()];
14246
+ var weekdays = isArray(this._weekdays) ? this._weekdays :
14247
+ this._weekdays[(m && m !== true && this._weekdays.isFormat.test(format)) ? 'format' : 'standalone'];
14248
+ return (m === true) ? shiftWeekdays(weekdays, this._week.dow)
14249
+ : (m) ? weekdays[m.day()] : weekdays;
14235
14250
  }
14236
14251
 
14237
14252
  var defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_');
14238
14253
  function localeWeekdaysShort (m) {
14239
- return (m) ? this._weekdaysShort[m.day()] : this._weekdaysShort;
14254
+ return (m === true) ? shiftWeekdays(this._weekdaysShort, this._week.dow)
14255
+ : (m) ? this._weekdaysShort[m.day()] : this._weekdaysShort;
14240
14256
  }
14241
14257
 
14242
14258
  var defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_');
14243
14259
  function localeWeekdaysMin (m) {
14244
- return (m) ? this._weekdaysMin[m.day()] : this._weekdaysMin;
14260
+ return (m === true) ? shiftWeekdays(this._weekdaysMin, this._week.dow)
14261
+ : (m) ? this._weekdaysMin[m.day()] : this._weekdaysMin;
14245
14262
  }
14246
14263
 
14247
14264
  function handleStrictParse$1(weekdayName, format, strict) {
@@ -14990,13 +15007,13 @@ moment.tz.load(require('./data/packed/latest.json'));
14990
15007
  weekdayOverflow = true;
14991
15008
  }
14992
15009
  } else if (w.e != null) {
14993
- // local weekday -- counting starts from begining of week
15010
+ // local weekday -- counting starts from beginning of week
14994
15011
  weekday = w.e + dow;
14995
15012
  if (w.e < 0 || w.e > 6) {
14996
15013
  weekdayOverflow = true;
14997
15014
  }
14998
15015
  } else {
14999
- // default to begining of week
15016
+ // default to beginning of week
15000
15017
  weekday = dow;
15001
15018
  }
15002
15019
  }
@@ -15590,7 +15607,7 @@ moment.tz.load(require('./data/packed/latest.json'));
15590
15607
  years = normalizedInput.year || 0,
15591
15608
  quarters = normalizedInput.quarter || 0,
15592
15609
  months = normalizedInput.month || 0,
15593
- weeks = normalizedInput.week || 0,
15610
+ weeks = normalizedInput.week || normalizedInput.isoWeek || 0,
15594
15611
  days = normalizedInput.day || 0,
15595
15612
  hours = normalizedInput.hour || 0,
15596
15613
  minutes = normalizedInput.minute || 0,
@@ -15894,7 +15911,7 @@ moment.tz.load(require('./data/packed/latest.json'));
15894
15911
  ms : toInt(absRound(match[MILLISECOND] * 1000)) * sign // the millisecond decimal point is included in the match
15895
15912
  };
15896
15913
  } else if (!!(match = isoRegex.exec(input))) {
15897
- sign = (match[1] === '-') ? -1 : (match[1] === '+') ? 1 : 1;
15914
+ sign = (match[1] === '-') ? -1 : 1;
15898
15915
  duration = {
15899
15916
  y : parseIso(match[2], sign),
15900
15917
  M : parseIso(match[3], sign),
@@ -15936,7 +15953,7 @@ moment.tz.load(require('./data/packed/latest.json'));
15936
15953
  }
15937
15954
 
15938
15955
  function positiveMomentsDifference(base, other) {
15939
- var res = {milliseconds: 0, months: 0};
15956
+ var res = {};
15940
15957
 
15941
15958
  res.months = other.month() - base.month() +
15942
15959
  (other.year() - base.year()) * 12;
@@ -16045,7 +16062,7 @@ moment.tz.load(require('./data/packed/latest.json'));
16045
16062
  if (!(this.isValid() && localInput.isValid())) {
16046
16063
  return false;
16047
16064
  }
16048
- units = normalizeUnits(!isUndefined(units) ? units : 'millisecond');
16065
+ units = normalizeUnits(units) || 'millisecond';
16049
16066
  if (units === 'millisecond') {
16050
16067
  return this.valueOf() > localInput.valueOf();
16051
16068
  } else {
@@ -16058,7 +16075,7 @@ moment.tz.load(require('./data/packed/latest.json'));
16058
16075
  if (!(this.isValid() && localInput.isValid())) {
16059
16076
  return false;
16060
16077
  }
16061
- units = normalizeUnits(!isUndefined(units) ? units : 'millisecond');
16078
+ units = normalizeUnits(units) || 'millisecond';
16062
16079
  if (units === 'millisecond') {
16063
16080
  return this.valueOf() < localInput.valueOf();
16064
16081
  } else {
@@ -16067,9 +16084,14 @@ moment.tz.load(require('./data/packed/latest.json'));
16067
16084
  }
16068
16085
 
16069
16086
  function isBetween (from, to, units, inclusivity) {
16087
+ var localFrom = isMoment(from) ? from : createLocal(from),
16088
+ localTo = isMoment(to) ? to : createLocal(to);
16089
+ if (!(this.isValid() && localFrom.isValid() && localTo.isValid())) {
16090
+ return false;
16091
+ }
16070
16092
  inclusivity = inclusivity || '()';
16071
- return (inclusivity[0] === '(' ? this.isAfter(from, units) : !this.isBefore(from, units)) &&
16072
- (inclusivity[1] === ')' ? this.isBefore(to, units) : !this.isAfter(to, units));
16093
+ return (inclusivity[0] === '(' ? this.isAfter(localFrom, units) : !this.isBefore(localFrom, units)) &&
16094
+ (inclusivity[1] === ')' ? this.isBefore(localTo, units) : !this.isAfter(localTo, units));
16073
16095
  }
16074
16096
 
16075
16097
  function isSame (input, units) {
@@ -16078,7 +16100,7 @@ moment.tz.load(require('./data/packed/latest.json'));
16078
16100
  if (!(this.isValid() && localInput.isValid())) {
16079
16101
  return false;
16080
16102
  }
16081
- units = normalizeUnits(units || 'millisecond');
16103
+ units = normalizeUnits(units) || 'millisecond';
16082
16104
  if (units === 'millisecond') {
16083
16105
  return this.valueOf() === localInput.valueOf();
16084
16106
  } else {
@@ -16088,11 +16110,11 @@ moment.tz.load(require('./data/packed/latest.json'));
16088
16110
  }
16089
16111
 
16090
16112
  function isSameOrAfter (input, units) {
16091
- return this.isSame(input, units) || this.isAfter(input,units);
16113
+ return this.isSame(input, units) || this.isAfter(input, units);
16092
16114
  }
16093
16115
 
16094
16116
  function isSameOrBefore (input, units) {
16095
- return this.isSame(input, units) || this.isBefore(input,units);
16117
+ return this.isSame(input, units) || this.isBefore(input, units);
16096
16118
  }
16097
16119
 
16098
16120
  function diff (input, units, asFloat) {
@@ -16269,62 +16291,130 @@ moment.tz.load(require('./data/packed/latest.json'));
16269
16291
  return this._locale;
16270
16292
  }
16271
16293
 
16294
+ var MS_PER_SECOND = 1000;
16295
+ var MS_PER_MINUTE = 60 * MS_PER_SECOND;
16296
+ var MS_PER_HOUR = 60 * MS_PER_MINUTE;
16297
+ var MS_PER_400_YEARS = (365 * 400 + 97) * 24 * MS_PER_HOUR;
16298
+
16299
+ // actual modulo - handles negative numbers (for dates before 1970):
16300
+ function mod$1(dividend, divisor) {
16301
+ return (dividend % divisor + divisor) % divisor;
16302
+ }
16303
+
16304
+ function localStartOfDate(y, m, d) {
16305
+ // the date constructor remaps years 0-99 to 1900-1999
16306
+ if (y < 100 && y >= 0) {
16307
+ // preserve leap years using a full 400 year cycle, then reset
16308
+ return new Date(y + 400, m, d) - MS_PER_400_YEARS;
16309
+ } else {
16310
+ return new Date(y, m, d).valueOf();
16311
+ }
16312
+ }
16313
+
16314
+ function utcStartOfDate(y, m, d) {
16315
+ // Date.UTC remaps years 0-99 to 1900-1999
16316
+ if (y < 100 && y >= 0) {
16317
+ // preserve leap years using a full 400 year cycle, then reset
16318
+ return Date.UTC(y + 400, m, d) - MS_PER_400_YEARS;
16319
+ } else {
16320
+ return Date.UTC(y, m, d);
16321
+ }
16322
+ }
16323
+
16272
16324
  function startOf (units) {
16325
+ var time;
16273
16326
  units = normalizeUnits(units);
16274
- // the following switch intentionally omits break keywords
16275
- // to utilize falling through the cases.
16327
+ if (units === undefined || units === 'millisecond' || !this.isValid()) {
16328
+ return this;
16329
+ }
16330
+
16331
+ var startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
16332
+
16276
16333
  switch (units) {
16277
16334
  case 'year':
16278
- this.month(0);
16279
- /* falls through */
16335
+ time = startOfDate(this.year(), 0, 1);
16336
+ break;
16280
16337
  case 'quarter':
16338
+ time = startOfDate(this.year(), this.month() - this.month() % 3, 1);
16339
+ break;
16281
16340
  case 'month':
16282
- this.date(1);
16283
- /* falls through */
16341
+ time = startOfDate(this.year(), this.month(), 1);
16342
+ break;
16284
16343
  case 'week':
16344
+ time = startOfDate(this.year(), this.month(), this.date() - this.weekday());
16345
+ break;
16285
16346
  case 'isoWeek':
16347
+ time = startOfDate(this.year(), this.month(), this.date() - (this.isoWeekday() - 1));
16348
+ break;
16286
16349
  case 'day':
16287
16350
  case 'date':
16288
- this.hours(0);
16289
- /* falls through */
16351
+ time = startOfDate(this.year(), this.month(), this.date());
16352
+ break;
16290
16353
  case 'hour':
16291
- this.minutes(0);
16292
- /* falls through */
16354
+ time = this._d.valueOf();
16355
+ time -= mod$1(time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE), MS_PER_HOUR);
16356
+ break;
16293
16357
  case 'minute':
16294
- this.seconds(0);
16295
- /* falls through */
16358
+ time = this._d.valueOf();
16359
+ time -= mod$1(time, MS_PER_MINUTE);
16360
+ break;
16296
16361
  case 'second':
16297
- this.milliseconds(0);
16298
- }
16299
-
16300
- // weeks are a special case
16301
- if (units === 'week') {
16302
- this.weekday(0);
16303
- }
16304
- if (units === 'isoWeek') {
16305
- this.isoWeekday(1);
16306
- }
16307
-
16308
- // quarters are also special
16309
- if (units === 'quarter') {
16310
- this.month(Math.floor(this.month() / 3) * 3);
16362
+ time = this._d.valueOf();
16363
+ time -= mod$1(time, MS_PER_SECOND);
16364
+ break;
16311
16365
  }
16312
16366
 
16367
+ this._d.setTime(time);
16368
+ hooks.updateOffset(this, true);
16313
16369
  return this;
16314
16370
  }
16315
16371
 
16316
16372
  function endOf (units) {
16373
+ var time;
16317
16374
  units = normalizeUnits(units);
16318
- if (units === undefined || units === 'millisecond') {
16375
+ if (units === undefined || units === 'millisecond' || !this.isValid()) {
16319
16376
  return this;
16320
16377
  }
16321
16378
 
16322
- // 'date' is an alias for 'day', so it should be considered as such.
16323
- if (units === 'date') {
16324
- units = 'day';
16379
+ var startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
16380
+
16381
+ switch (units) {
16382
+ case 'year':
16383
+ time = startOfDate(this.year() + 1, 0, 1) - 1;
16384
+ break;
16385
+ case 'quarter':
16386
+ time = startOfDate(this.year(), this.month() - this.month() % 3 + 3, 1) - 1;
16387
+ break;
16388
+ case 'month':
16389
+ time = startOfDate(this.year(), this.month() + 1, 1) - 1;
16390
+ break;
16391
+ case 'week':
16392
+ time = startOfDate(this.year(), this.month(), this.date() - this.weekday() + 7) - 1;
16393
+ break;
16394
+ case 'isoWeek':
16395
+ time = startOfDate(this.year(), this.month(), this.date() - (this.isoWeekday() - 1) + 7) - 1;
16396
+ break;
16397
+ case 'day':
16398
+ case 'date':
16399
+ time = startOfDate(this.year(), this.month(), this.date() + 1) - 1;
16400
+ break;
16401
+ case 'hour':
16402
+ time = this._d.valueOf();
16403
+ time += MS_PER_HOUR - mod$1(time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE), MS_PER_HOUR) - 1;
16404
+ break;
16405
+ case 'minute':
16406
+ time = this._d.valueOf();
16407
+ time += MS_PER_MINUTE - mod$1(time, MS_PER_MINUTE) - 1;
16408
+ break;
16409
+ case 'second':
16410
+ time = this._d.valueOf();
16411
+ time += MS_PER_SECOND - mod$1(time, MS_PER_SECOND) - 1;
16412
+ break;
16325
16413
  }
16326
16414
 
16327
- return this.startOf(units).add(1, (units === 'isoWeek' ? 'week' : units)).subtract(1, 'ms');
16415
+ this._d.setTime(time);
16416
+ hooks.updateOffset(this, true);
16417
+ return this;
16328
16418
  }
16329
16419
 
16330
16420
  function valueOf () {
@@ -17030,10 +17120,14 @@ moment.tz.load(require('./data/packed/latest.json'));
17030
17120
 
17031
17121
  units = normalizeUnits(units);
17032
17122
 
17033
- if (units === 'month' || units === 'year') {
17034
- days = this._days + milliseconds / 864e5;
17123
+ if (units === 'month' || units === 'quarter' || units === 'year') {
17124
+ days = this._days + milliseconds / 864e5;
17035
17125
  months = this._months + daysToMonths(days);
17036
- return units === 'month' ? months : months / 12;
17126
+ switch (units) {
17127
+ case 'month': return months;
17128
+ case 'quarter': return months / 3;
17129
+ case 'year': return months / 12;
17130
+ }
17037
17131
  } else {
17038
17132
  // handle milliseconds separately because of floating point math errors (issue #1867)
17039
17133
  days = this._days + Math.round(monthsToDays(this._months));
@@ -17076,6 +17170,7 @@ moment.tz.load(require('./data/packed/latest.json'));
17076
17170
  var asDays = makeAs('d');
17077
17171
  var asWeeks = makeAs('w');
17078
17172
  var asMonths = makeAs('M');
17173
+ var asQuarters = makeAs('Q');
17079
17174
  var asYears = makeAs('y');
17080
17175
 
17081
17176
  function clone$1 () {
@@ -17267,6 +17362,7 @@ moment.tz.load(require('./data/packed/latest.json'));
17267
17362
  proto$2.asDays = asDays;
17268
17363
  proto$2.asWeeks = asWeeks;
17269
17364
  proto$2.asMonths = asMonths;
17365
+ proto$2.asQuarters = asQuarters;
17270
17366
  proto$2.asYears = asYears;
17271
17367
  proto$2.valueOf = valueOf$1;
17272
17368
  proto$2._bubble = bubble;
@@ -17311,7 +17407,7 @@ moment.tz.load(require('./data/packed/latest.json'));
17311
17407
  // Side effect imports
17312
17408
 
17313
17409
 
17314
- hooks.version = '2.22.2';
17410
+ hooks.version = '2.24.0';
17315
17411
 
17316
17412
  setHookCallback(createLocal);
17317
17413
 
@@ -17352,7 +17448,7 @@ moment.tz.load(require('./data/packed/latest.json'));
17352
17448
  TIME: 'HH:mm', // <input type="time" />
17353
17449
  TIME_SECONDS: 'HH:mm:ss', // <input type="time" step="1" />
17354
17450
  TIME_MS: 'HH:mm:ss.SSS', // <input type="time" step="0.001" />
17355
- WEEK: 'YYYY-[W]WW', // <input type="week" />
17451
+ WEEK: 'GGGG-[W]WW', // <input type="week" />
17356
17452
  MONTH: 'YYYY-MM' // <input type="month" />
17357
17453
  };
17358
17454