Skip to content

Commit 9963fb4

Browse files
committed
Fixing nanosecond calculation bug.
1 parent 02b30ce commit 9963fb4

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lib/rosauth.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function diffTime(l, s) {
5454

5555
function getJavaScriptTime() {
5656
const t = new Date().getTime();
57-
return {sec: Math.floor(t / 1000), nanosec: t % 1000};
57+
return {sec: Math.floor(t / 1000), nanosec: (t % 1000) * 1000 * 1000};
5858
}
5959

6060
function authenticate(msg) {

test/test-rosauth-internal.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const {sha512} = require('js-sha512');
2020

2121
function getJavaScriptTime() {
2222
const t = new Date().getTime();
23-
return {sec: Math.floor(t / 1000), nanosec: t % 1000};
23+
return {sec: Math.floor(t / 1000), nanosec: (t % 1000) * 1000 * 1000};
2424
}
2525

2626
describe('Test rosauth module internally/directly', function() {

0 commit comments

Comments
 (0)