iliekturtles/uom

Formatter with automatic prefixes

Opened this issue · 3 comments

Is there a possibilty to display quantities with automatic "human readable" prefixes? Example: 0.1 s -> 100 ms.
As a human one typically chooses the prefix such that that there are 1..3 digits displayed before the fractional part. Maybe one could implement this as an additional DisplayStyle.

There isn't any functionality like this currently. I'm not sure if this should be in scope to be directly in uom, so I'll leave the issue open for consideration.

Additional human readable formatting options might also be useful for time quantities where you might expect to see eg. 2:30 rather than 2.5 mins or similar .

As a human one typically chooses the prefix such that that there are 1..3 digits displayed before the fractional part

This is called Engineering notation. Rust formats the Duration type like this. But it mostly applies to SI units, so I think it would be hard to reasonably implement something like that in this crate, which is far more general.