Skip to content

Commit c8e447e

Browse files
committed
Fix timeouts with floating point numbers bug
fixes #897.
1 parent 3ce5e6f commit c8e447e

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/node.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ int Start (int argc, char *argv[]);
4343

4444
/* Converts a unixtime to V8 Date */
4545
#define NODE_UNIXTIME_V8(t) v8::Date::New(1000*static_cast<double>(t))
46-
#define NODE_V8_UNIXTIME(v) (static_cast<double>((v)->IntegerValue())/1000.0);
46+
#define NODE_V8_UNIXTIME(v) (static_cast<double>((v)->NumberValue())/1000.0);
4747

4848
#define NODE_DEFINE_CONSTANT(target, constant) \
4949
(target)->Set(v8::String::NewSymbol(#constant), \

test/simple/test-regress-GH-897.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
var common = require('../common');
2+
var assert = require('assert');
3+
4+
var t = Date.now();
5+
var diff;
6+
setTimeout(function () {
7+
diff = Date.now() - t;
8+
console.error(diff);
9+
}, 0.1);
10+
11+
12+
process.on('exit', function() {
13+
assert.ok(diff < 10);
14+
});

0 commit comments

Comments
 (0)