Skip to content

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

Closed

Description

@cacharle

It would be nice to be able to create a Date from a std::chrono::system_clock::time_point

Here is my (not so great) implementation):

Napi::Value timePointToJsDate(Napi::Env env, std::chrono::system_clock::time_point tp)
{
    using namespace std::chrono;
    auto ms static_cast<double>(duration_cast<milliseconds>(tp.time_since_epoch()).count());
    return Date::New(env, ms);
}

Activity

  1. moved this from Need Triage to Todo in Node-API Team Projecton Jan 30, 2026
  2. legendecas commented on Jan 30, 2026

    @legendecas
    Member

    @cacharle thanks for the issue! Would you like to file a PR for this?

  3. cacharle commented on Jan 30, 2026

    @cacharle
    ContributorAuthor

    ye, sure thing :)

  4. moved this from Todo to Has PR in Node-API Team Projecton Feb 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions