TimeDiff

Trait TimeDiff 

Source
pub trait TimeDiff {
    // Provided methods
    fn diff<T: Time>(&self, other: &T) -> u64
       where Self: Time { ... }
    fn diff_ms<T: Time>(&self, other: &T) -> u64
       where Self: Time { ... }
}
Expand description

Implements the diff functions (optional)

Provided Methods§

Source

fn diff<T: Time>(&self, other: &T) -> u64
where Self: Time,

Get the difference between two times in seconds

§Examples
use thetime::{System, Time, TimeDiff, StrTime, IntTime};
let x = "2018-01-01 00:00:00".parse_time::<System>("%Y-%m-%d %H:%M:%S");
let y = "2017-01-01 00:00:00".parse_time::<System>("%Y-%m-%d %H:%M:%S");
println!("{} seconds difference", x.diff(&y));
assert_eq!(x.diff(&y), 31536000u64);
Source

fn diff_ms<T: Time>(&self, other: &T) -> u64
where Self: Time,

Get the difference between two times in milliseconds

§Examples
use thetime::{System, Time, TimeDiff};
let x = System::now();
let y = System::now();
println!("{} milliseconds difference", x.diff_ms(&y));

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§