What else would you do on a weekend except build something no one asked for?
Have you ever used the Unix utility units? It’s one of those quiet, decades-old tools that’s amazing at doing unit math and conversion. You type in what you have, it tells you what you want. It looks something like this:
> 3 meters to feet
9.84252 feet
> 60 mph to km/h
96.56064 kilometers per hour
> 100 kg * 9.8 m/s^2
980 kilogram-meter-per-square-second
> 12 ft + 3 in to ft
12.25 feet
> 1 gallon to liters
3.785412 liters
> sqrt(9 m^2)
3 meters
> 1|3 cup to mL
78.862746 milliliters
It handles juxtaposition multiplication the way physicists expect (kg m / s^2 means (kg * m) / s^2), it does rational numbers with |, and it knows about over 150 unit types with all their SI-prefixed variants. You can search for units, ask what’s conformable with what, and pipe it into shell scripts.
But what you may not have guessed is that this Unity, a units clone written in Elixir.
It leverages the units-of-measure capabilities of Localize with the power of a NimbleParsec grammar and an expression interpreter. And it adds some things that GNU units never anticipated.
Like locale-aware output:
> locale de
Locale set to :de
> 1234.5 meter to kilometer
1,2345 Kilometer
> locale ja
Locale set to :ja
> 1 kilometer
1 キロメートル
Variable binding:
> let distance = 42.195 km
42.195 kilometers
> let time = 2 hours
2 hours
> distance / time
21.0975 kilometers per hour
> _ to mph
13.109 miles per hour
Measurement system conversion — just say where you want to go:
> 100 meter to US
0.062137 miles
> 100 fahrenheit to metric
37.777778 degrees Celsius
> 100 meter to preferred
0.062137 miles
> locale de
Locale set to :de
> 100 meter to preferred
0,1 Kilometer
And mixed-unit decomposition:
> 3.756 hours to h;min;s
3 hours, 45 minutes, 21.6 seconds
You never asked for this, and you’ll probably never need it. But when you do, you’ll find it at hex.pm/packages/unity.
Coda
I’m always looking for ways to test the boundaries of Localize. This fun project was intended just as a great way to exercise Localize.Unit and it did shine a light on two small bugs. And then somehow grew into something much more.

























