Commit 7e154b7c authored by mdsecurity's avatar mdsecurity
Browse files

fixed issue where sunday was reperesented as -1 instead of 6

parent 437da7ca
...@@ -24,7 +24,8 @@ export class PlaceCardComponent implements OnInit { ...@@ -24,7 +24,8 @@ export class PlaceCardComponent implements OnInit {
} }
openInContext() { openInContext() {
this.dataProvider.setContext(this.place); this.dataProvider.setContext(this.place);
console.log(this.place.openFor().hour+ " "+ this.place.openFor().minute+ " "+ this.place.openFor().second) // console.log(this.place.openFor().hour+ " "+ this.place.openFor().minute+ " "+ this.place.openFor().second)
console.log(this.place);
} }
openDialog() { openDialog() {
let dialogRef = this.dialog.open(FeedbackDialogComponent); let dialogRef = this.dialog.open(FeedbackDialogComponent);
......
...@@ -25,12 +25,13 @@ export class Place { ...@@ -25,12 +25,13 @@ export class Place {
isOpen(): boolean { isOpen(): boolean {
const currTime = new Date(); const currTime = new Date();
const inSeconds = currTime.getHours() * 60 * 60 + currTime.getMinutes() * 60 + currTime.getSeconds(); const inSeconds = currTime.getHours() * 60 * 60 + currTime.getMinutes() * 60 + currTime.getSeconds();
const dayOfWeek = currTime.getDay() - 1; const dayOfWeekShift = [6, 5, 4, 3, 2, 1, 0];
const dayOfWeek = dayOfWeekShift[currTime.getDay()];
const useSpecialSchedule = this.useSpecial(); const useSpecialSchedule = this.useSpecial();
let schedule; let schedule;
if(useSpecialSchedule === -1){ if (useSpecialSchedule === -1) {
schedule = this.main_schedule_times; schedule = this.main_schedule_times;
}else{ } else {
schedule = this.special_schedules[useSpecialSchedule].openTimes; schedule = this.special_schedules[useSpecialSchedule].openTimes;
} }
for (let i = 0; i < schedule.length; i++) { for (let i = 0; i < schedule.length; i++) {
...@@ -59,20 +60,21 @@ export class Place { ...@@ -59,20 +60,21 @@ export class Place {
const currTime = new Date(); const currTime = new Date();
const today = currTime.getDay() - 1; const today = currTime.getDay() - 1;
const inSeconds = currTime.getHours() * 60 * 60 + currTime.getMinutes() * 60 + currTime.getSeconds(); const inSeconds = currTime.getHours() * 60 * 60 + currTime.getMinutes() * 60 + currTime.getSeconds();
const dayOfWeek = currTime.getDay() - 1; const dayOfWeekShift = [6, 5, 4, 3, 2, 1, 0];
const dayOfWeek = dayOfWeekShift[currTime.getDay()];
const useSpecialSchedule = this.useSpecial(); const useSpecialSchedule = this.useSpecial();
let timeTilClose = new Time(); let timeTilClose = new Time();
let sumSeconds = 0; let sumSeconds = 0;
let schedule; let schedule;
if(useSpecialSchedule === -1){ if (useSpecialSchedule === -1) {
schedule = this.main_schedule_times; schedule = this.main_schedule_times;
}else{ } else {
schedule = this.special_schedules[useSpecialSchedule].openTimes; schedule = this.special_schedules[useSpecialSchedule].openTimes;
} }
// clean up if statements later // clean up if statements later
if (this.isOpen()) { // if (this.isOpen()) {
for (let i = 0; i < schedule.length; i++) { for (let i = 0; i < schedule.length; i++) {
const day = schedule[i]; const day = schedule[i];
if (day.end_day !== day.start_day) { if (day.end_day !== day.start_day) {
...@@ -87,9 +89,9 @@ export class Place { ...@@ -87,9 +89,9 @@ export class Place {
return timeTilClose.fromSeconds(sumSeconds); return timeTilClose.fromSeconds(sumSeconds);
} }
} else { // } else {
return timeTilClose; return timeTilClose;
} // }
} }
useSpecial(): number { useSpecial(): number {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment