Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
whats-open-web
Commits
4c76825f
Commit
4c76825f
authored
Feb 13, 2017
by
mdsecurity
Browse files
finished openFor and touched up isOpen
parent
f212ef0a
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/app/context-bar/context-bar.component.ts
View file @
4c76825f
...
...
@@ -21,7 +21,9 @@ export class ContextBarComponent implements OnInit {
}
tempf
=
function
(){
for
(
let
i
=
0
;
i
<
this
.
data
.
length
;
i
++
){
console
.
log
(
this
.
data
[
i
].
name
+
'
OPEN:
'
+
this
.
data
[
i
].
isOpen
())
if
(
this
.
data
[
i
].
isOpen
()){
console
.
log
(
this
.
data
[
i
].
name
+
'
OPEN:
'
+
this
.
data
[
i
].
openFor
())
}
}
}
...
...
src/app/place.ts
View file @
4c76825f
...
...
@@ -28,32 +28,53 @@ export class Place {
for
(
let
i
=
0
;
i
<
this
.
main_schedule_times
.
length
;
i
++
)
{
const
day
=
this
.
main_schedule_times
[
i
];
if
(
day
.
start_day
===
dayOfWeek
&&
day
.
end_day
===
dayOfWeek
)
{
if
(
day
.
end_time
.
inSeconds
()
>
inSeconds
)
{
// change the order of if statements at some point
if
(
day
.
start_day
!==
day
.
end_day
)
{
if
(
day
.
end_day
===
dayOfWeek
)
{
if
(
day
.
end_time
.
inSeconds
()
>
inSeconds
)
{
return
true
;
}
}
else
if
(
day
.
start_day
===
dayOfWeek
)
{
return
true
;
}
}
if
(
day
.
end_day
===
dayOfWeek
)
{
if
(
day
.
end_time
.
inSeconds
()
>
inSeconds
)
{
return
true
;
}
else
{
if
(
day
.
start_day
===
dayOfWeek
)
{
if
(
day
.
end_time
.
inSeconds
()
>
inSeconds
)
{
return
true
;
}
}
}
}
return
false
;
}
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;
// for (let i = 0; i < openDays.length; i++) {
// let day = openDays[i];
// sumSeconds += day.end_time.inSeconds() - day.end_time.inSeconds();
// }
const
today
=
currTime
.
getDay
()
-
1
;
const
inSeconds
=
currTime
.
getHours
()
*
60
*
60
+
currTime
.
getMinutes
()
*
60
+
currTime
.
getSeconds
();
const
dayOfWeek
=
currTime
.
getDay
()
-
1
;
let
timeTilClose
=
new
Time
();
let
sumSeconds
=
0
;
// clean up if statements later
if
(
this
.
isOpen
())
{
for
(
let
i
=
0
;
i
<
this
.
main_schedule_times
.
length
;
i
++
)
{
const
day
=
this
.
main_schedule_times
[
i
];
if
(
day
.
end_day
!==
day
.
start_day
)
{
if
(
dayOfWeek
===
day
.
end_day
)
{
sumSeconds
=
day
.
end_time
.
inSeconds
()
-
inSeconds
-
86400
;
}
else
if
(
dayOfWeek
===
day
.
start_day
)
{
sumSeconds
=
day
.
end_time
.
inSeconds
()
+
86400
-
inSeconds
;
}
}
else
{
sumSeconds
=
day
.
end_time
.
inSeconds
()
-
inSeconds
;
}
timeTilClose
.
fromSeconds
(
sumSeconds
)
return
timeTilClose
.
toString
();
}
}
else
{
return
'
closed
'
;
}
}
}
src/app/time.ts
View file @
4c76825f
export
class
Time
{
hour
:
number
;
minute
:
number
;
second
:
number
;
hour
:
number
;
minute
:
number
;
second
:
number
;
constructor
(
hour
:
number
,
minute
:
number
,
second
:
number
)
{
this
.
hour
=
hour
||
0
;
this
.
minute
=
minute
||
0
;
this
.
second
=
second
||
0
;
}
constructor
(
hour
?:
number
,
minute
?:
number
,
second
?:
number
)
{
this
.
hour
=
hour
||
0
;
this
.
minute
=
minute
||
0
;
this
.
second
=
second
||
0
;
}
isGreater
(
time
:
Time
):
boolean
{
if
(
this
.
hour
>
time
.
hour
)
{
return
true
;
}
else
{
if
(
this
.
minute
>
time
.
minute
)
{
return
true
;
}
else
{
if
(
this
.
second
>
time
.
second
)
{
return
true
;
}
}
}
return
false
;
}
inSeconds
(){
return
this
.
hour
*
60
*
60
+
this
.
minute
*
60
+
this
.
second
;
}
isGreater
(
time
:
Time
):
boolean
{
if
(
this
.
hour
>
time
.
hour
)
{
return
true
;
}
else
{
if
(
this
.
minute
>
time
.
minute
)
{
return
true
;
}
else
{
if
(
this
.
second
>
time
.
second
)
{
return
true
;
}
}
}
return
false
;
}
inSeconds
()
{
return
this
.
hour
*
60
*
60
+
this
.
minute
*
60
+
this
.
second
;
}
fromSeconds
(
second
:
number
):
Time
{
this
.
hour
=
Math
.
trunc
(
second
/
3600
);
second
-=
this
.
hour
*
3600
;
this
.
minute
=
Math
.
trunc
(
second
/
60
);
second
-=
this
.
minute
*
60
;
this
.
second
=
second
;
return
this
;
}
toString
():
string
{
return
(
this
.
hour
+
"
:
"
+
this
.
minute
+
"
:
"
+
this
.
second
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment