@discomedia/utils 1.0.16 → 1.0.17

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.
@@ -13739,16 +13739,24 @@ class MarketTimeCalculator {
13739
13739
  /**
13740
13740
  * Get the last full trading date
13741
13741
  */
13742
- getLastFullTradingDate(currentDate = new Date()) {
13742
+ getLastFullTradingDate(currentDate = new Date(), extendedHours = true) {
13743
13743
  const nowET = toZonedTime(currentDate, this.timezone);
13744
- // If today is a market day and we're after extended hours close, return today
13745
13744
  if (this.calendar.isMarketDay(nowET)) {
13746
13745
  const timeInMinutes = nowET.getHours() * 60 + nowET.getMinutes();
13747
- let extendedEndMinutes = MARKET_CONFIG.TIMES.EXTENDED_END.hour * 60 + MARKET_CONFIG.TIMES.EXTENDED_END.minute;
13748
- if (this.calendar.isEarlyCloseDay(nowET)) {
13749
- extendedEndMinutes = MARKET_CONFIG.TIMES.EARLY_EXTENDED_END.hour * 60 + MARKET_CONFIG.TIMES.EARLY_EXTENDED_END.minute;
13746
+ let endMinutes;
13747
+ if (extendedHours) {
13748
+ endMinutes = MARKET_CONFIG.TIMES.EXTENDED_END.hour * 60 + MARKET_CONFIG.TIMES.EXTENDED_END.minute;
13749
+ if (this.calendar.isEarlyCloseDay(nowET)) {
13750
+ endMinutes = MARKET_CONFIG.TIMES.EARLY_EXTENDED_END.hour * 60 + MARKET_CONFIG.TIMES.EARLY_EXTENDED_END.minute;
13751
+ }
13752
+ }
13753
+ else {
13754
+ endMinutes = MARKET_CONFIG.TIMES.MARKET_CLOSE.hour * 60 + MARKET_CONFIG.TIMES.MARKET_CLOSE.minute;
13755
+ if (this.calendar.isEarlyCloseDay(nowET)) {
13756
+ endMinutes = MARKET_CONFIG.TIMES.EARLY_CLOSE.hour * 60 + MARKET_CONFIG.TIMES.EARLY_CLOSE.minute;
13757
+ }
13750
13758
  }
13751
- if (timeInMinutes >= extendedEndMinutes) {
13759
+ if (timeInMinutes >= endMinutes) {
13752
13760
  return fromZonedTime(set(nowET, { hours: 0, minutes: 0, seconds: 0, milliseconds: 0 }), this.timezone);
13753
13761
  }
13754
13762
  }