@@ -243,6 +243,7 @@ typedef enum {
243243 napi_queue_full,
244244 napi_closing,
245245 napi_bigint_expected,
246+ napi_date_expected,
246247} napi_status;
247248```
248249If additional information is required upon an API returning a failed status,
@@ -1527,6 +1528,31 @@ This API allocates a `node::Buffer` object and initializes it with data copied
15271528from the passed-in buffer. While this is still a fully-supported data
15281529structure, in most cases using a `TypedArray` will suffice.
15291530
1531+ #### napi_create_date
1532+ <!-- YAML
1533+ added: REPLACEME
1534+ napiVersion: 4
1535+ -->
1536+
1537+ > Stability: 1 - Experimental
1538+
1539+ ```C
1540+ napi_status napi_create_date(napi_env env,
1541+ double time,
1542+ napi_value* result);
1543+ ```
1544+
1545+ - `[in] env`: The environment that the API is invoked under.
1546+ - `[in] time`: ECMAScript time value in milliseconds since 01 January, 1970 UTC.
1547+ - `[out] result`: A `napi_value` representing a JavaScript `Date`.
1548+
1549+ Returns `napi_ok` if the API succeeded.
1550+
1551+ This API allocates a JavaScript `Date` object.
1552+
1553+ JavaScript `Date` objects are described in
1554+ [Section 20.3][] of the ECMAScript Language Specification.
1555+
15301556#### napi_create_external
15311557<!-- YAML
15321558added: v8.0.0
@@ -2147,6 +2173,31 @@ Returns `napi_ok` if the API succeeded.
21472173
21482174This API returns various properties of a `DataView`.
21492175
2176+ #### napi_get_date_value
2177+ <!-- YAML
2178+ added: REPLACEME
2179+ napiVersion: 4
2180+ -->
2181+
2182+ > Stability: 1 - Experimental
2183+
2184+ ```C
2185+ napi_status napi_get_date_value(napi_env env,
2186+ napi_value value,
2187+ double* result)
2188+ ```
2189+
2190+ - `[in] env`: The environment that the API is invoked under.
2191+ - `[in] value`: `napi_value` representing a JavaScript `Date`.
2192+ - `[out] result`: Time value as a `double` represented as milliseconds
2193+ since midnight at the beginning of 01 January, 1970 UTC.
2194+
2195+ Returns `napi_ok` if the API succeeded. If a non-date `napi_value` is passed
2196+ in it returns `napi_date_expected`.
2197+
2198+ This API returns the C double primitive of time value for the given JavaScript
2199+ `Date`.
2200+
21502201#### napi_get_value_bool
21512202<!-- YAML
21522203added: v8.0.0
@@ -2731,6 +2782,27 @@ Returns `napi_ok` if the API succeeded.
27312782
27322783This API checks if the `Object` passed in is a buffer.
27332784
2785+ ### napi_is_date
2786+ <!-- YAML
2787+ added: REPLACEME
2788+ napiVersion: 4
2789+ -->
2790+
2791+ > Stability: 1 - Experimental
2792+
2793+ ```C
2794+ napi_status napi_is_date(napi_env env, napi_value value, bool* result)
2795+ ```
2796+
2797+ - `[in] env`: The environment that the API is invoked under.
2798+ - `[in] value`: The JavaScript value to check.
2799+ - `[out] result`: Whether the given `napi_value` represents a JavaScript `Date`
2800+ object.
2801+
2802+ Returns `napi_ok` if the API succeeded.
2803+
2804+ This API checks if the `Object` passed in is a date.
2805+
27342806### napi_is_error
27352807<!-- YAML
27362808added: v8.0.0
@@ -4712,6 +4784,7 @@ This API may only be called from the main thread.
47124784[Object Lifetime Management]: #n_api_object_lifetime_management
47134785[Object Wrap]: #n_api_object_wrap
47144786[Section 12.5.5]: https://tc39.github.io/ecma262/#sec-typeof-operator
4787+ [Section 20.3]: https://tc39.github.io/ecma262/#sec-date-objects
47154788[Section 22.1]: https://tc39.github.io/ecma262/#sec-array-objects
47164789[Section 22.2]: https://tc39.github.io/ecma262/#sec-typedarray-objects
47174790[Section 24.1]: https://tc39.github.io/ecma262/#sec-arraybuffer-objects
0 commit comments