@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.
- package/dist/index-frontend.cjs +14 -6
- package/dist/index-frontend.cjs.map +1 -1
- package/dist/index-frontend.mjs +14 -6
- package/dist/index-frontend.mjs.map +1 -1
- package/dist/index.cjs +31 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +31 -10
- package/dist/index.mjs.map +1 -1
- package/dist/package.json +1 -1
- package/dist/test.js +413 -7390
- package/dist/test.js.map +1 -1
- package/dist/types/market-time.d.ts +1 -1
- package/dist/types/market-time.d.ts.map +1 -1
- package/dist/types-frontend/market-time.d.ts +1 -1
- package/dist/types-frontend/market-time.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index-frontend.mjs
CHANGED
|
@@ -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
|
|
13748
|
-
if (
|
|
13749
|
-
|
|
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 >=
|
|
13759
|
+
if (timeInMinutes >= endMinutes) {
|
|
13752
13760
|
return fromZonedTime(set(nowET, { hours: 0, minutes: 0, seconds: 0, milliseconds: 0 }), this.timezone);
|
|
13753
13761
|
}
|
|
13754
13762
|
}
|