Fix Duration.fmt with negative durations
Negative durations are useful when calculating the duration between two points, as you don't have to worry about overflows. For example, if I have time A
and B
, I can do both B - A
and A - B
to get a Duration
. For cases like std::process.sleep
it just rounds negative durations to zero, meaning it more or less doesn't sleep/wait at all.
Unfortunately, Duration.fmt
currently doesn't handle negative durations well and instead always formats the duration in nanoseconds. We should also add some tests to confirm negative durations indeed work (e.g. when using Duration.-
).