Skip to content

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

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

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