pub struct Duration {
    pub year: f32,
    pub month: f32,
    pub day: f32,
    pub hour: f32,
    pub minute: f32,
    pub second: f32,
}

Fields§

§year: f32§month: f32§day: f32§hour: f32§minute: f32§second: f32

Implementations§

source§

impl Duration

source

pub fn to_chrono(&self) -> Option<ChronoDuration>

Convert Duration to chrono::Duration.

This method will return None is Duration contains year or month.

source

pub fn to_chrono_at_datetime<Tz: TimeZone>( &self, at: DateTime<Tz> ) -> ChronoDuration

Convert Duration to chrono::Duration at given datetime.

source§

impl Duration

source

pub fn new( year: f32, month: f32, day: f32, hour: f32, minute: f32, second: f32 ) -> Self

Create a new duration

source

pub fn num_years(&self) -> Option<f32>

Return number of years in the duration

This method will return None is Duration contains second, minute or hour.

source

pub fn num_months(&self) -> Option<f32>

Return number of months in the duration

This method will return None is Duration contains second, minute or hour.

source

pub fn num_weeks(&self) -> Option<f32>

Return number of weeks in the duration

This method will return None is Duration contains year or month.

source

pub fn num_days(&self) -> Option<f32>

Return number of days in the duration

This method will return None is Duration contains year or month.

source

pub fn num_hours(&self) -> Option<f32>

Return number of hours in the duration

This method will return None is Duration contains year or month.

source

pub fn num_minutes(&self) -> Option<f32>

Return number of minutes in the duration

This method will return None is Duration contains year or month.

source

pub fn num_seconds(&self) -> Option<f32>

Return number of seconds in the duration

This method will return None is Duration contains year or month.

source

pub fn to_std(&self) -> Option<StdDuration>

Convert duration to std::time::Duration.

This method will return None is Duration contains year or month.

See to know how to convert a Duration contains year or month.

source

pub fn parse(input: &str) -> Result<Duration, ParseDurationError>

Parse given string into Duration

Trait Implementations§

source§

impl<Tz: TimeZone> Add<Duration> for DateTime<Tz>

§

type Output = DateTime<Tz>

The resulting type after applying the + operator.
source§

fn add(self, rhs: Duration) -> Self

Performs the + operation. Read more
source§

impl Clone for Duration

source§

fn clone(&self) -> Duration

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Duration

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for Duration

source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for Duration

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl FromStr for Duration

§

type Err = ParseDurationError

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
source§

impl PartialEq<Duration> for Duration

source§

fn eq(&self, other: &Duration) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Duration

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Copy for Duration

source§

impl StructuralPartialEq for Duration

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,