pub struct DateTime(_);Expand description
Representation of a date and time in the local time zone.
Implementations
sourceimpl DateTime
impl DateTime
sourcepub fn new(date: (u32, u32, u32), time: (u32, u32, u32)) -> Result<Self>
pub fn new(date: (u32, u32, u32), time: (u32, u32, u32)) -> Result<Self>
Create a DateTime from two tuples, one representing the date (year, month, day) and
the second representing the time (hour, minute, second).
Errors
Return an Error::InvalidDate if the values in the tuples are not appropriate for the
data types.
sourcepub fn timestamp(&self) -> i64
pub fn timestamp(&self) -> i64
Return the epoch time representing the current value of the DateTime object.
sourcepub fn second_offset(&self) -> u32
pub fn second_offset(&self) -> u32
Return the number of seconds after the hour.
sourcepub fn sub(&self, rhs: &Self) -> Result<Duration>
pub fn sub(&self, rhs: &Self) -> Result<Duration>
Return the Duration as a Result resulting from subtracting the rhs from the
object.
Errors
Return an Error::EntryOrder if the rhs is larger than the DateTime.
sourcepub fn add(&self, rhs: Duration) -> Result<Self>
pub fn add(&self, rhs: Duration) -> Result<Self>
Return a DateTime as a Result resulting from adding the rhs Duration to the
object.
Errors
Return an Error::InvalidDate if adding the duration results in a bad date.
sourcepub fn seconds(seconds: u64) -> Duration
pub fn seconds(seconds: u64) -> Duration
Return a Duration lasting the supplied number of minutes.
Trait Implementations
sourceimpl Ord for DateTime
impl Ord for DateTime
sourceimpl PartialOrd<DateTime> for DateTime
impl PartialOrd<DateTime> for DateTime
sourcefn partial_cmp(&self, other: &DateTime) -> Option<Ordering>
fn partial_cmp(&self, other: &DateTime) -> Option<Ordering>
This method returns an ordering between self and other values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self and other) and is used by the <=
operator. Read more
sourceimpl TryFrom<&str> for DateTime
impl TryFrom<&str> for DateTime
sourcefn try_from(datetime: &str) -> Result<Self>
fn try_from(datetime: &str) -> Result<Self>
Parse the DateTime out of a string, returning a Result
Errors
If the datetime is not formatted as ‘YYYY-MM-DD HH:MM:SS’, returns an
Error::InvalidDate. Also if the datetime cannot be converted into a DateTime,
returns an Error::InvalidDate.
impl Copy for DateTime
impl Eq for DateTime
impl StructuralEq for DateTime
impl StructuralPartialEq for DateTime
Auto Trait Implementations
impl RefUnwindSafe for DateTime
impl Send for DateTime
impl Sync for DateTime
impl Unpin for DateTime
impl UnwindSafe for DateTime
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more