Skip to content

Commit

Permalink
Merge pull request #786 from nightscout/wip/treatmentcurrent-fix
Browse files Browse the repository at this point in the history
minor fix for possible error when treatment data is missing
  • Loading branch information
jasoncalabrese committed Aug 16, 2015
2 parents c22f3b6 + deab2b9 commit 21e0192
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/plugins/treatmentnotify.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,13 @@ function init() {
}

function isCurrent(last) {
if (!last) {
return false;
}

var now = Date.now();
var lastTime = last ? last.mills : 0;
var ago = (lastTime && lastTime <= now) ? now - lastTime : -1;
var lastTime = last.mills;
var ago = (last.mills <= now) ? now - lastTime : -1;
return ago !== -1 && ago < times.mins(10).msecs;
}

Expand Down

0 comments on commit 21e0192

Please sign in to comment.