Struct temporal_rs::components::Instant
source · #[non_exhaustive]pub struct Instant { /* private fields */ }
Expand description
The native Rust implementation of Temporal.Instant
Implementations§
source§impl Instant
impl Instant
sourcepub fn new(nanos: BigInt) -> TemporalResult<Self>
pub fn new(nanos: BigInt) -> TemporalResult<Self>
Create a new validated Instant
.
sourcepub fn add(&self, duration: Duration) -> TemporalResult<Self>
pub fn add(&self, duration: Duration) -> TemporalResult<Self>
Adds a Duration
to the current Instant
, returning an error if the Duration
contains a DateDuration
.
sourcepub fn add_time_duration(&self, duration: &TimeDuration) -> TemporalResult<Self>
pub fn add_time_duration(&self, duration: &TimeDuration) -> TemporalResult<Self>
Adds a TimeDuration
to Instant
.
sourcepub fn subtract(&self, duration: Duration) -> TemporalResult<Self>
pub fn subtract(&self, duration: Duration) -> TemporalResult<Self>
Subtract a Duration
to the current Instant
, returning an error if the Duration
contains a DateDuration
.
sourcepub fn subtract_time_duration(
&self,
duration: &TimeDuration
) -> TemporalResult<Self>
pub fn subtract_time_duration( &self, duration: &TimeDuration ) -> TemporalResult<Self>
Subtracts a TimeDuration
to Instant
.
sourcepub fn since(
&self,
other: &Self,
rounding_mode: Option<TemporalRoundingMode>,
rounding_increment: Option<f64>,
largest_unit: Option<TemporalUnit>,
smallest_unit: Option<TemporalUnit>
) -> TemporalResult<TimeDuration>
pub fn since( &self, other: &Self, rounding_mode: Option<TemporalRoundingMode>, rounding_increment: Option<f64>, largest_unit: Option<TemporalUnit>, smallest_unit: Option<TemporalUnit> ) -> TemporalResult<TimeDuration>
Returns a TimeDuration
representing the duration since provided Instant
sourcepub fn until(
&self,
other: &Self,
rounding_mode: Option<TemporalRoundingMode>,
rounding_increment: Option<f64>,
largest_unit: Option<TemporalUnit>,
smallest_unit: Option<TemporalUnit>
) -> TemporalResult<TimeDuration>
pub fn until( &self, other: &Self, rounding_mode: Option<TemporalRoundingMode>, rounding_increment: Option<f64>, largest_unit: Option<TemporalUnit>, smallest_unit: Option<TemporalUnit> ) -> TemporalResult<TimeDuration>
Returns a TimeDuration
representing the duration until provided Instant
sourcepub fn round(
&self,
increment: Option<f64>,
unit: TemporalUnit,
rounding_mode: Option<TemporalRoundingMode>
) -> TemporalResult<Self>
pub fn round( &self, increment: Option<f64>, unit: TemporalUnit, rounding_mode: Option<TemporalRoundingMode> ) -> TemporalResult<Self>
Returns an Instant
by rounding the current Instant
according to the provided settings.
sourcepub fn epoch_seconds(&self) -> f64
pub fn epoch_seconds(&self) -> f64
Returns the epochSeconds
value for this Instant
.
sourcepub fn epoch_milliseconds(&self) -> f64
pub fn epoch_milliseconds(&self) -> f64
Returns the epochMilliseconds
value for this Instant
.
sourcepub fn epoch_microseconds(&self) -> f64
pub fn epoch_microseconds(&self) -> f64
Returns the epochMicroseconds
value for this Instant
.
sourcepub fn epoch_nanoseconds(&self) -> f64
pub fn epoch_nanoseconds(&self) -> f64
Returns the epochNanoseconds
value for this Instant
.
Trait Implementations§
source§impl Ord for Instant
impl Ord for Instant
source§impl PartialEq for Instant
impl PartialEq for Instant
source§impl PartialOrd for Instant
impl PartialOrd for Instant
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more