Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
opening-hours
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
regionalkauf
opening-hours
Commits
934b98ad
Commit
934b98ad
authored
Jun 23, 2014
by
Johannes Bill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
initial
parents
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
0 deletions
+58
-0
.gitignore
.gitignore
+2
-0
app.js
app.js
+56
-0
No files found.
.gitignore
0 → 100644
View file @
934b98ad
.idea/
\ No newline at end of file
app.js
0 → 100644
View file @
934b98ad
var
start
=
new
Date
();
var
stop
=
new
Date
(
start
.
getTime
()
+
30
*
24
*
3600
*
1000
);
console
.
log
(
stop
);
function
cyclicInterval
(
from
,
until
,
interval
)
{
var
resultArray
=
[];
for
(
var
offset
=
0
;
until
.
getTime
()
+
offset
<
stop
.
getTime
();
offset
+=
interval
)
{
resultArray
.
push
([
new
Date
(
from
.
getTime
()
+
offset
),
new
Date
(
until
.
getTime
()
+
offset
)]);
}
return
resultArray
;
}
function
orOperator
(
intervals
)
{
var
result
=
[];
for
(
var
i
=
0
;
i
<
intervals
.
length
;
i
++
)
{
result
=
result
.
concat
(
intervals
[
i
]);
}
result
.
sort
(
function
(
a
,
b
)
{
return
a
[
0
]
-
b
[
0
];
});
return
result
;
}
function
removeOverlaps
(
interval
)
{
var
i
=
0
;
while
(
i
<
interval
.
length
-
1
)
{
var
endFirst
=
interval
[
i
][
1
];
var
startSecond
=
interval
[
i
+
1
][
0
];
var
endSecond
=
interval
[
i
+
1
][
1
];
if
(
endFirst
>
startSecond
)
{
interval
.
splice
(
i
+
1
,
1
);
interval
[
i
][
1
]
=
endSecond
;
}
else
i
++
;
}
return
interval
;
}
function
andOperator
(
interval1
,
interval2
)
{
var
i
=
0
;
var
j
=
0
;
while
(
i
<
interval1
.
length
&&
j
<
interval2
.
length
)
{
}
}
var
a
=
cyclicInterval
(
new
Date
(
2014
,
5
,
23
,
9
),
new
Date
(
2014
,
5
,
23
,
14
),
7
*
24
*
3600
*
1000
);
var
b
=
cyclicInterval
(
new
Date
(
2014
,
5
,
23
,
13
),
new
Date
(
2014
,
5
,
23
,
18
),
7
*
24
*
3600
*
1000
);
var
x
=
orOperator
([
a
,
b
]);
x
=
removeOverlaps
(
x
);
console
.
log
(
x
);
\ No newline at end of file
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