how to round durations to most significant unit ? (5 secs, 889 ms, and 811 μs => 5 secs)

Timothee Cour thelastmammoth at gmail.com
Thu Feb 13 23:37:13 PST 2014


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)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20140213/c03df3bf/attachment-0001.html>


More information about the Digitalmars-d-learn mailing list