Skip to content

Releases: elixir-cldr/cldr_units

Cldr Units version 3.13.1

07 Jun 09:02
Compare
Choose a tag to compare

Bug Fixes

  • Fix Cldr.Unit.Math.* to respect unit :usage of the input parameters

  • Fix Cldr.Math.localize/2 to respect unit :usage of the options parameter if provided

Cldr Units version 3.13.0

05 Apr 20:30
Compare
Choose a tag to compare

Cldr Units version 3.12.2

27 Feb 10:07
Compare
Choose a tag to compare

Bug Fixes

  • Fixes conversions where the base units don't match (string match) but the units are of the same unit category and therefore are convertible. Thanks to @narrowtux for the report. Fixes #27.

Cldr Units version 3.12.1

23 Feb 03:35
Compare
Choose a tag to compare

Bug Fixes

  • Remove compilation warning for Phoenix.HTML.Safe that was emitted since the :phoenix_html library is not a dependency. Thanks for @maennchen for the report. Fixes #26.

Cldr Units version 3.12.0

20 Feb 23:10
Compare
Choose a tag to compare

Bug Fixes

  • Fix Cldr.Unit.measurement_system_from_locale/2 to allow the second parameter to be either a backend or a measurement system key.

Enhancements

  • Add Cldr.Unit.from_map/1 to create a unit from a map. This can be used to consume the results of serializing a unit to JSON. The input parameter is designed to mirror the output of the custom Jason encoder.

  • Updates to ex_cldr version 2.26.0 and ex_cldr_numbers version 2.25.0 which use atoms for locale names and rbnf locale names. This is consistent with other elements of t:Cldr.LanguageTag where atoms are used when the cardinality of the data is fixed and relatively small and strings where the data is free format.

Cldr Units version 3.11.0

10 Jan 01:43
Compare
Choose a tag to compare

Bug Fixes

  • Fix canonical base unit calculation when the unit is a per per form like candela per lux.

Enhancements

  • Add unit filters for Cldr.Unit.parse/2. This means that the options :only and :except can comprise both unit categories and unit names as part of the filter.

Cldr Units version 3.10.0

26 Dec 23:27
Compare
Choose a tag to compare

Bug Fixes

  • Further refinement to Cldr.Unit.unit_category/1 to return a result in a broader range of cases.

Enhancements

  • Adds :only and :except options to Cldr.Unit.parse/2. These options provide a mechanism to disambiguate the unit when a unit string could refer to more than one unit. For example, "2w" could refer to either "2 weeks" or "2 watts". If neither option is provided then the result is the same as in prior releases: the unit with the lexically shorter and alphabetically earlier unit is returned.

Cldr Units version 3.9.2

26 Dec 05:29
Compare
Choose a tag to compare

Bug Fixes

  • Fix Cldr.Unit.unit_category/1. Thanks to @DaTrader for the report. Closes #24.

Cldr Units version 3.9.1

15 Nov 11:50
Compare
Choose a tag to compare

Bug Fixes

  • Support parsing units with multiple "per" clauses like "gallon per feet per second".

  • Fix canonical unit name for currency units. This also fixes unit math with currency units.

  • Add display_name/2 to backend modules.

Cldr Units version 3.9.0

14 Nov 08:25
Compare
Choose a tag to compare

Bug Fixes

  • Use import Config not deprecated use Mix.Config in config files. Only significant for developers of ex_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"}