A2UICore.Formatter.Default (A2UICore v0.1.1)

Copy Markdown View Source

The built-in A2UICore.Formatter: en-US conventions for every locale.

Numbers follow CLDR's #,##0.### decimal pattern and ¤#,##0.00 currency pattern with round-half-even on the shortest decimal form of the input (so 2.675 rounds to 2.68, as the reference's decimal arithmetic does). Alphabetic currency symbols are separated from the digits by U+00A0 (CHF 1,234.56), CLDR's currencySpacing.

iex> A2UICore.Formatter.Default.decimal(1234.567, decimals: 2)
"1,234.57"
iex> A2UICore.Formatter.Default.currency(99.99, "USD", [])
"$99.99"
iex> A2UICore.Formatter.Default.date(~U[2026-08-26 12:00:00Z], "MMM d, yyyy", [])
"Aug 26, 2026"

Date patterns are Unicode TR35 patterns: text in single quotes is literal and '' is a quote.

iex> A2UICore.Formatter.Default.date(~U[2026-08-26 19:30:00Z], "EEEE 'at' h:mm a", [])
"Wednesday at 7:30 PM"