@@ -184,6 +184,7 @@ typedef enum {
184
184
napi_queue_full,
185
185
napi_closing,
186
186
napi_bigint_expected,
187
+ napi_date_expected,
187
188
} napi_status;
188
189
```
189
190
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
1468
1469
from the passed-in buffer. While this is still a fully-supported data
1469
1470
structure, in most cases using a `TypedArray` will suffice.
1470
1471
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
+
1471
1497
#### napi_create_external
1472
1498
<!-- YAML
1473
1499
added: v8.0.0
@@ -2088,6 +2114,31 @@ Returns `napi_ok` if the API succeeded.
2088
2114
2089
2115
This API returns various properties of a `DataView`.
2090
2116
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
+
2091
2142
#### napi_get_value_bool
2092
2143
<!-- YAML
2093
2144
added: v8.0.0
@@ -2672,6 +2723,27 @@ Returns `napi_ok` if the API succeeded.
2672
2723
2673
2724
This API checks if the `Object` passed in is a buffer.
2674
2725
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
+
2675
2747
### napi_is_error
2676
2748
<!-- YAML
2677
2749
added: v8.0.0
@@ -4653,6 +4725,7 @@ This API may only be called from the main thread.
4653
4725
[Object Lifetime Management]: #n_api_object_lifetime_management
4654
4726
[Object Wrap]: #n_api_object_wrap
4655
4727
[Section 12.5.5]: https://tc39.github.io/ecma262/#sec-typeof-operator
4728
+ [Section 20.3]: https://tc39.github.io/ecma262/#sec-date-objects
4656
4729
[Section 22.1]: https://tc39.github.io/ecma262/#sec-array-objects
4657
4730
[Section 22.2]: https://tc39.github.io/ecma262/#sec-typedarray-objects
4658
4731
[Section 24.1]: https://tc39.github.io/ecma262/#sec-arraybuffer-objects
0 commit comments