[][src]Struct game_time::FloatDuration

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<'de> Deserialize<'de> for FloatDuration
[src]

impl Serialize for FloatDuration
[src]

impl Sub<FloatDuration> for FloatDuration
[src]

The resulting type after applying the - operator.

impl FromDuration<Duration> for FloatDuration
[src]

impl FromDuration<Duration> for FloatDuration
[src]

impl From<Duration> for FloatDuration
[src]

impl From<Duration> for FloatDuration
[src]

impl Debug for FloatDuration
[src]

impl PartialEq<FloatDuration> for FloatDuration
[src]

impl Mul<f64> for FloatDuration
[src]

The resulting type after applying the * operator.

impl DivAssign<f64> for FloatDuration
[src]

impl Clone for FloatDuration
[src]

Performs copy-assignment from source. Read more

impl ApproxEq for FloatDuration
[src]

Used for specifying relative comparisons.

The inverse of ApproxEq::relative_eq.

The inverse of ApproxEq::ulps_eq.

impl Div<FloatDuration> for FloatDuration
[src]

The resulting type after applying the / operator.

impl Div<f64> for FloatDuration
[src]

The resulting type after applying the / operator.

impl Display for FloatDuration
[src]

impl AddAssign<FloatDuration> for FloatDuration
[src]

impl PartialOrd<FloatDuration> for FloatDuration
[src]

impl MulAssign<f64> for FloatDuration
[src]

impl SubAssign<FloatDuration> for FloatDuration
[src]

impl Add<FloatDuration> for FloatDuration
[src]

The resulting type after applying the + operator.

impl Sum<FloatDuration> for FloatDuration
[src]

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

impl Neg for FloatDuration
[src]

The resulting type after applying the - operator.

impl Default for FloatDuration
[src]

impl Copy for FloatDuration
[src]

Auto Trait Implementations

impl Send for FloatDuration

impl Sync for FloatDuration

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

impl<T> From for T
[src]

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> IntoDuration for T where
    U: FromDuration<T>, 
[src]

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]