napi_get_date_value


napi_status napi_get_date_value(napi_env env,
                                napi_value value,
                                double* result) 
  • [in] env:调用 API 的环境。

    ¥[in] env: The environment that the API is invoked under.

  • [in] valuenapi_value 代表一个 JavaScript Date

    ¥[in] value: napi_value representing a JavaScript Date.

  • [out] result:作为 double 的时间值表示为自 1970 年 1 月 1 日 UTC 午夜以来的毫秒数。

    ¥[out] result: Time value as a double represented as milliseconds since midnight at the beginning of 01 January, 1970 UTC.

此 API 不遵守闰秒;它们被忽略,因为 ECMAScript 符合 POSIX 时间规范。

¥This API does not observe leap seconds; they are ignored, as ECMAScript aligns with POSIX time specification.

如果 API 成功,则返回 napi_ok。如果传入非日期 napi_value,则返回 napi_date_expected

¥Returns napi_ok if the API succeeded. If a non-date napi_value is passed in it returns napi_date_expected.

此 API 返回给定 JavaScript Date 的时间值的 C 双精度基础类型。

¥This API returns the C double primitive of time value for the given JavaScript Date.