Skip to content

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

@cacharle

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);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Need Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions