dtt

Macro dtt_diff

Source
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 first DateTime instance.
  • $dt2:expr: The second DateTime instance.
  • $unit:expr: The unit for the difference (seconds, days, etc.).

§Returns

The difference in the specified unit between the two DateTime instances.

§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, 30i64);