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
c1424fd6
Commit
c1424fd6
authored
Jul 08, 2014
by
Johannes Bill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added Mocha Test
parent
7f271949
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
32 deletions
+4
-32
holidays.js
lib/holidays.js
+4
-32
No files found.
lib/holidays.js
View file @
c1424fd6
var
holidayMapping
=
require
(
'./holidayMapping.json'
);
var
easterSunday
=
require
(
'./easterSunday'
);
var
fixedHolidays
=
{
101
:
"0101"
,
...
...
@@ -23,44 +24,15 @@ var variableOffsets = {
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
=
{
2014
:
new
Date
(
2014
,
3
,
20
),
2015
:
new
Date
(
2015
,
3
,
5
),
2016
:
new
Date
(
2016
,
2
,
27
)
};
function
getEasterSunday
()
{
if
(
!
easterSundays
[
year
])
easterSundays
[
year
]
=
easterSunday
.
getEasterSunday
(
year
);
console
.
log
(
easterSundays
);
return
easterSundays
[
year
];
}
...
...
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