@@ -184,6 +184,7 @@ typedef enum {
184184 napi_queue_full,
185185 napi_closing,
186186 napi_bigint_expected,
187+ napi_date_expected,
187188} napi_status;
188189```
189190If 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
14681469from the passed-in buffer. While this is still a fully-supported data
14691470structure, in most cases using a `TypedArray` will suffice.
14701471
1472+ #### napi_create_date
1473+ <!-- YAML
1474+ added: REPLACEME
1475+ napiVersion: 4
1476+ -->
1477+
1478+ > Stability: 1 - Experimental
1479+
1480+ ```C
1481+ napi_status napi_create_date(napi_env env,
1482+ double time,
1483+ napi_value* result);
1484+ ```
1485+
1486+ - `[in] env`: The environment that the API is invoked under.
1487+ - `[in] time`: ECMAScript time value in milliseconds since 01 January, 1970 UTC.
1488+ - `[out] result`: A `napi_value` representing a JavaScript `Date`.
1489+
1490+ Returns `napi_ok` if the API succeeded.
1491+
1492+ This API allocates a JavaScript `Date` object.
1493+
1494+ JavaScript `Date` objects are described in
1495+ [Section 20.3][] of the ECMAScript Language Specification.
1496+
14711497#### napi_create_external
14721498<!-- YAML
14731499added: v8.0.0
@@ -2088,6 +2114,31 @@ Returns `napi_ok` if the API succeeded.
20882114
20892115This API returns various properties of a `DataView`.
20902116
2117+ #### napi_get_date_value
2118+ <!-- YAML
2119+ added: REPLACEME
2120+ napiVersion: 4
2121+ -->
2122+
2123+ > Stability: 1 - Experimental
2124+
2125+ ```C
2126+ napi_status napi_get_date_value(napi_env env,
2127+ napi_value value,
2128+ double* result)
2129+ ```
2130+
2131+ - `[in] env`: The environment that the API is invoked under.
2132+ - `[in] value`: `napi_value` representing a JavaScript `Date`.
2133+ - `[out] result`: Time value as a `double` represented as milliseconds
2134+ since midnight at the beginning of 01 January, 1970 UTC.
2135+
2136+ Returns `napi_ok` if the API succeeded. If a non-date `napi_value` is passed
2137+ in it returns `napi_date_expected`.
2138+
2139+ This API returns the C double primitive of time value for the given JavaScript
2140+ `Date`.
2141+
20912142#### napi_get_value_bool
20922143<!-- YAML
20932144added: v8.0.0
@@ -2672,6 +2723,27 @@ Returns `napi_ok` if the API succeeded.
26722723
26732724This API checks if the `Object` passed in is a buffer.
26742725
2726+ ### napi_is_date
2727+ <!-- YAML
2728+ added: REPLACEME
2729+ napiVersion: 4
2730+ -->
2731+
2732+ > Stability: 1 - Experimental
2733+
2734+ ```C
2735+ napi_status napi_is_date(napi_env env, napi_value value, bool* result)
2736+ ```
2737+
2738+ - `[in] env`: The environment that the API is invoked under.
2739+ - `[in] value`: The JavaScript value to check.
2740+ - `[out] result`: Whether the given `napi_value` represents a JavaScript `Date`
2741+ object.
2742+
2743+ Returns `napi_ok` if the API succeeded.
2744+
2745+ This API checks if the `Object` passed in is a date.
2746+
26752747### napi_is_error
26762748<!-- YAML
26772749added: v8.0.0
@@ -4653,6 +4725,7 @@ This API may only be called from the main thread.
46534725[Object Lifetime Management]: #n_api_object_lifetime_management
46544726[Object Wrap]: #n_api_object_wrap
46554727[Section 12.5.5]: https://tc39.github.io/ecma262/#sec-typeof-operator
4728+ [Section 20.3]: https://tc39.github.io/ecma262/#sec-date-objects
46564729[Section 22.1]: https://tc39.github.io/ecma262/#sec-array-objects
46574730[Section 22.2]: https://tc39.github.io/ecma262/#sec-typedarray-objects
46584731[Section 24.1]: https://tc39.github.io/ecma262/#sec-arraybuffer-objects
0 commit comments