Struct chrono::Duration [−][src]
ISO 8601 time duration with nanosecond precision. This also allows for the negative duration; see individual methods for details.
Implementations
impl Duration
[src][−]
pub fn weeks(weeks: i64) -> Duration
[src][−]
Makes a new Duration
with given number of weeks.
Equivalent to Duration::seconds(weeks * 7 * 24 * 60 * 60)
with overflow checks.
Panics when the duration is out of bounds.
pub fn days(days: i64) -> Duration
[src][−]
Makes a new Duration
with given number of days.
Equivalent to Duration::seconds(days * 24 * 60 * 60)
with overflow checks.
Panics when the duration is out of bounds.
pub fn hours(hours: i64) -> Duration
[src][−]
Makes a new Duration
with given number of hours.
Equivalent to Duration::seconds(hours * 60 * 60)
with overflow checks.
Panics when the duration is out of bounds.
pub fn minutes(minutes: i64) -> Duration
[src][−]
Makes a new Duration
with given number of minutes.
Equivalent to Duration::seconds(minutes * 60)
with overflow checks.
Panics when the duration is out of bounds.
pub fn seconds(seconds: i64) -> Duration
[src][−]
Makes a new Duration
with given number of seconds.
Panics when the duration is more than i64::MAX
milliseconds
or less than i64::MIN
milliseconds.
pub fn milliseconds(milliseconds: i64) -> Duration
[src][−]
Makes a new Duration
with given number of milliseconds.
pub fn microseconds(microseconds: i64) -> Duration
[src][−]
Makes a new Duration
with given number of microseconds.
pub fn nanoseconds(nanos: i64) -> Duration
[src][−]
Makes a new Duration
with given number of nanoseconds.
pub fn span<F>(f: F) -> Duration where
F: FnOnce(),
[src][−]
F: FnOnce(),
Runs a closure, returning the duration of time it took to run the closure.
pub fn num_weeks(&self) -> i64
[src][−]
Returns the total number of whole weeks in the duration.
pub fn num_days(&self) -> i64
[src][−]
Returns the total number of whole days in the duration.
pub fn num_hours(&self) -> i64
[src][−]
Returns the total number of whole hours in the duration.
pub fn num_minutes(&self) -> i64
[src][−]
Returns the total number of whole minutes in the duration.
pub fn num_seconds(&self) -> i64
[src][−]
Returns the total number of whole seconds in the duration.
pub fn num_milliseconds(&self) -> i64
[src][−]
Returns the total number of whole milliseconds in the duration,
pub fn num_microseconds(&self) -> Option<i64>
[src][−]
Returns the total number of whole microseconds in the duration,
or None
on overflow (exceeding 263 microseconds in either direction).
pub fn num_nanoseconds(&self) -> Option<i64>
[src][−]
Returns the total number of whole nanoseconds in the duration,
or None
on overflow (exceeding 263 nanoseconds in either direction).
pub fn checked_add(&self, rhs: &Duration) -> Option<Duration>
[src][−]
Add two durations, returning None
if overflow occurred.
pub fn checked_sub(&self, rhs: &Duration) -> Option<Duration>
[src][−]
Subtract two durations, returning None
if overflow occurred.
pub fn min_value() -> Duration
[src][−]
The minimum possible Duration
: i64::MIN
milliseconds.
pub fn max_value() -> Duration
[src][−]
The maximum possible Duration
: i64::MAX
milliseconds.
pub fn zero() -> Duration
[src][−]
A duration where the stored seconds and nanoseconds are equal to zero.
pub fn is_zero(&self) -> bool
[src][−]
Returns true
if the duration equals Duration::zero()
.
pub fn from_std(duration: Duration) -> Result<Duration, OutOfRangeError>
[src][−]
Creates a time::Duration
object from std::time::Duration
This function errors when original duration is larger than the maximum value supported for this type.
pub fn to_std(&self) -> Result<Duration, OutOfRangeError>
[src][−]
Creates a std::time::Duration
object from time::Duration
This function errors when duration is less than zero. As standard library implementation is limited to non-negative values.
Trait Implementations
impl Add<Duration> for Duration
[src][+]
impl Add<Duration> for NaiveDate
[src][+]
impl Add<Duration> for NaiveDateTime
[src][+]
type Output = NaiveDateTime
fn add(self, rhs: OldDuration) -> NaiveDateTime
[src][−]
impl Add<Duration> for NaiveTime
[src][+]
impl<Tz: TimeZone> Add<Duration> for Date<Tz>
[src][+]
impl<Tz: TimeZone> Add<Duration> for DateTime<Tz>
[src][+]
impl AddAssign<Duration> for NaiveDate
[src][+]
impl AddAssign<Duration> for NaiveDateTime
[src][+]
impl AddAssign<Duration> for NaiveTime
[src][+]
impl Clone for Duration
[src][+]
impl Copy for Duration
[src]
impl Debug for Duration
[src][+]
impl Display for Duration
[src][+]
impl Div<i32> for Duration
[src][+]
impl Eq for Duration
[src]
impl Hash for Duration
[src][+]
impl Mul<i32> for Duration
[src][+]
impl Neg for Duration
[src][+]
impl Ord for Duration
[src][+]
impl PartialEq<Duration> for Duration
[src][+]
impl PartialOrd<Duration> for Duration
[src][+]
impl StructuralEq for Duration
[src]
impl StructuralPartialEq for Duration
[src]
impl Sub<Duration> for Duration
[src][+]
impl Sub<Duration> for NaiveDate
[src][+]
impl Sub<Duration> for NaiveDateTime
[src][+]
type Output = NaiveDateTime
fn sub(self, rhs: OldDuration) -> NaiveDateTime
[src][−]
impl Sub<Duration> for NaiveTime
[src][+]
impl<Tz: TimeZone> Sub<Duration> for Date<Tz>
[src][+]
impl<Tz: TimeZone> Sub<Duration> for DateTime<Tz>
[src][+]
impl SubAssign<Duration> for NaiveDate
[src][+]
impl SubAssign<Duration> for NaiveDateTime
[src][+]
impl SubAssign<Duration> for NaiveTime
[src][+]
Auto Trait Implementations
impl RefUnwindSafe for Duration
impl Send for Duration
impl Sync for Duration
impl Unpin for Duration
impl UnwindSafe for Duration
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src][+]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src][+]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src][+]
T: ?Sized,
impl<T> From<T> for T
[src][+]
impl<T, U> Into<U> for T where
U: From<T>,
[src][+]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src][+]
T: Clone,
impl<T> ToString for T where
T: Display + ?Sized,
[src][+]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src][+]
U: Into<T>,
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src][+]
U: TryFrom<T>,