Skip to content

Commit ac54469

Browse files
addaleaxdanbev
authored andcommitted
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). PR-URL: #23179 Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent cd40d7a commit ac54469

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/node.h

+10-3
Original file line numberDiff line numberDiff line change
@@ -289,9 +289,16 @@ NODE_EXTERN void RunAtExit(Environment* env);
289289
NODE_EXTERN struct uv_loop_s* GetCurrentEventLoop(v8::Isolate* isolate);
290290

291291
/* Converts a unixtime to V8 Date */
292-
#define NODE_UNIXTIME_V8(t) v8::Date::New(v8::Isolate::GetCurrent(), \
293-
1000 * static_cast<double>(t))
294-
#define NODE_V8_UNIXTIME(v) (static_cast<double>((v)->NumberValue())/1000.0);
292+
NODE_DEPRECATED("Use v8::Date::New() directly",
293+
inline v8::Local<v8::Value> NODE_UNIXTIME_V8(double time) {
294+
return v8::Date::New(v8::Isolate::GetCurrent(), 1000 * time);
295+
})
296+
#define NODE_UNIXTIME_V8 node::NODE_UNIXTIME_V8
297+
NODE_DEPRECATED("Use v8::Date::ValueOf() directly",
298+
inline double NODE_V8_UNIXTIME(v8::Local<v8::Date> date) {
299+
return date->ValueOf() / 1000;
300+
})
301+
#define NODE_V8_UNIXTIME node::NODE_V8_UNIXTIME
295302

296303
#define NODE_DEFINE_CONSTANT(target, constant) \
297304
do { \

0 commit comments

Comments
 (0)