macro_rules! dtt_diff {
($dt1:expr, $dt2:expr, $unit:expr) => { ... };
}Expand description
A helper macro to calculate the difference between two DateTime instances.
§Parameters
$dt1:expr: The firstDateTimeinstance, as a string parseable asi64.$dt2:expr: The secondDateTimeinstance, as a string parseable asi64.$unit:expr: The unit for the difference (seconds, days, etc.).
§Returns
Some(i64) containing the absolute difference in the specified unit, or
None if either input cannot be parsed as i64.
§Example
use dtt::{dtt_diff, dtt_parse};
let dt1 = "1609459200"; // 2021-01-01 00:00:00 UTC
let dt2 = "1609459230"; // 2021-01-01 00:00:30 UTC
let seconds_difference = dtt_diff!(dt1, dt2, 1);
assert_eq!(seconds_difference, Some(30i64));