Struct float_duration::duration::FloatDuration [] [src]

pub struct FloatDuration { /* fields omitted */ }

A time duration stored as a floating point quantity.

Unlike std::time::Duration or chrono::Duration, FloatDuration aims to be convenient and fast to use in simulation and mathematical expressions rather than to behave like a calendar or perfectly accurately represent precise time scales.

Internally, a FloatDuration stores a single f64 number of floating-point seconds, thus it is only as precise as the f64 type.

Methods

impl FloatDuration
[src]

Create a new FloatDuration representing a number of years.

float_duration considers one year to be exactly 365 days, with no consideration of leap years.

Create a new FloatDuration representing a number of days.

Create a new FloatDuration representing a number of hours.

Create a new FloatDuration representing a number of minutes.

Create a new FloatDuration representing a number of seconds.

Create a new FloatDuration representing a number of milliseconds.

Create a new FloatDuration representing a number of microseconds.

Create a new FloatDuration representing a number of nanoseconds.

Return the total number of fractional years represented by the FloatDuration.

float_duration considers one year to be exactly 365 days, with no consideration of leap years.

Return the total number of fractional days represented by the FloatDuration.

Return the total number of fractional hours represented by the FloatDuration.

Return the total number of fractional minutes represented by the FloatDuration.

Return the total number of fractional seconds represented by the FloatDuration.

Return the total number of fractional milliseconds represented by the FloatDuration.

Return the total number of fractional microseconds represented by the FloatDuration.

Return the total number of fractional nanoseconds represented by the FloatDuration.

Compute the absolute value of this duration.

Return a new FloatDuration that represents zero elapsed time.

Returns true is this duration represents zero elapsed time (equals FloatDuration::zero()).

Returns true if the FloatDuration holds a positive amount of time.

Returns true if the FloatDuration holds a negative amount of time.

Return a number that represents the sign of self.

  • 1.0 if the value is positive, +0.0 or INFINITY
  • -1.0 if the value is negative, -0.0 or NEG_INFINITY
  • NAN if the value is NAN

Return the maximum of two durations.

Return the minimum of two durations.

Return a new FloatDuration with the minimum possible value.

Return a new FloatDuration with the maximum possible value.

Create a std::time::Duration object from a FloatDuration.

Errors

std::time::Duration does not support negative values or seconds greater than std::u64::MAX. This function will return a DurationError::StdOutOfRange if the FloatDuration value is outside of either of those bounds.

Create a FloatDuration object from a std::time::Duration.

Equivalent to using FloatDuration::from(duration)

impl FloatDuration
[src]

Create a chrono::Duration object from a FloatDuration.

Errors

Presently, the conversion to chrono::Duration first goes through std::time::Duration and return an error if to_std returns an error.

Create a FloatDuration object from a chrono::Duration.

chrono::Duration does not provide a way to access sub-millisecond precision if the duration is too large to be entirely represented as a single value. Thus, if the absolute value of the total number of nanoseconds is greater than i64::MAX, only millisecond precision will be captured.

Equivalent to using FloatDuration::from(duration)

Trait Implementations

impl Debug for FloatDuration
[src]

Formats the value using the given formatter.

impl Clone for FloatDuration
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Copy for FloatDuration
[src]

impl PartialEq for FloatDuration
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl PartialOrd for FloatDuration
[src]

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl Serialize for FloatDuration
[src]

Serialize this value into the given Serde serializer. Read more

impl<'de> Deserialize<'de> for FloatDuration
[src]

Deserialize this value from the given Serde deserializer. Read more

impl FromDuration<Duration> for FloatDuration
[src]

Convert from into a Self object.

impl FromDuration<Duration> for FloatDuration
[src]

Convert from into a Self object.

impl From<Duration> for FloatDuration
[src]

Performs the conversion.

impl From<Duration> for FloatDuration
[src]

Performs the conversion.

impl Display for FloatDuration
[src]

Formats the value using the given formatter. Read more

impl Neg for FloatDuration
[src]

The resulting type after applying the - operator

The method for the unary - operator

impl Add<FloatDuration> for FloatDuration
[src]

The resulting type after applying the + operator

The method for the + operator

impl Sub<FloatDuration> for FloatDuration
[src]

The resulting type after applying the - operator

The method for the - operator

impl Mul<f64> for FloatDuration
[src]

The resulting type after applying the * operator

The method for the * operator

impl Div<f64> for FloatDuration
[src]

The resulting type after applying the / operator

The method for the / operator

impl Div<FloatDuration> for FloatDuration
[src]

The resulting type after applying the / operator

The method for the / operator

impl AddAssign<FloatDuration> for FloatDuration
[src]

The method for the += operator

impl SubAssign<FloatDuration> for FloatDuration
[src]

The method for the -= operator

impl MulAssign<f64> for FloatDuration
[src]

The method for the *= operator

impl DivAssign<f64> for FloatDuration
[src]

The method for the /= operator

impl Default for FloatDuration
[src]

Returns the "default value" for a type. Read more

impl Sum for FloatDuration
[src]

Method which takes an iterator and generates Self from the elements by "summing up" the items. Read more

impl<'a> Sum<&'a FloatDuration> for FloatDuration
[src]

Method which takes an iterator and generates Self from the elements by "summing up" the items. Read more

impl ApproxEq for FloatDuration
[src]

Used for specifying relative comparisons.

The default tolerance to use when testing values that are close together. Read more

The default relative tolerance for testing values that are far-apart. Read more

The default ULPs to tolerate when testing values that are far-apart. Read more

A test for equality that uses a relative comparison if the values are far apart.

A test for equality that uses units in the last place (ULP) if the values are far apart.

The inverse of ApproxEq::relative_eq.

The inverse of ApproxEq::ulps_eq.