Skip to main content

Module format

Module format 

Source
Expand description

Formatting for the basic catalog’s functions, in the en-US locale every reference SDK defaults to: numbers and currency as Intl.NumberFormat writes them, dates by TR35 pattern, plural categories, and the string forms JavaScript gives values (String(value)), so output is the same on every renderer.

Functions§

format_currency
formatCurrency: the amount with the currency’s en-US symbol, or its code and a no-break space when it has none; 2 fraction digits unless decimals says otherwise.
format_date
formatDate: a TR35 pattern applied to the date as written (yyyy yy MMMM MMM MM M EEEE E dd d HH H hh h mm ss a), or ISO for the instant in UTC with milliseconds. A value that does not parse gives "".
format_number
formatNumber: en-US digits with grouping unless grouping is false.
number_string
A number as JavaScript’s String(number) writes it: shortest round-trip digits, fixed notation between 1e-7 and 1e21, exponential outside.
plural_category
The plural category of a number in en: one for 1, other otherwise, with the explicit forms every SDK checks first (zero for 0, one for 1, two for 2) when given.
to_number
A value as JavaScript’s Number(value) reads it (NaN when it is not a number).
to_string
A value as JavaScript’s String(value) writes it, with objects and arrays as JSON and null as "" (the specification’s type conversion rule).