@@ -243,6 +243,7 @@ typedef enum {
243
243
napi_queue_full,
244
244
napi_closing,
245
245
napi_bigint_expected,
246
+ napi_date_expected,
246
247
} napi_status;
247
248
```
248
249
If 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
1527
1528
from the passed-in buffer. While this is still a fully-supported data
1528
1529
structure, in most cases using a `TypedArray` will suffice.
1529
1530
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
+
1530
1556
#### napi_create_external
1531
1557
<!-- YAML
1532
1558
added: v8.0.0
@@ -2147,6 +2173,31 @@ Returns `napi_ok` if the API succeeded.
2147
2173
2148
2174
This API returns various properties of a `DataView`.
2149
2175
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
+
2150
2201
#### napi_get_value_bool
2151
2202
<!-- YAML
2152
2203
added: v8.0.0
@@ -2731,6 +2782,27 @@ Returns `napi_ok` if the API succeeded.
2731
2782
2732
2783
This API checks if the `Object` passed in is a buffer.
2733
2784
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
+
2734
2806
### napi_is_error
2735
2807
<!-- YAML
2736
2808
added: v8.0.0
@@ -4712,6 +4784,7 @@ This API may only be called from the main thread.
4712
4784
[Object Lifetime Management]: #n_api_object_lifetime_management
4713
4785
[Object Wrap]: #n_api_object_wrap
4714
4786
[Section 12.5.5]: https://tc39.github.io/ecma262/#sec-typeof-operator
4787
+ [Section 20.3]: https://tc39.github.io/ecma262/#sec-date-objects
4715
4788
[Section 22.1]: https://tc39.github.io/ecma262/#sec-array-objects
4716
4789
[Section 22.2]: https://tc39.github.io/ecma262/#sec-typedarray-objects
4717
4790
[Section 24.1]: https://tc39.github.io/ecma262/#sec-arraybuffer-objects
0 commit comments