diff --git a/src/nodes/vrm-api.html b/src/nodes/vrm-api.html index 0bc1e3d..5d17878 100644 --- a/src/nodes/vrm-api.html +++ b/src/nodes/vrm-api.html @@ -110,6 +110,7 @@ ### /tfx -24 hours + beginning of yesterday beginning of day now @@ -119,6 +120,7 @@ now end of day + end of yesterday +24 hours ### tfx add more interval options +48 hours diff --git a/src/nodes/vrm-api.js b/src/nodes/vrm-api.js index 9540e53..513cfbf 100644 --- a/src/nodes/vrm-api.js +++ b/src/nodes/vrm-api.js @@ -43,14 +43,18 @@ module.exports = function (RED) { } if (config.stats_start !== 'undefined') { let start = config.stats_start - if (config.stats_start === 'bod') { + if (start === 'boy') { + start = (new Date().setUTCHours(0, 0, 0, 0) - Date.now() - 86400000) / 1000 + } else if (start === 'bod') { start = (new Date().setUTCHours(0, 0, 0, 0) - Date.now()) / 1000 } url += '&start=' + Math.floor((d.getTime() / 1000) + Number(start)) } if (config.stats_end !== 'undefined') { let end = config.stats_end - if (config.stats_end === 'eod') { + if (end === 'eoy') { + end = (new Date().setUTCHours(23, 59, 59, 0) - Date.now() - 86400000) / 1000 + } else if (end === 'eod') { end = (new Date().setUTCHours(23, 59, 59, 0) - Date.now()) / 1000 } url += '&end=' + Math.floor((d.getTime() / 1000) + Number(end))