1.5 KiB
1.5 KiB
Date
Napi::Date
class is a representation of the JavaScript
Date
object. The Napi::Date
class inherits its
behavior from Napi::Value
class (for more info see Napi::Value
)
Methods
Constructor
Creates a new empty instance of a Napi::Date
object.
::Date::Date(); Napi
Creates a new non-empty instance of a
Napi::Date
object.
::Date::Date(napi_env env, napi_value value); Napi
[in] env
: The environment in which to construct theNapi::Date
object.[in] value
: Thenapi_value
which is a handle for a JavaScriptDate
.
New
Creates a new instance of a Napi::Date
object.
static Napi::Date Napi::Date::New(Napi::Env env, double value);
[in] env
: The environment in which to construct theNapi::Date
object.[in] value
: The time value the JavaScriptDate
will contain represented as the number of milliseconds since 1 January 1970 00:00:00 UTC.
Returns a new instance of Napi::Date
object.
ValueOf
double Napi::Date::ValueOf() const;
Returns the time value as double
primitive represented
as the number of milliseconds since 1 January 1970 00:00:00 UTC.
Operators
operator double
Converts a Napi::Date
value to a double
primitive.
::Date::operator double() const; Napi
Example
The following shows an example of casting a Napi::Date
value to a double
primitive.
double operatorVal = Napi::Date::New(Env(), 0); // Napi::Date to double
// or
auto instanceVal = info[0].As<Napi::Date>().ValueOf();