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
a80c76ee
Commit
a80c76ee
authored
Jun 27, 2014
by
Johannes Bill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed date comparison, added mocha test
parent
b27b6dec
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
6 deletions
+7
-6
jsonInput.js
jsonInput.js
+5
-4
timeUtils.js
timeUtils.js
+2
-2
No files found.
jsonInput.js
View file @
a80c76ee
...
...
@@ -7,9 +7,10 @@ var includeString = "810a6deb-46f2-4fa8-b779-bb5c2a6b5577";
var
excludeString
=
"bb74c170-b06f-4d2b-ab88-2f6bf9ce8068"
;
//var _epochStart = new Date(2014, 3, 0);
var
_epochStart
=
new
Date
(
2014
,
4
,
2
0
);
var
_epochStart
=
new
Date
(
2014
,
0
,
0
);
//_epochStart.setDate(_epochStart.getDate() - 30);
var
_epochEnd
=
new
Date
(
_epochStart
.
getTime
()
+
90
*
24
*
3600000
);
//var _epochEnd = new Date(_epochStart.getTime() + 500 * 24 * 3600000);
var
_epochEnd
=
new
Date
(
2016
,
0
,
0
);
var
epocheSpan
=
[
_epochStart
,
_epochEnd
];
...
...
@@ -40,7 +41,6 @@ function calculateOpeningHours(json) {
resultExcl
.
push
(
getOpeningHours
(
data
,
option
));
}
resultExcl
=
tmUtils
.
orOperator
(
resultExcl
);
var
allHolidays
=
getAllHolidays
();
resultIncl
=
tmUtils
.
orOperator
(
resultIncl
);
resultIncl
=
tmUtils
.
andNotOperator
(
resultIncl
,
allHolidays
);
...
...
@@ -200,4 +200,5 @@ function getOpeningHoursRepeatable(data) {
}
}
console
.
log
(
calculateOpeningHours
(
require
(
'./testData/testHof.json'
)));
\ No newline at end of file
var
data
=
calculateOpeningHours
(
require
(
'./testData/testHof.json'
));
console
.
log
(
data
);
\ No newline at end of file
timeUtils.js
View file @
a80c76ee
...
...
@@ -228,7 +228,7 @@ function orOperator(intervals) {
function
sort
(
intervals
)
{
intervals
.
sort
(
function
(
a
,
b
)
{
return
a
[
0
]
-
b
[
0
]
;
return
a
[
0
]
.
getTime
()
-
b
[
0
].
getTime
()
;
});
return
intervals
;
}
...
...
@@ -300,7 +300,7 @@ function invert(interval, epochStart, epochEnd) {
function
andNotOperator
(
interval1
,
interval2
)
{
var
epochStart
=
new
Date
(
Math
.
min
(
interval1
[
0
][
0
],
interval2
[
0
][
0
]));
var
epochEnd
=
new
Date
(
Math
.
m
in
(
interval1
[
interval1
.
length
-
1
][
1
],
interval2
[
interval2
.
length
-
1
][
1
]));
var
epochEnd
=
new
Date
(
Math
.
m
ax
(
interval1
[
interval1
.
length
-
1
][
1
],
interval2
[
interval2
.
length
-
1
][
1
]));
interval2
=
invert
(
interval2
,
epochStart
,
epochEnd
);
return
andOperator
(
interval1
,
interval2
);
...
...
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