ecma402
ecma402 copied to clipboard
Add style ordinal/cardinal to NumberFormat (RBNF)
trafficstars
Support formatting ordinals & cardinals
Style Ordinal
console.log(new Intl.NumberFormat('en', { style: 'ordinal' }).format(2));
// 2nd
console.log(new Intl.NumberFormat('pt', { style: 'ordinal' }).format(2));
// 2.º or 2.ª (M/F)
Style Cardinal
console.log(new Intl.NumberFormat('en', { style: 'cardinal' }).format(2));
// second
console.log(new Intl.NumberFormat('pt', { style: 'cardinal' }).format(2));
// segundo or segunda (M/F)
Previous issue: #95. Let's keep this issue focused on Spellout and Ordinal specifically. However, the underlying code for these two styles is the same as for the algorithmic numbering systems (native, traditio, finance) listed in #95.
See some good discussion on https://github.com/tc39/proposal-intl-numberformat-v3/issues/22. CC @Bx1