napi-rs/napi/src/js_values/date.rs

14 lines
322 B
Rust
Raw Normal View History

2020-10-10 15:50:35 +09:00
use super::check_status;
use crate::{sys, Result, Value};
pub struct JsDate(pub(crate) Value);
impl JsDate {
#[inline]
2020-10-10 15:50:35 +09:00
pub fn value_of(&self) -> Result<f64> {
let mut timestamp: f64 = 0.0;
check_status!(unsafe { sys::napi_get_date_value(self.0.env, self.0.value, &mut timestamp) })?;
2020-10-10 15:50:35 +09:00
Ok(timestamp)
}
}