ecma402 icon indicating copy to clipboard operation
ecma402 copied to clipboard

Add style ordinal/cardinal to NumberFormat (RBNF)

Open romulocintra opened this issue 5 years ago • 6 comments
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)

romulocintra avatar Aug 10 '20 20:08 romulocintra

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.

sffc avatar Aug 10 '20 20:08 sffc

See some good discussion on https://github.com/tc39/proposal-intl-numberformat-v3/issues/22. CC @Bx1

sffc avatar Jan 14 '21 06:01 sffc