pub struct DateTime { /* private fields */ }Expand description
Default is the Unix epoch.
Implementations§
Source§impl DateTime
impl DateTime
pub const UNIX_EPOCH: DateTime
pub fn now() -> Self
pub const fn from_unix_micros(micros: i64) -> Self
pub const fn from_unix_seconds(secs: i64) -> Self
pub const fn unix_micros(&self) -> i64
pub const fn unix_seconds(&self) -> i64
pub fn add_seconds(&self, secs: i64) -> Self
Sourcepub fn from_utc_fields(
year: i64,
month: u32,
day: u32,
hour: u32,
min: u32,
sec: u32,
micros: u32,
) -> Option<Self>
pub fn from_utc_fields( year: i64, month: u32, day: u32, hour: u32, min: u32, sec: u32, micros: u32, ) -> Option<Self>
Builds a date-time from UTC calendar fields. Returns None on out-of-range fields.
Sourcepub fn to_utc_fields(&self) -> (i64, u32, u32, u32, u32, u32, u32)
pub fn to_utc_fields(&self) -> (i64, u32, u32, u32, u32, u32, u32)
Returns (year, month, day, hour, minute, second, microsecond) in UTC.
pub fn parse(s: &str) -> Result<Self, ParseError>
Trait Implementations§
impl Copy for DateTime
Source§impl<'de> Deserialize<'de> for DateTime
impl<'de> Deserialize<'de> for DateTime
Source§fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
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
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum 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