Commit aaa10e49 authored by Johannes Bill's avatar Johannes Bill

added express test

parent 4ed27584
{ {
"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"], "BW": ["106", "1", "111"],
"BY": ["106", "1", "815", "111"], "BY": ["106", "1", "815", "111"],
"BE": [], "BE": [],
...@@ -15,4 +38,5 @@ ...@@ -15,4 +38,5 @@
"ST": ["106", "131"], "ST": ["106", "131"],
"SH": [], "SH": [],
"TH": ["1", "131"] "TH": ["1", "131"]
}
} }
\ No newline at end of file
var holidayMapping = require('./holidayMapping.json'); var holidayMapping = require('./holidayMapping.json');
var specificHolidays = getRegionSpecificHolidays(holidayMapping); var fixedHolidays = {
console.log(specificHolidays);
function getRegionSpecificHolidays(holidayMapping) {
var ids = [];
for(var key in holidayMapping) {
var obj = holidayMapping[key];
for (var i = 0; i < obj.length; i++) {
if(ids.indexOf(obj[i]) < 0)
ids.push(obj[i]);
}
}
return ids;
}
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", 101: "0101",
106: "0601", 106: "0601",
501: "0105", 501: "0105",
...@@ -48,16 +12,47 @@ function Holidays(year) { ...@@ -48,16 +12,47 @@ function Holidays(year) {
121: "2412", 121: "2412",
122: "2512", 122: "2512",
123: "2612" 123: "2612"
}; };
var variableOffsets = { var variableOffsets = {
301: -2, 301: -2,
302: 0, 302: 0,
303: 1, 303: 1,
502: 39, 502: 39,
601: 49, 601: 49,
602: 50 602: 50
}; };
var specificHolidays = getRegionSpecificHolidays(holidayMapping);
console.log(holidayMapping.sureHolidays.concat(holidayMapping.specificHolidays).sort());
function getRegionSpecificHolidays(holidayMapping) {
var data = holidayMapping["region"];
var ids = [];
for (var key in data) {
var obj = data[key];
for (var i = 0; i < obj.length; i++) {
if (ids.indexOf(obj[i]) < 0)
ids.push(obj[i]);
}
}
return ids.sort();
}
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;
}
function Holidays(year) {
var easterSundays = { var easterSundays = {
2014: new Date(2014, 3, 20), 2014: new Date(2014, 3, 20),
...@@ -93,13 +88,13 @@ function Holidays(year) { ...@@ -93,13 +88,13 @@ function Holidays(year) {
var holidays = getFixedHolidays(fixedHolidays); var holidays = getFixedHolidays(fixedHolidays);
holidays = getVariableHolidaysMap(variableOffsets, holidays); holidays = getVariableHolidaysMap(variableOffsets, holidays);
this.getHolidayIDs = function(region, kath) { this.getHolidayIDs = function (region, kath) {
if(region === 'BY') { if (region === 'BY') {
} }
}; };
this.getAllHolidays = function(region, kath) { this.getAllHolidays = function (region, kath) {
var result = []; var result = [];
for (var key in holidays) { for (var key in holidays) {
result.push(holidays[key]); 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