diff --git a/src/file.cc b/src/file.cc index 8cb1bc6c89..03037f7494 100644 --- a/src/file.cc +++ b/src/file.cc @@ -58,7 +58,6 @@ EIOPromise::Create (void) return promise; } -#define NODE_UNIXTIME(t) v8::Date::New(1000*static_cast(t)) int EIOPromise::After (eio_req *req) { @@ -106,9 +105,9 @@ EIOPromise::After (eio_req *req) stats->Set(SIZE_SYMBOL, Integer::New(s->st_size)); /* total size, in bytes */ stats->Set(BLKSIZE_SYMBOL, Integer::New(s->st_blksize)); /* blocksize for filesystem I/O */ stats->Set(BLOCKS_SYMBOL, Integer::New(s->st_blocks)); /* number of blocks allocated */ - stats->Set(ATIME_SYMBOL, NODE_UNIXTIME(s->st_atime)); /* time of last access */ - stats->Set(MTIME_SYMBOL, NODE_UNIXTIME(s->st_mtime)); /* time of last modification */ - stats->Set(CTIME_SYMBOL, NODE_UNIXTIME(s->st_ctime)); /* time of last status change */ + stats->Set(ATIME_SYMBOL, NODE_UNIXTIME_V8(s->st_atime)); /* time of last access */ + stats->Set(MTIME_SYMBOL, NODE_UNIXTIME_V8(s->st_mtime)); /* time of last modification */ + stats->Set(CTIME_SYMBOL, NODE_UNIXTIME_V8(s->st_ctime)); /* time of last status change */ argc = 1; argv[0] = stats; break; diff --git a/src/net.cc b/src/net.cc index d3b66b6775..6955549e60 100644 --- a/src/net.cc +++ b/src/net.cc @@ -328,7 +328,7 @@ Connection::SetTimeout (const Arguments& args) Connection *connection = ObjectWrap::Unwrap(args.This()); assert(connection); - float timeout = (float)(args[0]->IntegerValue()) / 1000; + float timeout = NODE_V8_UNIXTIME(args[0]); connection->SetTimeout(timeout); diff --git a/src/node.h b/src/node.h index de1a547fab..6e18221586 100644 --- a/src/node.h +++ b/src/node.h @@ -11,6 +11,10 @@ namespace node { +/* Converts a unixtime to V8 Date */ +#define NODE_UNIXTIME_V8(t) v8::Date::New(1000*static_cast(t)) +#define NODE_V8_UNIXTIME(v) ((double)((v)->IntegerValue())/1000.0); + #define NODE_DEFINE_CONSTANT(target, constant) \ (target)->Set(v8::String::NewSymbol(#constant), \ v8::Integer::New(constant)) diff --git a/src/timer.cc b/src/timer.cc index 6572883e2e..e24a52a205 100644 --- a/src/timer.cc +++ b/src/timer.cc @@ -51,7 +51,7 @@ Timer::RepeatSetter (Local property, Local value, const AccessorI assert(timer); assert(property == REPEAT_SYMBOL); - timer->watcher_.repeat = (double)(value->IntegerValue()) / 1000; + timer->watcher_.repeat = NODE_V8_UNIXTIME(value); } void @@ -91,8 +91,8 @@ Timer::Start (const Arguments& args) if (args.Length() != 2) return ThrowException(String::New("Bad arguments")); - ev_tstamp after = (double)(args[0]->IntegerValue()) / 1000.0; - ev_tstamp repeat = (double)(args[1]->IntegerValue()) / 1000.0; + ev_tstamp after = NODE_V8_UNIXTIME(args[0]); + ev_tstamp repeat = NODE_V8_UNIXTIME(args[1]); ev_timer_init(&timer->watcher_, Timer::OnTimeout, after, repeat); timer->watcher_.data = timer;