Adding time object

This commit is contained in:
Lukas Bachschwell 2017-11-23 21:55:47 +01:00
parent dafc52aa09
commit 6a915c0ef6
2 changed files with 15 additions and 1 deletions

View File

@ -1,3 +1,5 @@
# valenBisiFilter
A filter for the valenbisi api to make it better for IOT
A filter for the valenbisi api to make it better for IOT
use nodemon for development :0

View File

@ -15,6 +15,12 @@ let returnObject;
returnObject = o;
}
});
let time = {
seconds: pad(new Date().getSeconds(), 2),
minutes: pad(new Date().getMinutes(), 2),
hours: pad(new Date().getHours(), 2)
};
returnObject.time = time;
return returnObject;
};
@ -45,5 +51,11 @@ function requestData(){
console.log(error);
});
}
function pad(n, width, z) {
z = z || '0';
n = n + '';
return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
}
// Listen for incoming requests and serve them.
app.listen(process.env.PORT || 3000);