Commit 11cafb58 authored by Johannes Bill's avatar Johannes Bill

generators added

parent 252fa957
...@@ -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
{
"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
endzeit kleiner anfangszeit ==> endzeit + 24
\ No newline at end of file
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