Struct datetime::interval::TimeInterval
source · pub struct TimeInterval { /* private fields */ }
Expand description
An interval of time between two timestamps.
Implementations§
source§impl TimeInterval
impl TimeInterval
sourcepub const fn new(seconds: i64, nanos: u32) -> Self
pub const fn new(seconds: i64, nanos: u32) -> Self
Create a new time interval from seconds and nanoseconds.
sourcepub const fn seconds(&self) -> i64
pub const fn seconds(&self) -> i64
The number of seconds this interval represents.
Note that the nanoseconds value is always positive, even if seconds is negative. For example, an interval representing -2.5 seconds will be represented as -3 seconds and 500,000,000 nanos.
sourcepub const fn nanoseconds(&self) -> u32
pub const fn nanoseconds(&self) -> u32
The number of nanoseconds this interval represents.
Note that the nanoseconds value is always positive, even if seconds is negative. For example, an interval representing -2.5 seconds will be represented as -3 seconds and 500,000,000 nanos.
sourcepub const fn as_milliseconds(&self) -> i64
pub const fn as_milliseconds(&self) -> i64
The number of milliseconds this interval represents.
sourcepub const fn as_microseconds(&self) -> i64
pub const fn as_microseconds(&self) -> i64
The number of microseconds this interval represents.
sourcepub const fn as_nanoseconds(&self) -> i128
pub const fn as_nanoseconds(&self) -> i128
The number of nanoseconds this interval represents.
Trait Implementations§
source§impl Add<TimeInterval> for DateTime
impl Add<TimeInterval> for DateTime
source§impl Clone for TimeInterval
impl Clone for TimeInterval
source§fn clone(&self) -> TimeInterval
fn clone(&self) -> TimeInterval
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for TimeInterval
impl Debug for TimeInterval
source§impl Default for TimeInterval
impl Default for TimeInterval
source§fn default() -> TimeInterval
fn default() -> TimeInterval
Returns the “default value” for a type. Read more
source§impl Ord for TimeInterval
impl Ord for TimeInterval
source§fn cmp(&self, other: &TimeInterval) -> Ordering
fn cmp(&self, other: &TimeInterval) -> Ordering
1.21.0 · 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 PartialEq for TimeInterval
impl PartialEq for TimeInterval
source§fn eq(&self, other: &TimeInterval) -> bool
fn eq(&self, other: &TimeInterval) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for TimeInterval
impl PartialOrd for TimeInterval
source§fn partial_cmp(&self, other: &TimeInterval) -> Option<Ordering>
fn partial_cmp(&self, other: &TimeInterval) -> Option<Ordering>
1.0.0 · source§fn 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 moresource§impl Sub<TimeInterval> for DateTime
impl Sub<TimeInterval> for DateTime
impl Copy for TimeInterval
impl Eq for TimeInterval
impl StructuralPartialEq for TimeInterval
Auto Trait Implementations§
impl Freeze for TimeInterval
impl RefUnwindSafe for TimeInterval
impl Send for TimeInterval
impl Sync for TimeInterval
impl Unpin for TimeInterval
impl UnwindSafe for TimeInterval
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