View Source Cldr.Unit.BaseUnit (Cldr Units v3.17.2)

Functions to support the base unit calculations for a unit.

Base unit equality is used to determine whether a one unit can be converted to another

Summary

Functions

Returns the canonical base unit name for a unit.

Returns the canonical base unit name for a unit.

Functions

Link to this function

canonical_base_unit(unit)

View Source

Returns the canonical base unit name for a unit.

The base unit is the common unit through which conversions are passed.

Arguments

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

Returns

  • {:ok, canonical_base_unit} or

  • {:error, {exception, reason}}

Examples

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

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

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

iex> Cldr.Unit.Parser.canonical_base_unit "yottagram per mile scandinavian"
{:ok, "kilogram_per_meter"}
Link to this function

canonical_base_unit!(unit_string)

View Source

Returns the canonical base unit name for a unit.

The base unit is the common unit through which conversions are passed.

Arguments

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

Returns

  • canonical_base_unit or

  • raises an exception

Examples

iex> Cldr.Unit.Parser.canonical_base_unit! "meter"
:meter

iex> Cldr.Unit.Parser.canonical_base_unit! "meter meter"
:square_meter

iex> Cldr.Unit.Parser.canonical_base_unit! "meter per kilogram"
"meter_per_kilogram"

iex> Cldr.Unit.Parser.canonical_base_unit! "yottagram per mile scandinavian"
"kilogram_per_meter"
Link to this function

do_canonical_base_unit(numerator)

View Source