macro_rules! time_unit {
    (
        $(#[$doc:meta])* $unit:ident,
        $label:expr,
        $inverse:expr,
        $s_factor:expr
    ) => { ... };
}
Expand description

Define a custom unit of time

  • unit Unit struct name
  • label Standard unit label
  • inverse Inverse time unit (frequency)
  • s_factor Factor to convert to seconds

Example: Fortnight

use mag::{time_unit, time::h};

time_unit!(
    Fortnight,
    "fortnight",
    "/fortnight",
    14.0 * 24.0 * 60.0 * 60.0
);

let f = 1 * Fortnight;
assert_eq!(f.to::<h>(), 24 * 14 * h);