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
11cafb58
Commit
11cafb58
authored
Jun 24, 2014
by
Johannes Bill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
generators added
parent
252fa957
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
188 additions
and
35 deletions
+188
-35
app.js
app.js
+23
-35
data.json
data.json
+164
-0
todo
todo
+1
-0
No files found.
app.js
View file @
11cafb58
...
@@ -14,19 +14,6 @@ function _cyclicInterval(from, until, interval, epochStart, epochEnd) {
...
@@ -14,19 +14,6 @@ function _cyclicInterval(from, until, interval, epochStart, epochEnd) {
return
resultArray
;
return
resultArray
;
}
}
/**
*
* @param day weekday 0=sunday
* @param timeFrom
* @param timeFrom.h
* @param timeFrom.m
* @param timeUntil
* @param timeUntil.h
* @param timeUntil.m
* @param epochStart
* @param epochEnd
* @param distanceDays
*/
function
standard
(
day
,
timeFrom
,
timeUntil
,
epochStart
,
epochEnd
,
distanceDays
)
{
function
standard
(
day
,
timeFrom
,
timeUntil
,
epochStart
,
epochEnd
,
distanceDays
)
{
var
dayDiff
=
day
-
epochStart
.
getDay
();
var
dayDiff
=
day
-
epochStart
.
getDay
();
if
(
dayDiff
<
0
)
if
(
dayDiff
<
0
)
...
@@ -36,29 +23,25 @@ function standard(day, timeFrom, timeUntil, epochStart, epochEnd, distanceDays)
...
@@ -36,29 +23,25 @@ function standard(day, timeFrom, timeUntil, epochStart, epochEnd, distanceDays)
epochStart
.
getDate
()
+
dayDiff
,
timeFrom
.
h
,
timeFrom
.
m
);
epochStart
.
getDate
()
+
dayDiff
,
timeFrom
.
h
,
timeFrom
.
m
);
var
endDate
=
new
Date
(
epochStart
.
getFullYear
(),
epochStart
.
getMonth
(),
var
endDate
=
new
Date
(
epochStart
.
getFullYear
(),
epochStart
.
getMonth
(),
epochStart
.
getDate
()
+
dayDiff
,
timeUntil
.
h
,
timeUntil
.
m
);
epochStart
.
getDate
()
+
dayDiff
,
timeUntil
.
h
,
timeUntil
.
m
);
return
_cyclicInterval
(
startDate
,
endDate
,
distanceDays
*
24
*
3600000
,
epochStart
,
epochEnd
);
return
_cyclicInterval
(
startDate
,
endDate
,
distanceDays
*
24
*
3600000
,
epochStart
,
epochEnd
);
}
}
/**
*
* @param dayFrom
* @param dayTill
* @param timeFrom
* @param timeFrom.h
* @param timeFrom.m
* @param timeUntil
* @param timeUntil.h
* @param timeUntil.m
* @param epochStart {Date}
* @param epochEnd {Date}
* @returns {Array}
* @param distanceDays
*/
function
standardFromTillDay
(
dayFrom
,
dayTill
,
timeFrom
,
timeUntil
,
epochStart
,
epochEnd
,
distanceDays
)
{
function
standardFromTillDay
(
dayFrom
,
dayTill
,
timeFrom
,
timeUntil
,
epochStart
,
epochEnd
,
distanceDays
)
{
var
result
=
[];
var
firstDays
=
standard
(
dayFrom
,
timeFrom
,
timeUntil
,
epochStart
,
epochEnd
,
distanceDays
);
for
(
var
i
=
dayFrom
;
i
<=
dayTill
;
i
++
)
{
var
result
=
firstDays
.
slice
();
result
=
result
.
concat
(
standard
(
i
,
timeFrom
,
timeUntil
,
epochStart
,
epochEnd
,
distanceDays
))
for
(
var
offset
=
1
;
offset
<=
dayTill
-
dayFrom
;
offset
++
)
{
for
(
var
i
=
0
;
i
<
firstDays
.
length
;
i
++
)
{
var
start
=
new
Date
(
firstDays
[
i
][
0
]);
var
end
=
new
Date
(
firstDays
[
i
][
1
]);
start
.
setDate
(
start
.
getDate
()
+
offset
);
end
.
setDate
(
end
.
getDate
()
+
offset
);
if
(
end
<=
epochEnd
)
result
.
push
([
start
,
end
]);
}
}
}
result
=
sortDateIntervals
(
result
);
result
=
sortDateIntervals
(
result
);
return
result
;
return
result
;
}
}
...
@@ -259,8 +242,13 @@ function andNotOperator(interval1, interval2) {
...
@@ -259,8 +242,13 @@ function andNotOperator(interval1, interval2) {
//var y = andNotOperator(a, c);
//var y = andNotOperator(a, c);
//console.log(y);
//console.log(y);
var
workday
=
standardFromTillDay
(
1
,
2
,
{
h
:
9
,
m
:
0
},
{
h
:
11
,
m
:
45
},
_epochStart
,
_epochEnd
,
14
);
//var workday = standardFromTillDay(1, 6, {h: 9, m: 0}, {h: 11, m: 45}, _epochStart, _epochEnd, 14);
console
.
log
(
workday
);
//console.log(workday);
var
t
=
cyclicFromTillDay
(
1
,
5
,
-
1
,
{
h
:
9
,
m
:
0
},
{
h
:
18
,
m
:
29
},
_epochStart
,
_epochEnd
);
var
t2
=
cyclicFromTillDay
(
2
,
2
,
-
1
,
{
h
:
9
,
m
:
0
},
{
h
:
18
,
m
:
29
},
_epochStart
,
_epochEnd
);
var
res
=
andNotOperator
(
t
,
t2
);
//var t = cyclicFromTillDay(1, 7, -1, {h: 9, m: 0}, {h: 18, m: 29}, _epochStart, _epochEnd);
console
.
log
(
res
);
//console.log(t);
\ No newline at end of file
\ No newline at end of file
data.json
0 → 100644
View file @
11cafb58
{
"0"
:
{
"option"
:
{
"0"
:
"default"
},
"dayoption"
:
{
"0"
:
"1"
},
"repeatoption"
:
{
"0"
:
""
},
"holidayoption"
:
{
"0"
:
""
},
"opening_day_from"
:
""
,
"opening_day_to"
:
""
,
"opening_from"
:
"9:00"
,
"opening_to"
:
"18:00"
},
"1"
:
{
"option"
:
{
"0"
:
"default"
},
"dayoption"
:
{
"0"
:
"2"
},
"repeatoption"
:
{
"0"
:
""
},
"holidayoption"
:
{
"0"
:
""
},
"opening_day_from"
:
""
,
"opening_day_to"
:
""
,
"opening_from"
:
"9:00"
,
"opening_to"
:
"12:00"
},
"2"
:
{
"option"
:
{
"0"
:
"default"
},
"dayoption"
:
{
"0"
:
"2"
},
"repeatoption"
:
{
"0"
:
""
},
"holidayoption"
:
{
"0"
:
""
},
"opening_day_from"
:
""
,
"opening_day_to"
:
""
,
"opening_from"
:
"13:00"
,
"opening_to"
:
"18:00"
},
"3"
:
{
"option"
:
{
"0"
:
"default"
},
"dayoption"
:
{
"0"
:
"8"
},
"repeatoption"
:
{
"0"
:
""
},
"holidayoption"
:
{
"0"
:
""
},
"opening_day_from"
:
""
,
"opening_day_to"
:
""
,
"opening_from"
:
"9:00"
,
"opening_to"
:
"18:00"
},
"4"
:
{
"option"
:
{
"0"
:
"repeatable"
},
"dayoption"
:
{
"0"
:
"3"
},
"repeatoption"
:
{
"0"
:
"3"
},
"holidayoption"
:
{
"0"
:
""
},
"opening_day_from"
:
""
,
"opening_day_to"
:
""
,
"opening_from"
:
"9:00"
,
"opening_to"
:
"18:00"
},
"5"
:
{
"option"
:
{
"0"
:
"repeatable"
},
"dayoption"
:
{
"0"
:
"4"
},
"repeatoption"
:
{
"0"
:
"14"
},
"holidayoption"
:
{
"0"
:
""
},
"opening_day_from"
:
"02.01"
,
"opening_day_to"
:
""
,
"opening_from"
:
"9:00"
,
"opening_to"
:
"18:00"
},
"6"
:
{
"option"
:
{
"0"
:
"season"
},
"dayoption"
:
{
"0"
:
"5"
},
"repeatoption"
:
{
"0"
:
""
},
"holidayoption"
:
{
"0"
:
""
},
"opening_day_from"
:
"25.05"
,
"opening_day_to"
:
"30.11"
,
"opening_from"
:
"9:00"
,
"opening_to"
:
"18:00"
},
"7"
:
{
"option"
:
{
"0"
:
"holiday"
},
"dayoption"
:
{
"0"
:
"1"
},
"repeatoption"
:
{
"0"
:
""
},
"holidayoption"
:
{
"0"
:
"0"
},
"opening_day_from"
:
""
,
"opening_day_to"
:
""
,
"opening_from"
:
"9:00"
,
"opening_to"
:
"18:00"
},
"8"
:
{
"option"
:
{
"0"
:
"vacation"
},
"dayoption"
:
{
"0"
:
"1"
},
"repeatoption"
:
{
"0"
:
""
},
"holidayoption"
:
{
"0"
:
""
},
"opening_day_from"
:
"25.08"
,
"opening_day_to"
:
"10.09"
,
"opening_from"
:
"9:00"
,
"opening_to"
:
"18:00"
}
}
\ No newline at end of file
todo
0 → 100644
View file @
11cafb58
endzeit kleiner anfangszeit ==> endzeit + 24
\ 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