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