Skip to content

Commit

Permalink
add beginning of yesterday and end of yesterday options
Browse files Browse the repository at this point in the history
  • Loading branch information
codeworkx authored and dirkjanfaber committed Dec 19, 2023
1 parent c3dc025 commit c948314
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/nodes/vrm-api.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
### /tfx

<option value="-86400">-24 hours</option>
<option value="boy">beginning of yesterday</option>
<option value="bod">beginning of day</option>
<option selected="selected" value="0">now</option>
</select>
Expand All @@ -119,6 +120,7 @@
<select id="node-input-stats_end">
<option value="0">now</option>
<option value="eod">end of day</option>
<option value="eoy">end of yesterday</option>
<option selected="selected" value="86400">+24 hours</option>
### tfx add more interval options
<option selected="selected" value="172800">+48 hours</option>
Expand Down
8 changes: 6 additions & 2 deletions src/nodes/vrm-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit c948314

Please sign in to comment.