Commit 56cb660e authored by Johannes Bill's avatar Johannes Bill

option for custom fields

parent 145bfc18
"use strict";
var tmUtils = require('./timeUtils'); var tmUtils = require('./timeUtils');
var holidaysGetter = {}; var holidaysGetter = {};
var Holidays = require('./holidays'); var Holidays = require('./holidays');
...@@ -27,10 +29,21 @@ function wrapper(_epochSpan) { ...@@ -27,10 +29,21 @@ function wrapper(_epochSpan) {
} }
function parseJSON(data) { function parseJSON(data) {
var rawCustom = data["custom"];
var custom = {};
for (var key in rawCustom) {
var field = rawCustom[key];
custom[field] = {
include: field.include || [],
exclude: field.exclude || []
}
}
return { return {
incl: data["include"], incl: data["include"],
excl: data["exclude"], excl: data["exclude"],
maybe: data["maybe"] maybe: data["maybe"],
custom: custom
} }
} }
...@@ -56,6 +69,16 @@ function wrapper(_epochSpan) { ...@@ -56,6 +69,16 @@ function wrapper(_epochSpan) {
ret.maybeIntervals = tmUtils.andNotOp(maybeIntervals, ret.intervals); ret.maybeIntervals = tmUtils.andNotOp(maybeIntervals, ret.intervals);
} }
ret.debugInfo = debugInfo; ret.debugInfo = debugInfo;
if (json.custom) {
var custIntervals = ret.customIntervals = {};
let custObj = json.custom;
for (let key in custObj) {
let field = custObj[key];
custIntervals[key] = buildOpeningHours([field.include, field.exclude], []);
}
}
cb(null, ret); cb(null, ret);
} }
......
...@@ -20,16 +20,13 @@ var blndMapping = { ...@@ -20,16 +20,13 @@ var blndMapping = {
module.exports = { module.exports = {
getBundesland: function (info, cb) { getBundesland: function (info, cb) {
if(!info.state) { var state = info.state || "Bayern";
console.log(info);
return cb(new Error("no state given"));
}
var mappedState = blndMapping[info.state]; var mappedState = blndMapping[state];
if(mappedState) return cb(null, mappedState); if(mappedState) return cb(null, mappedState);
else { else {
if(info.state = "Tschechien") return cb(null, "BY"); if(info.state = "Tschechien") return cb(null, "BY");
return cb(new Error("no state mapping found for " + info.state)) return cb(new Error("no state mapping found for " + state))
} }
}, },
getKatholisch: function (info, cb) { getKatholisch: function (info, cb) {
......
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