Commit 964b2601 authored by Johannes Bill's avatar Johannes Bill

fixed dateview asstring

parent 778847d8
{
"restApiHost": "127.0.0.1",
"restApiPort": 3001,
"mysqlConfig": {
"host": "127.0.0.1",
"user": "root",
"password": "bla",
"database": "holidays"
}
"restApiHost": "127.0.0.1",
"restApiPort": 3001,
"mysqlConfig": {
"host": "127.0.0.1",
"user": "root",
"password": "bla",
"database": "holidays"
}
}
\ No newline at end of file
......@@ -2,6 +2,8 @@ var moment = require('moment');
moment.lang("de");
var twoHours = 1000 * 3600 * 2;
function createWeekView(dataObj, now) {
var data = dataObj.intervals;
var holidays = dataObj.holidays;
......@@ -287,6 +289,7 @@ function asString(data, now) {
var open = false;
var nowT = now.getTime();
var idx = 0;
var first, second;
while (nowT >= data[idx][0].getTime() && idx < data.length) {
if (data[idx][1].getTime() >= nowT)
......@@ -295,27 +298,34 @@ function asString(data, now) {
}
if (open) {
idx--;
return {
isOpen: true,
asString: ["Jetzt geöffnet", "bis " + moment(data[idx][1]).format("LT")]
};
if(data[idx][1].getTime() - nowT <= twoHours)
first = "Jetzt noch geöffnet";
else first = "Jetzt geöffnet";
second = "bis " + moment(data[idx][1]).format("LT");
}
else {
var retStr = "Jetzt nicht geöffnet";
first = "Jetzt nicht geöffnet";
if (idx == data.length) {
return {
isOpen: false,
asString: [retStr, "nächster Öffnungstermin unbekannt"]
}
second = "nächster Öffnungstermin unbekannt";
}
else {
var nextM = moment(data[idx][0]);
return {
isOpen: false,
asString: [retStr, "wieder geöffnet am " + nextM.format("dddd") + ", " + nextM.format("l") + " ab " + nextM.format("LT")]
};
if(data[idx][0].getTime() - nowT <= twoHours) {
second = "bald wieder geöffnet, 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;
......
......@@ -38,6 +38,7 @@ module.exports.getData = function (now, cb) {
cnt++;
var view = dateView.getView(dataObj, now);
var asString = dateView.asString(dataObj, now);
asString = asString.asString.join(", ");
result.push('<div class="name">' + name + "</div> " + asString + view);
}
if (--iters == 0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment