From 4635ed7fdeef93c011d06ecbfa0030d3c0e1f9d8 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Thu, 11 Mar 2010 12:40:19 -0800 Subject: [PATCH] Add process.now Faster way to find out current time. --- src/node.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/node.cc b/src/node.cc index 8095ea63cd..b625803a3d 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1,6 +1,8 @@ // Copyright 2009 Ryan Dahl #include +#include + #include #include #include @@ -533,6 +535,13 @@ static Handle SetUid(const Arguments& args) { return Undefined(); } +Handle +NowGetter (Local property, const AccessorInfo& info) +{ + HandleScope scope; + return scope.Close(Integer::New(ev_now(EV_DEFAULT_UC))); +} + v8::Handle Exit(const v8::Arguments& args) { HandleScope scope; @@ -1003,6 +1012,8 @@ static void Load(int argc, char *argv[]) { Local process_template = FunctionTemplate::New(); node::EventEmitter::Initialize(process_template); + process_template->InstanceTemplate()->SetAccessor(String::NewSymbol("now"), NowGetter, NULL); + process = Persistent::New(process_template->GetFunction()->NewInstance()); // Add a reference to the global object