View Source Cldr.Unit.BaseUnit (Cldr Units v3.16.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
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 aslight_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"}
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 aslight_year_per_week
.
Returns
canonical_base_unit
orraises 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"