user friendly display of numbers - specifically size measurement with units

64 Views Asked by At

I am looking for a javascript library that converts a given number and unit into a user friendly display (given whether it should be metric or "US standard"). E.g., I give it "1032 m" and it shows "1 km" or "0.64 mi".

Basically I am looking for an equivalent library to the date conversion from an absolute date to a relative, user-friendly date(e.g. 10pm October 11th 2016 -> 1 year ago, 10pm October 9th 2017 -> 1 day ago). It can round the numbers if necessary, as long as the resulting number is easy to understand for a user.

For the metric system such a conversion could be easy, but including the US standard, it makes it already harder. E.g. No one would want to see 34.5'' but 34'6''.

A sepcial case would be if the library would also be able to handle large numbers. E.g. "15 563 564" becomes "15.5 Mio." and "15 543 454 345" becomes "15.5 Bio." (in american english) and "15.5 Mrd." (in german). But this is very tricky because some languages don't have names for all of the cases.

Does anyone know anything that I could use? Or would I need to hand code all of this? Please note, i am not looking for a library to simply convert numbers between units. I want to library to decide (based on the given number and unit) what is the best way to display it.

0

There are 0 best solutions below