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
9f8a2c46
Commit
9f8a2c46
authored
Jun 25, 2014
by
Johannes Bill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bugfixing
parent
eca9e65e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
101 additions
and
27 deletions
+101
-27
holidays.js
holidays.js
+78
-0
jsonInput.js
jsonInput.js
+1
-1
timeUtils.js
timeUtils.js
+21
-25
todo
todo
+1
-1
No files found.
holidays.js
0 → 100644
View file @
9f8a2c46
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"
};
var
variableOffsets
=
{
301
:
-
2
,
302
:
0
,
303
:
1
,
502
:
39
,
601
:
49
,
602
:
50
};
function
getEasterSunday
()
{
return
new
Date
(
2014
,
3
,
5
);
}
function
getFixedHolidays
(
fixedHolidays
)
{
var
result
=
{};
for
(
var
key
in
fixedHolidays
)
{
var
dateString
=
fixedHolidays
[
key
];
var
date
=
parseInt
(
dateString
.
slice
(
0
,
2
));
var
month
=
parseInt
(
dateString
.
slice
(
2
,
4
));
console
.
log
(
date
,
month
);
result
[
key
]
=
new
Date
(
year
,
month
-
1
,
date
);
console
.
log
(
result
[
key
]);
}
return
result
;
}
function
getVariableHolidaysMap
(
offsets
)
{
var
result
=
{};
var
easterDate
=
getEasterSunday
();
for
(
var
key
in
offsets
)
{
var
offset
=
offsets
[
key
];
result
[
key
]
=
new
Date
(
year
,
easterDate
.
getMonth
(),
easterDate
.
getDate
()
+
offset
);
}
return
result
;
}
console
.
log
(
getFixedHolidays
(
fixedHolidays
));
console
.
log
(
getVariableHolidaysMap
(
variableOffsets
));
}
new
Holidays
(
2014
);
module
.
exports
=
Holidays
;
\ No newline at end of file
jsonInput.js
View file @
9f8a2c46
...
@@ -6,7 +6,7 @@ var excludeString = "bb74c170-b06f-4d2b-ab88-2f6bf9ce8068";
...
@@ -6,7 +6,7 @@ var excludeString = "bb74c170-b06f-4d2b-ab88-2f6bf9ce8068";
var
_epochStart
=
new
Date
();
var
_epochStart
=
new
Date
();
_epochStart
.
setDate
(
_epochStart
.
getDate
()
-
14
);
_epochStart
.
setDate
(
_epochStart
.
getDate
()
-
14
);
var
_epochEnd
=
new
Date
(
_epochStart
.
getTime
()
+
60
*
24
*
3600000
);
var
_epochEnd
=
new
Date
(
_epochStart
.
getTime
()
+
31
*
24
*
3600000
);
var
epocheSpan
=
[
_epochStart
,
_epochEnd
];
var
epocheSpan
=
[
_epochStart
,
_epochEnd
];
...
...
timeUtils.js
View file @
9f8a2c46
function
compareFT
(
from
,
till
)
{
function
compareTimeSpan
(
timeSpan
)
{
var
from
=
timeSpan
[
0
];
var
till
=
timeSpan
[
1
];
if
(
from
.
h
==
till
.
h
)
if
(
from
.
h
==
till
.
h
)
return
from
.
m
-
till
.
m
;
return
from
.
m
-
till
.
m
;
else
else
return
from
.
h
-
till
.
h
return
from
.
h
-
till
.
h
}
}
function
transformTi
ll
(
from
,
till
)
{
function
transformTi
meSpan
(
timeSpan
)
{
if
(
compare
FT
(
from
,
till
)
>=
0
)
{
if
(
compare
TimeSpan
(
timeSpan
)
>=
0
)
{
return
{
h
:
till
.
h
+
24
,
m
:
till
.
m
}
timeSpan
[
1
].
h
+=
24
;
}
}
else
return
till
;
return
timeSpan
;
}
}
function
_cyclicInterval
(
from
,
until
,
interval
,
epochStart
,
epochEnd
)
{
function
_cyclicInterval
(
from
,
until
,
interval
,
epochStart
,
epochEnd
)
{
...
@@ -35,6 +37,7 @@ function _standard(day, timeFrom, timeUntil, epochStart, epochEnd, distanceDays)
...
@@ -35,6 +37,7 @@ function _standard(day, timeFrom, timeUntil, epochStart, epochEnd, distanceDays)
}
}
function
standardFromTillDay
(
daySpan
,
timeSpan
,
dateSpan
,
daysDistance
)
{
function
standardFromTillDay
(
daySpan
,
timeSpan
,
dateSpan
,
daysDistance
)
{
timeSpan
=
transformTimeSpan
(
timeSpan
);
var
dayFrom
=
daySpan
[
0
];
var
dayFrom
=
daySpan
[
0
];
var
dayTill
=
daySpan
[
1
];
var
dayTill
=
daySpan
[
1
];
var
timeFrom
=
timeSpan
[
0
];
var
timeFrom
=
timeSpan
[
0
];
...
@@ -42,8 +45,6 @@ function standardFromTillDay(daySpan, timeSpan, dateSpan, daysDistance) {
...
@@ -42,8 +45,6 @@ function standardFromTillDay(daySpan, timeSpan, dateSpan, daysDistance) {
var
epochStart
=
dateSpan
[
0
];
var
epochStart
=
dateSpan
[
0
];
var
epochEnd
=
dateSpan
[
1
];
var
epochEnd
=
dateSpan
[
1
];
timeUntil
=
transformTill
(
timeFrom
,
timeUntil
);
var
firstDays
=
_standard
(
dayFrom
,
timeFrom
,
timeUntil
,
epochStart
,
epochEnd
,
daysDistance
);
var
firstDays
=
_standard
(
dayFrom
,
timeFrom
,
timeUntil
,
epochStart
,
epochEnd
,
daysDistance
);
var
result
=
firstDays
.
slice
();
var
result
=
firstDays
.
slice
();
...
@@ -85,6 +86,7 @@ function cyclic(day, noInMonth, timeFrom, timeUntil, epochStart, epochEnd) {
...
@@ -85,6 +86,7 @@ function cyclic(day, noInMonth, timeFrom, timeUntil, epochStart, epochEnd) {
}
}
function
cyclicFromTillDay
(
daySpan
,
noInMonth
,
timeSpan
,
dateSpan
,
epochSpan
)
{
function
cyclicFromTillDay
(
daySpan
,
noInMonth
,
timeSpan
,
dateSpan
,
epochSpan
)
{
timeSpan
=
transformTimeSpan
(
timeSpan
);
var
dayFrom
=
daySpan
[
0
];
var
dayFrom
=
daySpan
[
0
];
var
dayTill
=
daySpan
[
1
];
var
dayTill
=
daySpan
[
1
];
var
timeFrom
=
timeSpan
[
0
];
var
timeFrom
=
timeSpan
[
0
];
...
@@ -100,7 +102,6 @@ function cyclicFromTillDay(daySpan, noInMonth, timeSpan, dateSpan, epochSpan) {
...
@@ -100,7 +102,6 @@ function cyclicFromTillDay(daySpan, noInMonth, timeSpan, dateSpan, epochSpan) {
epochStart
=
new
Date
(
t
.
getFullYear
(),
t
.
getMonth
()
-
1
,
t
.
getDate
())
epochStart
=
new
Date
(
t
.
getFullYear
(),
t
.
getMonth
()
-
1
,
t
.
getDate
())
}
}
timeUntil
=
transformTill
(
timeFrom
,
timeUntil
);
var
result
=
[];
var
result
=
[];
epochStart
=
new
Date
(
epochStart
);
epochStart
=
new
Date
(
epochStart
);
...
@@ -179,26 +180,22 @@ function _getNextNoInMonthOccurence(day, startDate, noInMonth) {
...
@@ -179,26 +180,22 @@ function _getNextNoInMonthOccurence(day, startDate, noInMonth) {
return
startDate
;
return
startDate
;
}
}
function
singleDay
(
date
)
{
function
singleDay
(
date
,
timeSpan
)
{
var
startDate
=
new
Date
(
date
.
getFullYear
(),
date
.
getMonth
(),
date
.
getDate
());
var
startDate
,
endDate
;
var
endDate
=
new
Date
(
startDate
);
if
(
timeSpan
)
{
endDate
.
setDate
(
endDate
.
getDate
()
+
1
);
startDate
=
new
Date
(
date
.
getFullYear
(),
date
.
getMonth
(),
date
.
getDate
(),
timeSpan
[
0
].
h
,
timeSpan
[
0
].
m
);
endDate
=
new
Date
(
date
.
getFullYear
(),
date
.
getMonth
(),
date
.
getDate
(),
timeSpan
[
1
].
h
,
timeSpan
[
1
].
m
);
}
else
{
startDate
=
new
Date
(
date
.
getFullYear
(),
date
.
getMonth
(),
date
.
getDate
());
endDate
=
new
Date
(
date
.
getFullYear
(),
date
.
getMonth
(),
date
.
getDate
()
+
1
);
}
return
[
return
[
[
startDate
,
endDate
]
[
startDate
,
endDate
]
];
];
}
}
function
wholeInterval
(
start
,
end
)
{
return
[
new
Date
(
start
.
getFullYear
(),
start
.
getMonth
(),
start
.
getDate
()),
new
Date
(
end
.
getFullYear
(),
end
.
getMonth
(),
end
.
getDate
())];
}
function
limitToInterval
(
intervals
,
start
,
end
)
{
var
limit
=
wholeInterval
(
start
,
end
);
intervals
=
andOperator
(
intervals
,
limit
);
return
intervals
;
}
function
orOperator
(
intervals
)
{
function
orOperator
(
intervals
)
{
var
result
=
[];
var
result
=
[];
for
(
var
i
=
0
;
i
<
intervals
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
intervals
.
length
;
i
++
)
{
...
@@ -295,5 +292,4 @@ module.exports.singleDay = singleDay;
...
@@ -295,5 +292,4 @@ module.exports.singleDay = singleDay;
module
.
exports
.
orOperator
=
orOperator
;
module
.
exports
.
orOperator
=
orOperator
;
module
.
exports
.
andOperator
=
andOperator
;
module
.
exports
.
andOperator
=
andOperator
;
module
.
exports
.
andNotOperator
=
andNotOperator
;
module
.
exports
.
andNotOperator
=
andNotOperator
;
module
.
exports
.
mergeOverlaps
=
mergeOverlaps
;
module
.
exports
.
mergeOverlaps
=
mergeOverlaps
;
module
.
exports
.
limitToInterval
=
limitToInterval
;
\ No newline at end of file
\ No newline at end of file
todo
View file @
9f8a2c46
feiertage defaultmaessig abziehen
feiertage defaultmaessig abziehen
ausser feiertage sind in der ausschlussliste
verbindung feiertag - region
verbindung feiertag - region
\ No newline at end of file
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