diff --git a/doc/api/n-api.md b/doc/api/n-api.md index db29ef20e36b78..c9bed390b11bac 100644 --- a/doc/api/n-api.md +++ b/doc/api/n-api.md @@ -184,6 +184,7 @@ typedef enum { napi_queue_full, napi_closing, napi_bigint_expected, + napi_date_expected, } napi_status; ``` If additional information is required upon an API returning a failed status, @@ -1468,6 +1469,31 @@ This API allocates a `node::Buffer` object and initializes it with data copied from the passed-in buffer. While this is still a fully-supported data structure, in most cases using a `TypedArray` will suffice. +#### napi_create_date + + +> Stability: 1 - Experimental + +```C +napi_status napi_create_date(napi_env env, + double time, + napi_value* result); +``` + +- `[in] env`: The environment that the API is invoked under. +- `[in] time`: ECMAScript time value in milliseconds since 01 January, 1970 UTC. +- `[out] result`: A `napi_value` representing a JavaScript `Date`. + +Returns `napi_ok` if the API succeeded. + +This API allocates a JavaScript `Date` object. + +JavaScript `Date` objects are described in +[Section 20.3][] of the ECMAScript Language Specification. + #### napi_create_external + +> Stability: 1 - Experimental + +```C +napi_status napi_get_date_value(napi_env env, + napi_value value, + double* result) +``` + +- `[in] env`: The environment that the API is invoked under. +- `[in] value`: `napi_value` representing a JavaScript `Date`. +- `[out] result`: Time value as a `double` represented as milliseconds +since midnight at the beginning of 01 January, 1970 UTC. + +Returns `napi_ok` if the API succeeded. If a non-date `napi_value` is passed +in it returns `napi_date_expected`. + +This API returns the C double primitive of time value for the given JavaScript +`Date`. + #### napi_get_value_bool + +> Stability: 1 - Experimental + +```C +napi_status napi_is_date(napi_env env, napi_value value, bool* result) +``` + +- `[in] env`: The environment that the API is invoked under. +- `[in] value`: The JavaScript value to check. +- `[out] result`: Whether the given `napi_value` represents a JavaScript `Date` +object. + +Returns `napi_ok` if the API succeeded. + +This API checks if the `Object` passed in is a date. + ### napi_is_error