Cldr.Unit.Parser.canonical_unit_name

You're seeing just the function canonical_unit_name, go back to Cldr.Unit.Parser module for more information.
Link to this function

canonical_unit_name(unit_string)

View Source

Returns the canonical unit name for a unit

Arguments

  • unit_string is any string representing a unit such as light_year_per_week.

Returns

  • {:ok, canonical_name} or

  • {:error, {exception, reason}}

Examples

iex> Cldr.Unit.Parser.canonical_unit_name "meter"
{:ok, :meter}

iex> Cldr.Unit.Parser.canonical_unit_name "meter meter"
{:ok, :square_meter}

iex> Cldr.Unit.Parser.canonical_unit_name "meter per kilogram"
{:ok, "meter_per_kilogram"}

iex> Cldr.Unit.Parser.canonical_unit_name "meter kilogram"
{:ok, "kilogram_meter"}

iex> Cldr.Unit.Parser.canonical_unit_name "meter kilogram per fluxom"
{:error, {Cldr.UnknownUnitError, "Unknown unit was detected at \"fluxom\""}}