Skip to content

Commit e9a0cff

Browse files
addaleaxtargos
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 eb87219 commit e9a0cff

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
@@ -309,9 +309,16 @@ NODE_EXTERN void RunAtExit(Environment* env);
309309
NODE_EXTERN struct uv_loop_s* GetCurrentEventLoop(v8::Isolate* isolate);
310310

311311
/* Converts a unixtime to V8 Date */
312-
#define NODE_UNIXTIME_V8(t) v8::Date::New(v8::Isolate::GetCurrent(), \
313-
1000 * static_cast<double>(t))
314-
#define NODE_V8_UNIXTIME(v) (static_cast<double>((v)->NumberValue())/1000.0);
312+
NODE_DEPRECATED("Use v8::Date::New() directly",
313+
inline v8::Local<v8::Value> NODE_UNIXTIME_V8(double time) {
314+
return v8::Date::New(v8::Isolate::GetCurrent(), 1000 * time);
315+
})
316+
#define NODE_UNIXTIME_V8 node::NODE_UNIXTIME_V8
317+
NODE_DEPRECATED("Use v8::Date::ValueOf() directly",
318+
inline double NODE_V8_UNIXTIME(v8::Local<v8::Date> date) {
319+
return date->ValueOf() / 1000;
320+
})
321+
#define NODE_V8_UNIXTIME node::NODE_V8_UNIXTIME
315322

316323
#define NODE_DEFINE_CONSTANT(target, constant) \
317324
do { \

0 commit comments

Comments
 (0)