Syntax
object {
length?,
style?,
group?,
round?,
divisor?,
minimumIntegerDigits?,
maximumFractionDigits?,
minimumFractionDigits?,
maximumSignificantDigits?,
minimumSignificantDigits?,
nu?
}
Properties
length?: UnitLength
- Length of the unit indicator
style?: UnitFormatStyleType
- Style used to format the number.
group?: boolean
- Enable grouping of digits.
round?: RoundingModeType
- Mode used to round numbers during formatting.
divisor?: number
- Specify an explicit divisor when formatting a compact style. Should be a round power of 10, e.g.
1000
, 10000
, etc.
minimumIntegerDigits?: number
- Minimum integer digits to display.
maximumFractionDigits?: number
- Maximum fraction digits to display.
minimumFractionDigits?: number
- Minimum fraction digits to display.
maximumSignificantDigits?: number
- Maximum significant digits to display.
minimumSignificantDigits?: number
- Minimum significant digits to display.
nu?: NumberSystemType
- Override the number system used to format the digits.
Example
const cldr = framework.get('en');
const qty: Quantity = { value: '17', unit: 'inch' };
const opts: UnitFormatOptions[] = [
{ length: 'long' },
{ length: 'short' },
{ length: 'narrow' }
];
for (const opt of opts) {
const result = cldr.Units.formatQuantity(qty, opt);
log(result);
}
17 inches
17 in
17″
References