Struct temporal_rs::components::duration::TimeDuration
source · #[non_exhaustive]pub struct TimeDuration {
pub hours: f64,
pub minutes: f64,
pub seconds: f64,
pub milliseconds: f64,
pub microseconds: f64,
pub nanoseconds: f64,
}
Expand description
TimeDuration
represents the Time 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
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.hours: f64
TimeDuration
’s internal hour value.
minutes: f64
TimeDuration
’s internal minute value.
seconds: f64
TimeDuration
’s internal second value.
milliseconds: f64
TimeDuration
’s internal millisecond value.
microseconds: f64
TimeDuration
’s internal microsecond value.
nanoseconds: f64
TimeDuration
’s internal nanosecond value.
Implementations§
source§impl TimeDuration
impl TimeDuration
sourcepub fn new(
hours: f64,
minutes: f64,
seconds: f64,
milliseconds: f64,
microseconds: f64,
nanoseconds: f64
) -> TemporalResult<Self>
pub fn new( hours: f64, minutes: f64, seconds: f64, milliseconds: f64, microseconds: f64, nanoseconds: f64 ) -> TemporalResult<Self>
Creates a new validated TimeDuration
.
sourcepub fn from_partial(partial: &TimeDuration) -> Self
pub fn from_partial(partial: &TimeDuration) -> Self
Creates a TimeDuration
from a provided partial TimeDuration
.
sourcepub fn abs(&self) -> Self
pub fn abs(&self) -> Self
Returns a new TimeDuration
representing the absolute value of the current.
sourcepub fn is_within_range(&self) -> bool
pub fn is_within_range(&self) -> bool
Utility function for returning if values in a valid range.
source§impl TimeDuration
impl TimeDuration
sourcepub fn round(
&self,
increment: u64,
unit: TemporalUnit,
mode: TemporalRoundingMode
) -> TemporalResult<(NormalizedTimeDuration, i64)>
pub fn round( &self, increment: u64, unit: TemporalUnit, mode: TemporalRoundingMode ) -> TemporalResult<(NormalizedTimeDuration, i64)>
Rounds the current TimeDuration
given a rounding increment, unit and rounding mode. round
will return a tuple of the rounded TimeDuration
and
the total
value of the smallest unit prior to rounding.
Trait Implementations§
source§impl Clone for TimeDuration
impl Clone for TimeDuration
source§fn clone(&self) -> TimeDuration
fn clone(&self) -> TimeDuration
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more