Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
opening-hours
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
regionalkauf
opening-hours
Commits
aaa10e49
Commit
aaa10e49
authored
Jul 08, 2014
by
Johannes Bill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added express test
parent
4ed27584
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
86 additions
and
67 deletions
+86
-67
holidayMapping.json
lib/holidayMapping.json
+41
-17
holidays.js
lib/holidays.js
+45
-50
No files found.
lib/holidayMapping.json
View file @
aaa10e49
{
{
"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
lib/holidays.js
View file @
aaa10e49
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
]);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment