Cldr Units version 3.9.0
Bug Fixes
-
Use
import Config
not deprecateduse Mix.Config
in config files. Only significant for developers ofex_cldr_units
. -
Make
decimal
a required dependency, not optional, since various pattern matches expect its presence.
Enhancements
- Add support for currency-based units. This allows for calculations and formatting of units such as "$2 per gallon". For this example, the unit would be created with
Cldr.Unit.new(2, "curr-usd-per-gallon")
. The inverse is also possible, for example:
iex> MyApp.Cldr.Unit.to_string(Cldr.Unit.new!(2, "curr-usd-per-gallon"))
{:ok, "$2.00 per gallon"}
iex> MyApp.Cldr.Unit.to_string(Cldr.Unit.new!(2, "gallon-per-curr-usd"))
{:ok, "2 gallons per US dollar"}
- Add support for binary factor prefixed units. These units are factors of 1024 and include "kibi", "mebi", "gibi", "tebi", "pebi", "exbi", "zebi" and "yobi". For example:
iex> MyApp.Cldr.Unit.to_string Cldr.Unit.new!(3, :gibibyte)
{:ok, "3 gibibytes"}
- Add support for integer prefixes for units. This is useful for units like "liters per 100 kilometers" or "25 calories per 100 grams". For example:
iex> MyApp.Cldr.Unit.to_string Cldr.Unit.new!(25, "calorie_per_100-gram")
{:ok, "25 calories per 100 grams"}