File tree Expand file tree Collapse file tree 3 files changed +16
-0
lines changed
Expand file tree Collapse file tree 3 files changed +16
-0
lines changed Original file line number Diff line number Diff line change 1919#endif // NAPI_HAS_THREADS
2020#include < string>
2121#include < vector>
22+ #if __cplusplus >= 201103L
23+ #include < chrono>
24+ #endif
2225
2326// VS2015 RTM has bugs with constexpr, so require min of VS2015 Update 3 (known
2427// good version)
Original file line number Diff line number Diff line change 1+ #if __cplusplus >= 201103L
2+ #include < chrono>
3+ #endif
4+
15#include " napi.h"
26
37using namespace Napi ;
@@ -11,6 +15,13 @@ Value CreateDate(const CallbackInfo& info) {
1115 return Date::New (info.Env (), input);
1216}
1317
18+ #if __cplusplus >= 201103L
19+ Value CreateDateFromTimePoint (const CallbackInfo& info) {
20+ auto input = std::chrono::system_clock::time_point{};
21+ return Date::New (info.Env (), input);
22+ }
23+ #endif
24+
1425Value IsDate (const CallbackInfo& info) {
1526 Date input = info[0 ].As <Date>();
1627
@@ -35,6 +46,7 @@ Value OperatorValue(const CallbackInfo& info) {
3546Object InitDate (Env env) {
3647 Object exports = Object::New (env);
3748 exports[" CreateDate" ] = Function::New (env, CreateDate);
49+ exports[" CreateDateFromTimePoint" ] = Function::New (env, CreateDate);
3850 exports[" IsDate" ] = Function::New (env, IsDate);
3951 exports[" ValueOf" ] = Function::New (env, ValueOf);
4052 exports[" OperatorValue" ] = Function::New (env, OperatorValue);
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ function test (binding) {
1212 OperatorValue
1313 } = binding . date ;
1414 assert . deepStrictEqual ( CreateDate ( 0 ) , new Date ( 0 ) ) ;
15+ assert . deepStrictEqual ( CreateDateFromTimePoint ( ) , new Date ( 0 ) ) ;
1516 assert . strictEqual ( IsDate ( new Date ( 0 ) ) , true ) ;
1617 assert . strictEqual ( ValueOf ( new Date ( 42 ) ) , 42 ) ;
1718 assert . strictEqual ( OperatorValue ( new Date ( 42 ) ) , true ) ;
You can’t perform that action at this time.
0 commit comments