mirror of
https://github.com/bendtherules/is-nifty-open.git
synced 2026-08-18 13:52:20 +00:00
Calculate next closing only from events and not weekends
This commit is contained in:
@@ -23,7 +23,8 @@ export class NextOpenCloseMini extends React.Component<NextOpenCloseMiniProps, {
|
|||||||
this.openOrClose = props.openOrClose;
|
this.openOrClose = props.openOrClose;
|
||||||
this.allHolidays = props.allHolidays;
|
this.allHolidays = props.allHolidays;
|
||||||
|
|
||||||
this.nextOpenOrCloseDate = Utils.findNextOpenOrCloseFromDate(this.xDay, this.allHolidays, this.openOrClose);
|
this.nextOpenOrCloseDate = Utils.findNextOpenOrEventCloseFromDate(
|
||||||
|
this.xDay, this.allHolidays, this.openOrClose);
|
||||||
}
|
}
|
||||||
|
|
||||||
getOpeningClosingString() {
|
getOpeningClosingString() {
|
||||||
|
|||||||
+4
-4
@@ -81,7 +81,7 @@ export class Utils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static findNextOpenOrCloseFromDate(
|
static findNextOpenOrEventCloseFromDate(
|
||||||
xDay: moment.Moment,
|
xDay: moment.Moment,
|
||||||
allHolidays: HolidayList,
|
allHolidays: HolidayList,
|
||||||
openOrClose: OpenOrClose): moment.Moment | undefined {
|
openOrClose: OpenOrClose): moment.Moment | undefined {
|
||||||
@@ -89,13 +89,13 @@ export class Utils {
|
|||||||
let currentDay = xDay.clone().add(1, "day");
|
let currentDay = xDay.clone().add(1, "day");
|
||||||
|
|
||||||
while (this.checkSameYearInSameTZ(currentDay, xDay)) {
|
while (this.checkSameYearInSameTZ(currentDay, xDay)) {
|
||||||
var holidayAnswerOnCurrentDay = this.getHolidayAnswerOnDate(currentDay, allHolidays);
|
var holidayOnCurrentDay = this.getEventHolidayOnDate(currentDay, allHolidays);
|
||||||
|
|
||||||
if ((openOrClose === OpenOrClose.Open) && holidayAnswerOnCurrentDay.open) {
|
if ((openOrClose === OpenOrClose.Open) && (holidayOnCurrentDay === undefined)) {
|
||||||
return currentDay;
|
return currentDay;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((openOrClose === OpenOrClose.Close) && !holidayAnswerOnCurrentDay.open) {
|
if ((openOrClose === OpenOrClose.Close) && (holidayOnCurrentDay !== undefined)) {
|
||||||
return currentDay;
|
return currentDay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user