diff --git a/README.md b/README.md index 659f7d3..6a36059 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ # valenBisiFilter -A filter for the valenbisi api to make it better for IOT \ No newline at end of file +A filter for the valenbisi api to make it better for IOT + +use nodemon for development :0 diff --git a/index.js b/index.js index 12c97ff..749d9fd 100644 --- a/index.js +++ b/index.js @@ -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);