Commit b58db5f7 authored by Johannes Bill's avatar Johannes Bill

bla

parent 9f8a2c46
.idea/ .idea/
node_modules
\ No newline at end of file
...@@ -32,6 +32,7 @@ function Holidays(year) { ...@@ -32,6 +32,7 @@ function Holidays(year) {
122: "2512", 122: "2512",
123: "2612" 123: "2612"
}; };
var variableOffsets = { var variableOffsets = {
301: -2, 301: -2,
302: 0, 302: 0,
...@@ -45,8 +46,8 @@ function Holidays(year) { ...@@ -45,8 +46,8 @@ function Holidays(year) {
return new Date(2014, 3, 5); return new Date(2014, 3, 5);
} }
function getFixedHolidays(fixedHolidays) { function getFixedHolidays(fixedHolidays, object) {
var result = {}; var result = object || {};
for(var key in fixedHolidays) { for(var key in fixedHolidays) {
var dateString = fixedHolidays[key]; var dateString = fixedHolidays[key];
var date = parseInt(dateString.slice(0,2)); var date = parseInt(dateString.slice(0,2));
...@@ -58,8 +59,8 @@ function Holidays(year) { ...@@ -58,8 +59,8 @@ function Holidays(year) {
return result; return result;
} }
function getVariableHolidaysMap(offsets) { function getVariableHolidaysMap(offsets, object) {
var result = {}; var result = object || {};
var easterDate = getEasterSunday(); var easterDate = getEasterSunday();
for(var key in offsets) { for(var key in offsets) {
var offset = offsets[key]; var offset = offsets[key];
...@@ -74,5 +75,4 @@ function Holidays(year) { ...@@ -74,5 +75,4 @@ function Holidays(year) {
new Holidays(2014); new Holidays(2014);
module.exports = Holidays; module.exports = Holidays;
\ No newline at end of file
...@@ -5,8 +5,8 @@ var includeString = "810a6deb-46f2-4fa8-b779-bb5c2a6b5577"; ...@@ -5,8 +5,8 @@ var includeString = "810a6deb-46f2-4fa8-b779-bb5c2a6b5577";
var excludeString = "bb74c170-b06f-4d2b-ab88-2f6bf9ce8068"; var excludeString = "bb74c170-b06f-4d2b-ab88-2f6bf9ce8068";
var _epochStart = new Date(); var _epochStart = new Date();
_epochStart.setDate(_epochStart.getDate() - 14); _epochStart.setDate(_epochStart.getDate()-14);
var _epochEnd = new Date(_epochStart.getTime() + 31 * 24 * 3600000); var _epochEnd = new Date(_epochStart.getTime()+31*24*3600000);
var epocheSpan = [_epochStart, _epochEnd]; var epocheSpan = [_epochStart, _epochEnd];
...@@ -19,18 +19,17 @@ function calculateOpeningHours(json) { ...@@ -19,18 +19,17 @@ function calculateOpeningHours(json) {
var resultIncl = getIntervals(jsonIncl); var resultIncl = getIntervals(jsonIncl);
var resultExcl = getIntervals(jsonExcl); var resultExcl = getIntervals(jsonExcl);
console.log(resultIncl);
console.log(resultExcl);
console.log(tmUtils.andNotOperator(resultIncl, resultExcl));
var result = tmUtils.andNotOperator(resultIncl, resultExcl);
console.log(process.hrtime(time0));
console.log(result);
} }
function getIntervals(json) { function getIntervals(json) {
var result = []; var result = [];
for(var key in json) { for (var key in json) {
var x = getOpeningHours(json[key]); var x = getOpeningHours(json[key]);
if(x) if (x)
result.push(x); result.push(x);
} }
return tmUtils.orOperator(result); return tmUtils.orOperator(result);
...@@ -38,8 +37,8 @@ function getIntervals(json) { ...@@ -38,8 +37,8 @@ function getIntervals(json) {
function getDaySpan(dayoption) { function getDaySpan(dayoption) {
if(dayoption < 7) return [dayoption, dayoption]; if (dayoption < 7) return [dayoption, dayoption];
switch(dayoption) { switch (dayoption) {
case 7: case 7:
return [0, 0]; return [0, 0];
case 8: case 8:
...@@ -62,13 +61,13 @@ function parseTime(time) { ...@@ -62,13 +61,13 @@ function parseTime(time) {
} }
function parseDate(date, addOneDay) { function parseDate(date, addOneDay) {
if(date.length == 0) if (date.length == 0)
return null; return null;
var year = now.getFullYear(); var year = now.getFullYear();
var split = date.split("."); var split = date.split(".");
var month = parseInt(split[1]) - 1; var month = parseInt(split[1])-1;
var day = parseInt(split[0]) + addOneDay?1:0; var day = parseInt(split[0])+addOneDay ? 1 : 0;
return new Date(year, month, day); return new Date(year, month, day);
} }
...@@ -84,7 +83,7 @@ function getOpeningHours(data) { ...@@ -84,7 +83,7 @@ function getOpeningHours(data) {
var timeSpan = [parseTime(data["opening_from"]), parseTime(data["opening_to"])]; var timeSpan = [parseTime(data["opening_from"]), parseTime(data["opening_to"])];
switch(option) { switch (option) {
case "default": case "default":
return tmUtils.standardFromTillDay(daySpan, timeSpan, epocheSpan, 7); return tmUtils.standardFromTillDay(daySpan, timeSpan, epocheSpan, 7);
case "season": case "season":
...@@ -92,13 +91,13 @@ function getOpeningHours(data) { ...@@ -92,13 +91,13 @@ function getOpeningHours(data) {
case "repeatable": case "repeatable":
var repeatOption = parseInt(data["repeatoption"]["0"]); var repeatOption = parseInt(data["repeatoption"]["0"]);
var noInMonth; var noInMonth;
if(repeatOption <= 4) noInMonth = repeatOption; if (repeatOption <= 4) noInMonth = repeatOption;
else if(repeatOption == 30) noInMonth = -1; else if (repeatOption == 30) noInMonth = -1;
if(noInMonth) if (noInMonth)
return tmUtils.cyclicFromTillDay(daySpan, noInMonth, timeSpan, dateSpan, epocheSpan); return tmUtils.cyclicFromTillDay(daySpan, noInMonth, timeSpan, dateSpan, epocheSpan);
switch(repeatOption) { switch (repeatOption) {
case 14: case 14:
case 21: case 21:
case 28: case 28:
......
{
"name": "OpeningHours",
"version": "0.0.0",
"main": "holidays.js",
"dependencies": {
"express": "^4.4.4"
},
"devDependencies": {},
"author": "",
"license": "ISC",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": " "
}
}
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