Skip to content

Commit

Permalink
src: deprecate V8 date conversion helpers
Browse files Browse the repository at this point in the history
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).

PR-URL: #23179
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
addaleax authored and targos committed Oct 4, 2018
1 parent eb87219 commit e9a0cff
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,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<double>(t))
#define NODE_V8_UNIXTIME(v) (static_cast<double>((v)->NumberValue())/1000.0);
NODE_DEPRECATED("Use v8::Date::New() directly",
inline v8::Local<v8::Value> 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<v8::Date> date) {
return date->ValueOf() / 1000;
})
#define NODE_V8_UNIXTIME node::NODE_V8_UNIXTIME

#define NODE_DEFINE_CONSTANT(target, constant) \
do { \
Expand Down

0 comments on commit e9a0cff

Please sign in to comment.