Commit b58db5f7 authored by Johannes Bill's avatar Johannes Bill

bla

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