macro_rules! from_ps {
($ps:expr, $frac:expr, on=$scale:expr, target=$target:expr) => { ... };
($ps:expr, $frac:expr, target=$target:expr, on=$scale:expr) => { ... };
($ps:expr, on=$scale:expr, target=$target:expr) => { ... };
($ps:expr, target=$target:expr, on=$scale:expr) => { ... };
($ps:expr, $frac:expr, on=$scale:expr) => { ... };
($ps:expr, $frac:expr, target=$target:expr) => { ... };
($ps:expr, on=$scale:expr) => { ... };
($ps:expr, target=$target:expr) => { ... };
($ps:expr, $frac:expr) => { ... };
($ps:expr) => { ... };
}Expand description
Builds a Dt from whole picoseconds and an optional signed
fractional remainder in attoseconds.
Sugar for Dt::from_ps. Does not perform
time-scale conversion.
The fractional remainder is in attoseconds — use
fs! (or another *_to_attos
helper) instead of writing the attosecond literal by hand.
§Defaults
| Omitted | Default |
|---|---|
| fraction | 0 |
on and target | both Scale::TAI |
only on=s | target=s |
only target=t | on=TAI |
§Forms
from_ps!(ps)
from_ps!(ps, frac)
from_ps!(ps, on=s)
from_ps!(ps, target=t)
from_ps!(ps, on=s, target=t)
from_ps!(ps, target=t, on=s)
from_ps!(ps, frac, on=s)
from_ps!(ps, frac, target=t)
from_ps!(ps, frac, on=s, target=t)
from_ps!(ps, frac, target=t, on=s)§Examples
use deep_time::{Dt, Scale, from_ps, fs};
// 1.3 ps → whole picoseconds + 300 fs remainder
let a = from_ps!(1);
let b = from_ps!(1, fs!(300));
let c = from_ps!(-1, fs!(-300), on=Scale::TAI);
let d = from_ps!(0, on=Scale::UTC);
let e = from_ps!(1, on=Scale::TAI, target=Scale::UTC);
let f = from_ps!(1, target=Scale::UTC);
assert_eq!(a, Dt::from_ps(1, 0, Scale::TAI, Scale::TAI));
assert_eq!(b, Dt::from_ps(1, fs!(300), Scale::TAI, Scale::TAI));
assert_eq!(c, Dt::from_ps(-1, fs!(-300), Scale::TAI, Scale::TAI));
assert_eq!(d, Dt::from_ps(0, 0, Scale::UTC, Scale::UTC));
assert_eq!(e, Dt::from_ps(1, 0, Scale::TAI, Scale::UTC));
assert_eq!(f, e);
let signed = from_ps!(-1, fs!(-300));
let floor = from_ps!(-2, fs!(700));
assert_eq!(signed, floor);
assert_eq!(signed, Dt::from_ps(-1, fs!(-300), Scale::TAI, Scale::TAI));