#[non_exhaustive]
pub struct DateDuration { pub years: f64, pub months: f64, pub weeks: f64, pub days: f64, }
Expand description

DateDuration represents the date duration record of the Duration.

These fields are laid out in the Temporal Proposal as 64-bit floating point numbers.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§years: f64

DateDuration’s internal year value.

§months: f64

DateDuration’s internal month value.

§weeks: f64

DateDuration’s internal week value.

§days: f64

DateDuration’s internal day value.

Implementations§

source§

impl DateDuration

source

pub fn balance_relative<C: CalendarProtocol>( &self, largest_unit: TemporalUnit, smallest_unit: TemporalUnit, plain_relative_to: Option<&Date<C>>, context: &mut C::Context ) -> TemporalResult<DateDuration>

7.5.38 BalanceDateDurationRelative ( years, months, weeks, days, largestUnit, smallestUnit, plainRelativeTo, calendarRec )

source§

impl DateDuration

source

pub fn new( years: f64, months: f64, weeks: f64, days: f64 ) -> TemporalResult<Self>

Creates a new DateDuration with provided values.

source

pub const fn partial() -> Self

Returns a PartialDateDuration with all fields set to NaN.

source

pub fn from_partial(partial: &DateDuration) -> Self

Creates a DateDuration from a provided partial DateDuration.

source

pub fn negated(&self) -> Self

Returns a negated DateDuration.

source

pub fn abs(&self) -> Self

Returns a new DateDuration representing the absolute value of the current.

source

pub fn sign(&self) -> i32

Returns the sign for the current DateDuration.

source§

impl DateDuration

source

pub fn round<C: CalendarProtocol, Z: TzProtocol>( &self, normalized_time: Option<NormalizedTimeDuration>, increment: u64, unit: TemporalUnit, rounding_mode: TemporalRoundingMode, relative_to: &RelativeTo<'_, C, Z>, _precalculated_dt: Option<DateTime<C>>, context: &mut C::Context ) -> TemporalResult<(Self, f64)>

Rounds the current DateDuration returning a tuple of the rounded DateDuration and the total value of the smallest unit prior to rounding.

Trait Implementations§

source§

impl Clone for DateDuration

source§

fn clone(&self) -> DateDuration

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 DateDuration

source§

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

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

impl Default for DateDuration

source§

fn default() -> DateDuration

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

impl Copy for DateDuration

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