Commit 7de0ed18 authored by Johannes Bill's avatar Johannes Bill

added express test

parent d91c5965
......@@ -95,6 +95,8 @@ function parseTime(time) {
}
}
//TODO now.getFullYear muss verschwinden, Jahreswechsel!!!!
function parseDate(date, addOneDay) {
if (date.length == 0)
return null;
......@@ -136,6 +138,7 @@ function getAllHolidays() {
function getDateSpan(data) {
var startDate = parseDate(data["opening_day_from"]) || epochSpan[0];
var endDate = parseDate(data["opening_day_to"], true) || epochSpan[1];
//TODO start und enddate vertauschen, falls enddate < startdate
return [startDate, endDate];
}
......
......@@ -2,7 +2,6 @@ var moment = require('moment');
moment.lang("de");
function createWeekView(data, now) {
var noOfDays = 7;
var offset = 3;
......@@ -123,7 +122,7 @@ function getMaxNoOfItemsPerDay(oHours) {
}
function formatDate(date) {
return moment(date).format("dd MM");
return moment(date).format("dd ll");
}
function formatTime(date) {
......@@ -165,7 +164,7 @@ function compareDate(date1, date2) {
}
function getPropperEpocheSpan(now) {
var epocheStart = new Date(now.getFullYear(), now.getMonth(), 1 - 4);
var epocheStart = new Date(now.getFullYear(), now.getMonth(), -10);
var epocheEnd = new Date(now.getFullYear(), now.getMonth() + 3, 1);
console.log(epocheStart);
console.log(epocheEnd);
......
......@@ -9,14 +9,14 @@ var connection = mysql.createConnection({
database: 'regiostart'
});
connection.connect();
module.exports.getData = function (cb) {
var now = new Date();
module.exports.getData = function (now, cb) {
dateArray.setEpocheSpan(dateView.getPropperEpocheSpan(now));
var epocheSpan = dateView.getPropperEpocheSpan(now);
console.log(now);
console.log(epocheSpan);
dateArray.setEpocheSpan(epocheSpan);
connection.query('SELECT name, elements FROM cms_zoo_item WHERE type = "company"', function (err, rows) {
var result = [];
......@@ -31,7 +31,6 @@ module.exports.getData = function (cb) {
}
}
catch (err) {
console.log(err, name);
}
}
cb(result.join('<br>'));
......
......@@ -3,8 +3,23 @@ var router = express.Router();
var db = require('../dataBaseQuery');
router.get('/', function(req, res) {
db.getData(function(result) {
var time0 = process.hrtime();
var dateString = req.query.date;
var now;
if(dateString.length == 8) {
var year = parseInt(dateString.slice(0,4));
var month = parseInt(dateString.slice(4,6));
var date = parseInt(dateString.slice(6,8));
now = new Date(year, month - 1, date);
}
else {
now = new Date();
}
db.getData(now, function(result) {
res.render('index', { body: result });
var time1 = process.hrtime(time0);
console.log('Time: ' + (time1[0] + time1[1]/1e9));
});
......
......@@ -15,9 +15,6 @@
.monthview-empty {
background-color: lightcoral;
}
.weekview-table {
border: 1px solid;
}
.name {
font-size: 20px;
}
......
......@@ -6,6 +6,7 @@ was passiert bei der zeitumstellung?
falls oeffnungszeit z.b. von 21:00 bis 4:00 muss bei 0:00 getrennt werden
saisonal,urlaub etc ueber neujahr? 23.12.2014 - 10.01.2015????
Funktionen:
......
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