pub struct JsDate { /* private fields */ }Expand description
A JS Date: a millisecond time value, or None for an invalid date (JS NaN).
Deliberately not Ord: compare get_time() values, so NaN comparisons stay explicit.
Implementations§
Source§impl JsDate
impl JsDate
Sourcepub fn from_millis(ms: i64) -> JsDate
pub fn from_millis(ms: i64) -> JsDate
new Date(ms).
Sourcepub fn local(
year: i64,
month: i64,
day: i64,
hour: i64,
minute: i64,
second: i64,
ms: i64,
) -> JsDate
pub fn local( year: i64, month: i64, day: i64, hour: i64, minute: i64, second: i64, ms: i64, ) -> JsDate
new Date(y, m, d, h, mi, s, ms) (local time = UTC here). Like JS, years 0–99 mean 1900–1999.
Sourcepub fn utc(
year: i64,
month: i64,
day: i64,
hour: i64,
minute: i64,
second: i64,
ms: i64,
) -> JsDate
pub fn utc( year: i64, month: i64, day: i64, hour: i64, minute: i64, second: i64, ms: i64, ) -> JsDate
Date.UTC(...). Same as JsDate::local because the system time zone is UTC.
pub fn is_valid(&self) -> bool
pub fn get_full_year(&self) -> i64
pub fn get_date(&self) -> i64
pub fn get_hours(&self) -> i64
pub fn get_minutes(&self) -> i64
pub fn get_seconds(&self) -> i64
pub fn get_milliseconds(&self) -> i64
Sourcepub fn get_timezone_offset(&self) -> i64
pub fn get_timezone_offset(&self) -> i64
Always 0: the system time zone is UTC.
Sourcepub fn set_full_year(&mut self, year: i64)
pub fn set_full_year(&mut self, year: i64)
setFullYear(y). Like JS, an invalid date is treated as time 0 first.
Sourcepub fn set_month(&mut self, month: i64)
pub fn set_month(&mut self, month: i64)
setMonth(m) (0-based). Keeps the day of month, so Jan 31 + 1 month overflows into March.
pub fn set_hours(&mut self, hour: i64)
pub fn set_minutes(&mut self, minute: i64)
pub fn set_seconds(&mut self, second: i64)
pub fn set_milliseconds(&mut self, ms: i64)
Sourcepub fn to_iso_string(&self) -> Option<String>
pub fn to_iso_string(&self) -> Option<String>
toISOString(). None where JS would throw (invalid date).
Trait Implementations§
impl Copy for JsDate
impl Eq for JsDate
Source§impl From<JsDate> for ReferenceInput
impl From<JsDate> for ReferenceInput
impl StructuralPartialEq for JsDate
Auto Trait Implementations§
impl Forget for JsDate
impl Freeze for JsDate
impl RefUnwindSafe for JsDate
impl Send for JsDate
impl Sync for JsDate
impl Unpin for JsDate
impl UnsafeUnpin for JsDate
impl UnwindSafe for JsDate
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more