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§
Sourcefn diff<T: Time>(&self, other: &T) -> u64where
Self: Time,
fn diff<T: Time>(&self, other: &T) -> u64where
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);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.