February 14, 2014 how to round durations to most significant unit ? (5 secs, 889 ms, and 811 μs => 5 secs) | ||||
---|---|---|---|---|
| ||||
Attachments:
| Is there a function to do this? If not and I/someone writes it, is there interest to add it to std.datetime? Duration t = ...; t.to!string => 5 secs, 889 ms, and 811 μs t.round.to!string => 5 secs t=...; t.to!string => 889 ms, and 811 μs t.round.to!string => 889 secs Use case: shorter logs. Similarly, it would be nice to have a module in phobos for representing other units such as bytes, and have a similar rounding scheme as in unix command 'ls -lh' which shows 532K, 12M etc) |
Copyright © 1999-2021 by the D Language Foundation