#[non_exhaustive]
pub struct Duration { /* private fields */ }
Expand description

The native Rust implementation of Temporal.Duration.

Duration is made up of a DateDuration and TimeDuration as primarily defined by Abtract Operation 7.5.1-5.

Implementations§

source§

impl Duration

source

pub fn new( years: f64, months: f64, weeks: f64, days: f64, hours: f64, minutes: f64, seconds: f64, milliseconds: f64, microseconds: f64, nanoseconds: f64 ) -> TemporalResult<Self>

Creates a new validated Duration.

source

pub const fn partial() -> Self

Creates a partial Duration with all fields set to NaN.

source

pub fn from_date_duration(date: &DateDuration) -> Self

Creates a Duration from only a DateDuration.

source

pub fn from_day_and_time(day: f64, time: &TimeDuration) -> Self

Creates a Duration from a provided a day and a TimeDuration.

Note: TimeDuration records can store a day value to deal with overflow.

source

pub fn from_partial(partial: &Duration) -> TemporalResult<Self>

Creates a new valid Duration from a partial Duration.

source

pub fn is_time_within_range(&self) -> bool

Return if the Durations values are within their valid ranges.

source§

impl Duration

source

pub fn time(&self) -> &TimeDuration

Returns a reference to the inner TimeDuration

source

pub fn date(&self) -> &DateDuration

Returns a reference to the inner DateDuration

source

pub fn set_time_duration(&mut self, time: TimeDuration)

Set this DurationRecord’s TimeDuration.

source

pub fn set_years(&mut self, y: f64)

Set the value for years.

source

pub const fn years(&self) -> f64

Returns the years field of duration.

source

pub fn set_months(&mut self, mo: f64)

Set the value for months.

source

pub const fn months(&self) -> f64

Returns the months field of duration.

source

pub fn set_weeks(&mut self, w: f64)

Set the value for weeks.

source

pub const fn weeks(&self) -> f64

Returns the weeks field of duration.

source

pub fn set_days(&mut self, d: f64)

Set the value for days.

source

pub const fn days(&self) -> f64

Returns the weeks field of duration.

source

pub fn set_hours(&mut self, h: f64)

Set the value for hours.

source

pub const fn hours(&self) -> f64

Returns the hours field of duration.

source

pub fn set_minutes(&mut self, m: f64)

Set the value for minutes.

source

pub const fn minutes(&self) -> f64

Returns the hours field of duration.

source

pub fn set_seconds(&mut self, s: f64)

Set the value for seconds.

source

pub const fn seconds(&self) -> f64

Returns the seconds field of duration.

source

pub fn set_milliseconds(&mut self, ms: f64)

Set the value for milliseconds.

source

pub const fn milliseconds(&self) -> f64

Returns the hours field of duration.

source

pub fn set_microseconds(&mut self, mis: f64)

Set the value for microseconds.

source

pub const fn microseconds(&self) -> f64

Returns the microseconds field of duration.

source

pub fn set_nanoseconds(&mut self, ns: f64)

Set the value for nanoseconds.

source

pub const fn nanoseconds(&self) -> f64

Returns the nanoseconds field of duration.

source§

impl Duration

source

pub fn sign(&self) -> i32

Determines the sign for the current self.

source

pub fn is_zero(&self) -> bool

Returns whether the current Duration is zero.

Equivalant to Temporal.Duration.blank().

source

pub fn negated(&self) -> Self

Returns a negated Duration

source

pub fn abs(&self) -> Self

Returns the absolute value of Duration.

source

pub fn round<C: CalendarProtocol, Z: TzProtocol>( &self, increment: Option<f64>, smallest_unit: Option<TemporalUnit>, largest_unit: Option<TemporalUnit>, rounding_mode: Option<TemporalRoundingMode>, relative_to: &RelativeTo<'_, C, Z>, context: &mut C::Context ) -> TemporalResult<Self>

Rounds the current Duration.

Trait Implementations§

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 Default for Duration

source§

fn default() -> Duration

Returns the “default value” for a type. Read more
source§

impl From<TimeDuration> for Duration

source§

fn from(value: TimeDuration) -> Self

Converts to this type from the input type.
source§

impl FromStr for Duration

§

type Err = TemporalError

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 Copy for Duration

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

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 T
where 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, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
source§

impl<T> ErasedDestructor for T
where T: 'static,

source§

impl<T> MaybeSendSync for T