Calculate next closing only from events and not weekends

This commit is contained in:
2018-03-20 08:51:18 +05:30
parent 90da533de7
commit 9886ea4fbe
2 changed files with 6 additions and 5 deletions
@@ -23,7 +23,8 @@ export class NextOpenCloseMini extends React.Component<NextOpenCloseMiniProps, {
this.openOrClose = props.openOrClose;
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() {
+4 -4
View File
@@ -81,7 +81,7 @@ export class Utils {
}
}
static findNextOpenOrCloseFromDate(
static findNextOpenOrEventCloseFromDate(
xDay: moment.Moment,
allHolidays: HolidayList,
openOrClose: OpenOrClose): moment.Moment | undefined {
@@ -89,13 +89,13 @@ export class Utils {
let currentDay = xDay.clone().add(1, "day");
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;
}
if ((openOrClose === OpenOrClose.Close) && !holidayAnswerOnCurrentDay.open) {
if ((openOrClose === OpenOrClose.Close) && (holidayOnCurrentDay !== undefined)) {
return currentDay;
}