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 {
|
2020-11-25 18:42:14 +09:00
|
|
|
#[inline]
|
2020-10-10 15:50:35 +09:00
|
|
|
pub fn value_of(&self) -> Result<f64> {
|
|
|
|
let mut timestamp: f64 = 0.0;
|
2020-11-25 18:42:14 +09:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|