Commit f212ef0a authored by mdsecurity's avatar mdsecurity
Browse files

fixing isOpen()

parent 714923bb
...@@ -2,53 +2,58 @@ import { Day } from './day'; ...@@ -2,53 +2,58 @@ import { Day } from './day';
import { Time } from './time'; import { Time } from './time';
export class Place { export class Place {
main_schedule_times: Day[] = []; main_schedule_times: Day[] = [];
special_schedule_times = []; special_schedule_times = [];
id: number; id: number;
last_modified: string; last_modified: string;
name: string; name: string;
category: number; category: number;
location: string; location: string;
constructor(main_schedule_times: Day[], special_schedule_times, id: number, last_modified: string, constructor(main_schedule_times: Day[], special_schedule_times, id: number, last_modified: string,
name: string, category: number, location: string) { name: string, category: number, location: string) {
this.main_schedule_times = main_schedule_times; this.main_schedule_times = main_schedule_times;
this.special_schedule_times = special_schedule_times; this.special_schedule_times = special_schedule_times;
this.id = id; this.id = id;
this.last_modified = last_modified; this.last_modified = last_modified;
this.name = name; this.name = name;
this.category = category; this.category = category;
this.location = location; this.location = location;
} }
// This method does NOT work with Special schedules // This method does NOT work with Special schedules
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 dayOfWeek = currTime.getDay() - 1;
for (let i = 0; i < this.main_schedule_times.length; i++) { for (let i = 0; i < this.main_schedule_times.length; i++) {
const day = this.main_schedule_times[i]; const day = this.main_schedule_times[i];
if (day.start_day === dayOfWeek || day.end_day === dayOfWeek + 1) { if (day.start_day === dayOfWeek && day.end_day === dayOfWeek) {
if (day.end_time.inSeconds() > inSeconds) { if (day.end_time.inSeconds() > inSeconds) {
return true; return true;
} }
} }
} if (day.end_day === dayOfWeek) {
return false; if (day.end_time.inSeconds() > inSeconds) {
} return true;
openFor() { }
const currTime = new Date(); }
// const today = currTime.getDay() - 1; }
// const openDays: Day[] = this.onDay(today); return false;
// const inSeconds = currTime.getHours() * 60 * 60 + currTime.getMinutes() * 60 + currTime.getSeconds(); }
openFor() {
const currTime = new Date();
// const today = currTime.getDay() - 1;
// const openDays: Day[] = this.onDay(today);
// const inSeconds = currTime.getHours() * 60 * 60 + currTime.getMinutes() * 60 + currTime.getSeconds();
// let sumSeconds = 0; // let sumSeconds = 0;
// for (let i = 0; i < openDays.length; i++) { // for (let i = 0; i < openDays.length; i++) {
// let day = openDays[i]; // let day = openDays[i];
// sumSeconds += day.end_time.inSeconds() - day.end_time.inSeconds(); // sumSeconds += day.end_time.inSeconds() - day.end_time.inSeconds();
// } // }
} }
} }
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
"import-spacing": true, "import-spacing": true,
"indent": [ "indent": [
true, true,
"spaces" "tabs"
], ],
"interface-over-type-literal": true, "interface-over-type-literal": true,
"label-position": true, "label-position": true,
......
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