Skip to content

Add Date::New overload for a std::chrono::system_clock::time_point#1705

Open
cacharle wants to merge 2 commits intonodejs:mainfrom
cacharle:add-date-new-time-point
Open

Add Date::New overload for a std::chrono::system_clock::time_point#1705
cacharle wants to merge 2 commits intonodejs:mainfrom
cacharle:add-date-new-time-point

Conversation

@cacharle
Copy link

Fixes #1704

@cacharle
Copy link
Author

Not too sure how to add a unit test for this since it seems they're being done in JS

@cacharle cacharle marked this pull request as ready for review February 1, 2026 17:11
@legendecas
Copy link
Member

@cacharle
Copy link
Author

cacharle commented Feb 3, 2026

Added some basic unit test, npm test takes too long to compile, how can I compile in parallel?

@legendecas legendecas moved this from Need Triage to In Progress in Node-API Team Project Feb 13, 2026
Object InitDate(Env env) {
Object exports = Object::New(env);
exports["CreateDate"] = Function::New(env, CreateDate);
exports["CreateDateFromTimePoint"] = Function::New(env, CreateDate);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
exports["CreateDateFromTimePoint"] = Function::New(env, CreateDate);
exports["CreateDateFromTimePoint"] = Function::New(env, CreateDateFromTimePoint);

OperatorValue
} = binding.date;
assert.deepStrictEqual(CreateDate(0), new Date(0));
assert.deepStrictEqual(CreateDateFromTimePoint(), new Date(0));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CreateDateFromTimePoint needs to be destructed in line 8 above.

Copy link
Contributor

@KevinEady KevinEady left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guards for c++11 can be removed.

Comment on lines +1 to +4
#if __cplusplus >= 201103L
#include <chrono>
#endif

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

Add Date::New for std::chrono::system_clock::time_point

3 participants