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
964b2601
Commit
964b2601
authored
Aug 04, 2014
by
Johannes Bill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed dateview asstring
parent
778847d8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
21 deletions
+32
-21
config.json
config.json
+8
-8
dateView.js
lib/dateView.js
+23
-13
dataBaseQuery.js
serverTest/dataBaseQuery.js
+1
-0
No files found.
config.json
View file @
964b2601
{
{
"restApiHost"
:
"127.0.0.1"
,
"restApiHost"
:
"127.0.0.1"
,
"restApiPort"
:
3001
,
"restApiPort"
:
3001
,
"mysqlConfig"
:
{
"mysqlConfig"
:
{
"host"
:
"127.0.0.1"
,
"host"
:
"127.0.0.1"
,
"user"
:
"root"
,
"user"
:
"root"
,
"password"
:
"bla"
,
"password"
:
"bla"
,
"database"
:
"holidays"
"database"
:
"holidays"
}
}
}
}
\ No newline at end of file
lib/dateView.js
View file @
964b2601
...
@@ -2,6 +2,8 @@ var moment = require('moment');
...
@@ -2,6 +2,8 @@ var moment = require('moment');
moment
.
lang
(
"de"
);
moment
.
lang
(
"de"
);
var
twoHours
=
1000
*
3600
*
2
;
function
createWeekView
(
dataObj
,
now
)
{
function
createWeekView
(
dataObj
,
now
)
{
var
data
=
dataObj
.
intervals
;
var
data
=
dataObj
.
intervals
;
var
holidays
=
dataObj
.
holidays
;
var
holidays
=
dataObj
.
holidays
;
...
@@ -287,6 +289,7 @@ function asString(data, now) {
...
@@ -287,6 +289,7 @@ function asString(data, now) {
var
open
=
false
;
var
open
=
false
;
var
nowT
=
now
.
getTime
();
var
nowT
=
now
.
getTime
();
var
idx
=
0
;
var
idx
=
0
;
var
first
,
second
;
while
(
nowT
>=
data
[
idx
][
0
].
getTime
()
&&
idx
<
data
.
length
)
{
while
(
nowT
>=
data
[
idx
][
0
].
getTime
()
&&
idx
<
data
.
length
)
{
if
(
data
[
idx
][
1
].
getTime
()
>=
nowT
)
if
(
data
[
idx
][
1
].
getTime
()
>=
nowT
)
...
@@ -295,27 +298,34 @@ function asString(data, now) {
...
@@ -295,27 +298,34 @@ function asString(data, now) {
}
}
if
(
open
)
{
if
(
open
)
{
idx
--
;
idx
--
;
return
{
if
(
data
[
idx
][
1
].
getTime
()
-
nowT
<=
twoHours
)
isOpen
:
true
,
first
=
"Jetzt noch geöffnet"
;
asString
:
[
"Jetzt geöffnet"
,
"bis "
+
moment
(
data
[
idx
][
1
]).
format
(
"LT"
)]
else
first
=
"Jetzt geöffnet"
;
};
second
=
"bis "
+
moment
(
data
[
idx
][
1
]).
format
(
"LT"
);
}
}
else
{
else
{
var
retStr
=
"Jetzt nicht geöffnet"
;
first
=
"Jetzt nicht geöffnet"
;
if
(
idx
==
data
.
length
)
{
if
(
idx
==
data
.
length
)
{
return
{
second
=
"nächster Öffnungstermin unbekannt"
;
isOpen
:
false
,
asString
:
[
retStr
,
"nächster Öffnungstermin unbekannt"
]
}
}
}
else
{
else
{
var
nextM
=
moment
(
data
[
idx
][
0
]);
var
nextM
=
moment
(
data
[
idx
][
0
]);
return
{
if
(
data
[
idx
][
0
].
getTime
()
-
nowT
<=
twoHours
)
{
isOpen
:
false
,
second
=
"bald wieder geöffnet, ab "
+
nextM
.
format
(
"LT"
);
asString
:
[
retStr
,
"wieder geöffnet am "
+
nextM
.
format
(
"dddd"
)
+
", "
+
nextM
.
format
(
"l"
)
+
" ab "
+
nextM
.
format
(
"LT"
)]
}
};
else
if
(
compareDate
(
now
,
data
[
idx
][
0
])
===
0
)
{
second
=
"wieder geöffnet ab "
+
nextM
.
format
(
"LT"
)
}
else
{
second
=
"wieder geöffnet am "
+
nextM
.
format
(
"dddd"
)
+
", "
+
nextM
.
format
(
"l"
)
+
" ab "
+
nextM
.
format
(
"LT"
);
}
}
}
}
}
return
{
isOpen
:
open
,
asString
:
[
first
,
second
]
}
}
}
module
.
exports
.
asString
=
asString
;
module
.
exports
.
asString
=
asString
;
...
...
serverTest/dataBaseQuery.js
View file @
964b2601
...
@@ -38,6 +38,7 @@ module.exports.getData = function (now, cb) {
...
@@ -38,6 +38,7 @@ module.exports.getData = function (now, cb) {
cnt
++
;
cnt
++
;
var
view
=
dateView
.
getView
(
dataObj
,
now
);
var
view
=
dateView
.
getView
(
dataObj
,
now
);
var
asString
=
dateView
.
asString
(
dataObj
,
now
);
var
asString
=
dateView
.
asString
(
dataObj
,
now
);
asString
=
asString
.
asString
.
join
(
", "
);
result
.
push
(
'<div class="name">'
+
name
+
"</div> "
+
asString
+
view
);
result
.
push
(
'<div class="name">'
+
name
+
"</div> "
+
asString
+
view
);
}
}
if
(
--
iters
==
0
)
{
if
(
--
iters
==
0
)
{
...
...
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