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
b47512ad
Commit
b47512ad
authored
Jul 10, 2014
by
Johannes Bill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor branch
parent
90b80c60
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
5 deletions
+29
-5
holidays.js
lib/holidays.js
+29
-5
No files found.
lib/holidays.js
View file @
b47512ad
...
@@ -2,6 +2,7 @@ var holidayMapping = require('./holidayMapping.json');
...
@@ -2,6 +2,7 @@ var holidayMapping = require('./holidayMapping.json');
var
easterSunday
=
require
(
'./easterSunday'
);
var
easterSunday
=
require
(
'./easterSunday'
);
var
restRequest
=
require
(
'./restRequests'
);
var
restRequest
=
require
(
'./restRequests'
);
var
easterSundays
=
{};
var
fixedHolidays
=
{
var
fixedHolidays
=
{
101
:
"0101"
,
101
:
"0101"
,
106
:
"0601"
,
106
:
"0601"
,
...
@@ -25,9 +26,27 @@ var variableOffsets = {
...
@@ -25,9 +26,27 @@ var variableOffsets = {
602
:
50
602
:
50
};
};
function
Holidays
(
year
)
{
var
holidayToSpecificMap
=
(
function
()
{
var
regionH
=
holidayMapping
[
"region"
];
var
hMap
=
{};
for
(
var
rKey
in
regionH
)
{
var
rH
=
regionH
[
rKey
];
for
(
var
cKey
in
rH
)
{
var
hArray
=
rH
[
cKey
];
for
(
var
i
=
0
;
i
<
hArray
.
length
;
i
++
)
{
var
hd
=
hArray
[
i
];
if
(
!
hMap
[
hd
])
hMap
[
hd
]
=
{
region
:
[],
special
:
[]};
if
(
cKey
==
"default"
)
hMap
[
hd
].
region
.
push
(
rKey
);
else
hMap
[
hd
].
special
.
push
(
cKey
);
}
}
}
return
hMap
;
}());
console
.
log
(
holidayToSpecificMap
);
var
easterSundays
=
{};
function
Holidays
(
year
)
{
function
getEasterSunday
()
{
function
getEasterSunday
()
{
if
(
!
easterSundays
[
year
])
if
(
!
easterSundays
[
year
])
...
@@ -58,13 +77,13 @@ function Holidays(year) {
...
@@ -58,13 +77,13 @@ function Holidays(year) {
var
holidays
=
getFixedHolidays
(
fixedHolidays
);
var
holidays
=
getFixedHolidays
(
fixedHolidays
);
holidays
=
getVariableHolidaysMap
(
variableOffsets
,
holidays
);
holidays
=
getVariableHolidaysMap
(
variableOffsets
,
holidays
);
console
.
log
(
holidays
);
function
getIsAugsburg
(
plz
)
{
function
getIsAugsburg
(
plz
)
{
return
!!
(
86150
<=
plz
&&
plz
<=
86199
);
return
!!
(
86150
<=
plz
&&
plz
<=
86199
);
}
}
function
getRegionOptions
(
plz
,
cb
)
{
function
getRegionOptions
(
plz
,
epochSpan
,
cb
)
{
var
blnd
;
var
blnd
;
var
options
=
{
var
options
=
{
isKath
:
false
,
isKath
:
false
,
...
@@ -86,6 +105,11 @@ function Holidays(year) {
...
@@ -86,6 +105,11 @@ function Holidays(year) {
cb
(
null
,
options
);
cb
(
null
,
options
);
}
}
});
});
}
function
isInEpochSpan
(
date
,
epochSpan
)
{
var
dateTime
=
date
.
getTime
();
return
epochSpan
[
0
].
getTime
()
<=
dateTime
&&
dateTime
<=
epochSpan
[
1
].
getTime
()
}
}
...
@@ -96,7 +120,7 @@ function Holidays(year) {
...
@@ -96,7 +120,7 @@ function Holidays(year) {
return
cb
(
null
,
keys
);
return
cb
(
null
,
keys
);
}
}
getRegionOptions
(
plz
,
function
(
err
,
options
)
{
getRegionOptions
(
plz
,
epochSpan
,
function
(
err
,
options
)
{
console
.
log
(
options
);
console
.
log
(
options
);
if
(
err
)
return
cb
(
err
);
if
(
err
)
return
cb
(
err
);
var
blnd
=
options
.
blnd
;
var
blnd
=
options
.
blnd
;
...
...
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