From 8bd23b5da10fb7ec08a7da6ac6c38ffcdc0d7f0f Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Sun, 30 Sep 2018 12:48:34 -0400 Subject: [PATCH] src: deprecate V8 date conversion helpers These helpers provide no benefit over the existing V8 API, and at least one of them fetches the current `Isolate` through `Isolate::GetCurrent()` (which should be avoided). --- src/node.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/node.h b/src/node.h index d9b070d14ad469..62ac999af19572 100644 --- a/src/node.h +++ b/src/node.h @@ -303,9 +303,16 @@ NODE_EXTERN void RunAtExit(Environment* env); NODE_EXTERN struct uv_loop_s* GetCurrentEventLoop(v8::Isolate* isolate); /* Converts a unixtime to V8 Date */ -#define NODE_UNIXTIME_V8(t) v8::Date::New(v8::Isolate::GetCurrent(), \ - 1000 * static_cast(t)) -#define NODE_V8_UNIXTIME(v) (static_cast((v)->NumberValue())/1000.0); +NODE_DEPRECATED("Use v8::Date::New() directly", + inline v8::Local NODE_UNIXTIME_V8(double time) { + return v8::Date::New(v8::Isolate::GetCurrent(), 1000 * time); +}) +#define NODE_UNIXTIME_V8 node::NODE_UNIXTIME_V8 +NODE_DEPRECATED("Use v8::Date::ValueOf() directly", + inline double NODE_V8_UNIXTIME(v8::Local date) { + return date->ValueOf() / 1000; +}) +#define NODE_V8_UNIXTIME node::NODE_V8_UNIXTIME #define NODE_DEFINE_CONSTANT(target, constant) \ do { \