Skip to content

Commit

Permalink
fix: increment hours when necessary while rounding time (#4346)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCalzone committed Mar 10, 2022
1 parent 93aa398 commit 900955f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/zwave-js/src/lib/node/Node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3089,11 +3089,13 @@ protocol version: ${this.protocolVersion}`;
// minute difference)
const now = new Date();
// local time
const hours = now.getHours();
let hours = now.getHours();
let minutes = now.getMinutes();
// A sending node knowing the current time with seconds precision SHOULD round its
// current time to the nearest minute when sending this command.
if (now.getSeconds() >= 30) {
// 18:59:31 should be rounded to 19:00, not 18:00
if (minutes === 59) hours++;
minutes = (minutes + 1) % 60;
}
// Sunday is 0 in JS, but 7 in Z-Wave
Expand Down

0 comments on commit 900955f

Please sign in to comment.