Commit aaa10e49 authored by Johannes Bill's avatar Johannes Bill

added express test

parent 4ed27584
{
"BW": ["106", "1", "111"],
"BY": ["106", "1", "815", "111"],
"BE": [],
"BB": ["131"],
"HB": [],
"HH": [],
"HE": ["1"],
"MV": ["131"],
"NI": [],
"NW": ["1", "111"],
"RP": ["1", "111"],
"SL": ["1", "815", "111"],
"SN": ["1", "131", "2"],
"ST": ["106", "131"],
"SH": [],
"TH": ["1", "131"]
}
"nameMapping": {
"0": "Alle",
"101": "Neujahrstag",
"106": "Hl. drei Koenige",
"301": "Karfreitag",
"302": "Ostersonntag",
"303": "Ostermontag",
"501": "Tag der Arbeit",
"502": "Himmelfahrt",
"601": "Pfingstsonntag",
"602": "Pfingstmontag",
"808": "Augsburger Friedensfest",
"815": "Mariae Himmelfahrt",
"103": "Tag der Deutschen Einheit",
"131": "Reformationstag",
"111": "Allerheiligen",
"121": "Heilig Abend",
"122": "Erster Weihnachtstag",
"123": "Zweiter Weihnachtstag"
},
"sureHolidays": [ "101", "103", "121", "122", "123", "501", "808", "301", "302", "303", "502", "601", "602" ],
"specificHolidays": [ "1", "106", "111", "131", "2", "815" ],
"region": {
"BW": ["106", "1", "111"],
"BY": ["106", "1", "815", "111"],
"BE": [],
"BB": ["131"],
"HB": [],
"HH": [],
"HE": ["1"],
"MV": ["131"],
"NI": [],
"NW": ["1", "111"],
"RP": ["1", "111"],
"SL": ["1", "815", "111"],
"SN": ["1", "131", "2"],
"ST": ["106", "131"],
"SH": [],
"TH": ["1", "131"]
}
}
\ No newline at end of file
var holidayMapping = require('./holidayMapping.json');
var fixedHolidays = {
101: "0101",
106: "0601",
501: "0105",
808: "0808",
815: "1508",
103: "0310",
131: "3110",
111: "1101",
121: "2412",
122: "2512",
123: "2612"
};
var variableOffsets = {
301: -2,
302: 0,
303: 1,
502: 39,
601: 49,
602: 50
};
var specificHolidays = getRegionSpecificHolidays(holidayMapping);
console.log(specificHolidays);
console.log(holidayMapping.sureHolidays.concat(holidayMapping.specificHolidays).sort());
function getRegionSpecificHolidays(holidayMapping) {
var data = holidayMapping["region"];
var ids = [];
for(var key in holidayMapping) {
var obj = holidayMapping[key];
for (var key in data) {
var obj = data[key];
for (var i = 0; i < obj.length; i++) {
if(ids.indexOf(obj[i]) < 0)
if (ids.indexOf(obj[i]) < 0)
ids.push(obj[i]);
}
}
return ids;
return ids.sort();
}
function Holidays(year) {
/* var mapping = {
0: "Alle",
101: "Neujahrstag",
106: "Hl. drei Koenige",
301: "Karfreitag",
302: "Ostersonntag",
303: "Ostermontag",
501: "Tag der Arbeit",
502: "Himmelfahrt",
601: "Pfingstsonntag",
602: "Pfingstmontag",
808: "Augsburger Friedensfest",
815: "Mariae Himmelfahrt",
103: "Tag der Deutschen Einheit",
131: "Reformationstag",
111: "Allerheiligen",
121: "Heilig Abend",
122: "Erster Weihnachtstag",
123: "Zweiter Weihnachtstag"};*/
var fixedHolidays = {
101: "0101",
106: "0601",
501: "0105",
808: "0808",
815: "1508",
103: "0310",
131: "3110",
111: "1101",
121: "2412",
122: "2512",
123: "2612"
};
function sureHolidays() {
var holidays = [];
for (var key in fixedHolidays) {
if(specificHolidays.indexOf(key) < 0)
holidays.push(key);
}
for (var key in variableOffsets) {
if(specificHolidays.indexOf(key) < 0)
holidays.push(key);
}
return holidays;
}
var variableOffsets = {
301: -2,
302: 0,
303: 1,
502: 39,
601: 49,
602: 50
};
function Holidays(year) {
var easterSundays = {
2014: new Date(2014, 3, 20),
......@@ -93,13 +88,13 @@ function Holidays(year) {
var holidays = getFixedHolidays(fixedHolidays);
holidays = getVariableHolidaysMap(variableOffsets, holidays);
this.getHolidayIDs = function(region, kath) {
if(region === 'BY') {
this.getHolidayIDs = function (region, kath) {
if (region === 'BY') {
}
};
this.getAllHolidays = function(region, kath) {
this.getAllHolidays = function (region, kath) {
var result = [];
for (var key in holidays) {
result.push(holidays[key]);
......
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