pub struct Duration { /* private fields */ }
Implementations§
Source§impl Duration
impl Duration
pub const fn new(value: f64, units: DurationUnit) -> Self
pub fn value(&self) -> f64
pub fn units(&self) -> DurationUnit
Source§impl Duration
impl Duration
Sourcepub const fn new_seconds(value: f64) -> Duration
pub const fn new_seconds(value: f64) -> Duration
Creates a new duration using the specified number of seconds
Sourcepub fn as_ydhms(&self) -> (u64, u16, u8, u8, u8)
pub fn as_ydhms(&self) -> (u64, u16, u8, u8, u8)
Returns this duration as (Years, Days, Hours, Minutes, Seconds)
Sourcepub fn as_dhms(&self) -> (u64, u8, u8, u8)
pub fn as_dhms(&self) -> (u64, u8, u8, u8)
Returns this duration as (Days, Hours, Minutes, Seconds)
Sourcepub fn as_seconds(&self) -> u64
pub fn as_seconds(&self) -> u64
Returns the value of this duration as whole seconds, with any fractional element truncated off.
Sourcepub fn as_seconds_f64(&self) -> f64
pub fn as_seconds_f64(&self) -> f64
Returns the value of this duration in fractional seconds
Sourcepub fn as_seconds_f32(&self) -> f32
pub fn as_seconds_f32(&self) -> f32
Returns the value of this duration in fractional seconds
Sourcepub fn as_millis(&self) -> u64
pub fn as_millis(&self) -> u64
Returns the value of this duration as whole milliseconds, with any fractional element truncated off.
Sourcepub fn as_micros(&self) -> u64
pub fn as_micros(&self) -> u64
Returns the value of this duration as whole microseconds, with any fractional element truncated off.
Sourcepub fn as_nanos(&self) -> u64
pub fn as_nanos(&self) -> u64
Returns the value of this duration as whole microseconds, with any fractional element truncated off.
Sourcepub fn as_minutes(&self) -> u64
pub fn as_minutes(&self) -> u64
Returns the value of this duration as whole minutes, with any fractional element truncated off
Sourcepub fn as_hours(&self) -> u64
pub fn as_hours(&self) -> u64
Returns the value of this duration as whole hours, with any fractional element truncated off
Source§impl Duration
impl Duration
Sourcepub const fn from_micros(micros: u64) -> Duration
pub const fn from_micros(micros: u64) -> Duration
Creates a new Duration
from the specified number of microseconds.
§Examples
use irox_units::units::duration::Duration;
let duration = Duration::from_micros(1_000_002);
assert_eq!(1, duration.as_seconds());
Sourcepub const fn from_millis(millis: u64) -> Duration
pub const fn from_millis(millis: u64) -> Duration
Creates a new Duration
from the specified number of milliseconds.
§Examples
use irox_units::units::duration::Duration;
let duration = Duration::from_millis(2569);
assert_eq!(2, duration.as_seconds());
Sourcepub const fn from_nanos(nanos: u64) -> Duration
pub const fn from_nanos(nanos: u64) -> Duration
Creates a new Duration
from the specified number of nanoseconds.
§Examples
use irox_units::units::duration::Duration;
let duration = Duration::from_nanos(1_000_000_123);
assert_eq!(1, duration.as_seconds());
Sourcepub const fn from_minutes(minutes: u64) -> Duration
pub const fn from_minutes(minutes: u64) -> Duration
Creates a new Duration
from the specified number of minutes.
§Examples
use irox_units::units::duration::Duration;
let duration = Duration::from_minutes(1);
assert_eq!(60, duration.as_seconds());
Sourcepub const fn from_hours(hours: u64) -> Duration
pub const fn from_hours(hours: u64) -> Duration
Creates a new Duration
from the specified number of hours.
§Examples
use irox_units::units::duration::Duration;
let duration = Duration::from_hours(1);
assert_eq!(3600, duration.as_seconds());
Sourcepub const fn from_days(days: u64) -> Duration
pub const fn from_days(days: u64) -> Duration
Creates a new Duration
from the specified number of NIST 811 Days where 1 Day = 86400 Seconds
§Examples
use irox_units::units::duration::Duration;
let duration = Duration::from_days(1);
assert_eq!(86400, duration.as_seconds());
Sourcepub const fn from_years(years: u64) -> Duration
pub const fn from_years(years: u64) -> Duration
Creates a new Duration
from the specified number of NIST 811 Years where 1 Year = 365 Days.
§Examples
use irox_units::units::duration::Duration;
let duration = Duration::from_years(1);
assert_eq!(31_536_000, duration.as_seconds());
Sourcepub const fn from_seconds(seconds: u64) -> Duration
pub const fn from_seconds(seconds: u64) -> Duration
Creates a new Duration
from the specified number of seconds.
§Examples
use irox_units::units::duration::Duration;
let duration = Duration::from_seconds(100);
assert_eq!(100, duration.as_seconds());
Sourcepub const fn from_seconds_f64(seconds: f64) -> Duration
pub const fn from_seconds_f64(seconds: f64) -> Duration
Creates a new Duration
from the specified number of f64 seconds.
§Examples
use irox_units::units::duration::Duration;
let duration = Duration::from_seconds_f64(25.5);
assert_eq!(25.5, duration.as_seconds_f64());
Trait Implementations§
Source§impl<'a> AddAssign<&Duration> for &mut Duration
impl<'a> AddAssign<&Duration> for &mut Duration
Source§fn add_assign(&mut self, rhs: &Duration)
fn add_assign(&mut self, rhs: &Duration)
+=
operation. Read moreSource§impl<'a> AddAssign<&Duration> for Duration
impl<'a> AddAssign<&Duration> for Duration
Source§fn add_assign(&mut self, rhs: &Duration)
fn add_assign(&mut self, rhs: &Duration)
+=
operation. Read moreSource§impl<'a> AddAssign<&mut Duration> for &mut Duration
impl<'a> AddAssign<&mut Duration> for &mut Duration
Source§fn add_assign(&mut self, rhs: &mut Duration)
fn add_assign(&mut self, rhs: &mut Duration)
+=
operation. Read moreSource§impl<'a> AddAssign<&mut Duration> for Duration
impl<'a> AddAssign<&mut Duration> for Duration
Source§fn add_assign(&mut self, rhs: &mut Duration)
fn add_assign(&mut self, rhs: &mut Duration)
+=
operation. Read moreSource§impl<'a> AddAssign<Duration> for &mut Duration
impl<'a> AddAssign<Duration> for &mut Duration
Source§fn add_assign(&mut self, rhs: Duration)
fn add_assign(&mut self, rhs: Duration)
+=
operation. Read moreSource§impl<'a> AddAssign for Duration
impl<'a> AddAssign for Duration
Source§fn add_assign(&mut self, rhs: Duration)
fn add_assign(&mut self, rhs: Duration)
+=
operation. Read moreSource§impl<'a> DivAssign<f64> for &mut Duration
impl<'a> DivAssign<f64> for &mut Duration
Source§fn div_assign(&mut self, rhs: f64)
fn div_assign(&mut self, rhs: f64)
/=
operation. Read moreSource§impl<'a> DivAssign<f64> for Duration
impl<'a> DivAssign<f64> for Duration
Source§fn div_assign(&mut self, rhs: f64)
fn div_assign(&mut self, rhs: f64)
/=
operation. Read moreSource§impl<'a> MulAssign<f64> for &mut Duration
impl<'a> MulAssign<f64> for &mut Duration
Source§fn mul_assign(&mut self, rhs: f64)
fn mul_assign(&mut self, rhs: f64)
*=
operation. Read moreSource§impl<'a> MulAssign<f64> for Duration
impl<'a> MulAssign<f64> for Duration
Source§fn mul_assign(&mut self, rhs: f64)
fn mul_assign(&mut self, rhs: f64)
*=
operation. Read moreSource§impl Ord for Duration
impl Ord for Duration
Source§impl PartialOrd for Duration
impl PartialOrd for Duration
Source§impl<'a> SubAssign<&Duration> for &mut Duration
impl<'a> SubAssign<&Duration> for &mut Duration
Source§fn sub_assign(&mut self, rhs: &Duration)
fn sub_assign(&mut self, rhs: &Duration)
-=
operation. Read moreSource§impl<'a> SubAssign<&Duration> for Duration
impl<'a> SubAssign<&Duration> for Duration
Source§fn sub_assign(&mut self, rhs: &Duration)
fn sub_assign(&mut self, rhs: &Duration)
-=
operation. Read moreSource§impl<'a> SubAssign<&mut Duration> for &mut Duration
impl<'a> SubAssign<&mut Duration> for &mut Duration
Source§fn sub_assign(&mut self, rhs: &mut Duration)
fn sub_assign(&mut self, rhs: &mut Duration)
-=
operation. Read moreSource§impl<'a> SubAssign<&mut Duration> for Duration
impl<'a> SubAssign<&mut Duration> for Duration
Source§fn sub_assign(&mut self, rhs: &mut Duration)
fn sub_assign(&mut self, rhs: &mut Duration)
-=
operation. Read moreSource§impl<'a> SubAssign<Duration> for &mut Duration
impl<'a> SubAssign<Duration> for &mut Duration
Source§fn sub_assign(&mut self, rhs: Duration)
fn sub_assign(&mut self, rhs: Duration)
-=
operation. Read moreSource§impl<'a> SubAssign for Duration
impl<'a> SubAssign for Duration
Source§fn sub_assign(&mut self, rhs: Duration)
fn sub_assign(&mut self, rhs: Duration)
-=
operation. Read more