pub struct DateTime {
pub days: i64,
pub seconds: u32,
}Expand description
A calendar date with an optional time of day, without a time zone.
Fields§
§days: i64Days since 1970-01-01 (negative before).
seconds: u32Seconds since midnight.
Implementations§
Source§impl DateTime
impl DateTime
Sourcepub fn from_ymd(year: i32, month: u32, day: u32) -> Option<Self>
pub fn from_ymd(year: i32, month: u32, day: u32) -> Option<Self>
The date year-month-day at midnight, or None if it does not exist.
Sourcepub fn parse(s: &str) -> Option<Self>
pub fn parse(s: &str) -> Option<Self>
Parses ISO 8601 dates: 2026-11-01, 2026-11-01T14:30, 2026-11-01 14:30:05
(a trailing zone such as Z or -03:00 is accepted and ignored).
Sourcepub fn now() -> Self
pub fn now() -> Self
The current local date and time in the browser; the current UTC date and time elsewhere (the standard library has no time zones).
Sourcepub fn add_months(self, n: i64) -> Self
pub fn add_months(self, n: i64) -> Self
The same day n months later, clamped to the month’s last day.
Trait Implementations§
impl Copy for DateTime
impl Eq for DateTime
Source§impl Ord for DateTime
impl Ord for DateTime
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialOrd for DateTime
impl PartialOrd for DateTime
impl StructuralPartialEq for DateTime
Auto Trait Implementations§
impl Freeze for DateTime
impl RefUnwindSafe for DateTime
impl Send for DateTime
impl Sync for DateTime
impl Unpin for DateTime
impl UnsafeUnpin for DateTime
impl UnwindSafe for DateTime
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