Struct game_time::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 Neg for FloatDuration
[src]

impl Debug for FloatDuration
[src]

Formats the value using the given formatter.

impl AddAssign<FloatDuration> for FloatDuration
[src]

impl Clone for FloatDuration
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl FromDuration<Duration> for FloatDuration
[src]

impl FromDuration<Duration> for FloatDuration
[src]

impl Display for FloatDuration
[src]

impl PartialOrd<FloatDuration> for FloatDuration
[src]

impl Default for FloatDuration
[src]

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

impl Sub<FloatDuration> for FloatDuration
[src]

impl Copy for FloatDuration
[src]

impl Add<FloatDuration> for FloatDuration
[src]

impl From<Duration> for FloatDuration
[src]

impl From<Duration> for FloatDuration
[src]

impl Div<FloatDuration> for FloatDuration
[src]

impl Div<f64> for FloatDuration
[src]

impl Mul<f64> for FloatDuration
[src]

impl Serialize for FloatDuration
[src]

impl ApproxEq for FloatDuration
[src]

impl SubAssign<FloatDuration> for FloatDuration
[src]

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

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

impl Sum<FloatDuration> for FloatDuration
[src]

impl DivAssign<f64> for FloatDuration
[src]

impl PartialEq<FloatDuration> 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 MulAssign<f64> for FloatDuration
[src]