Skip to main content

formatCost

@forge/monorepo


@forge/monorepo / frontend/src / formatCost

Function: formatCost()

formatCost(minorUnits, currency, locale?): string

Defined in: frontend/src/usage-panel.ts:194

A cost in minor units, formatted for the reader's locale.

Intl.NumberFormat with the report's currency, so €1,234.56 and $1,234.56 render the way each locale writes them — including which side the symbol goes on and which separator is which. Dividing by 100 here is the one place minor units become major ones; doing it at a call site is how a figure ends up a hundred times wrong.

Falls back to a plain number when the currency is unknown — a period with no usage has no currency, and Intl throws on an empty currency code rather than degrading.

Parameters

minorUnits

number

currency

string

locale?

string

Returns

string