Skip to content
Snippets Groups Projects
Unverified Commit 410dbbc8 authored by Sid Vishnoi's avatar Sid Vishnoi Committed by GitHub
Browse files

Add Indian numbering format (#1412)

parent 9273a0ab
No related branches found
No related tags found
No related merge requests found
...@@ -44,6 +44,16 @@ describe('utility functions', () => { ...@@ -44,6 +44,16 @@ describe('utility functions', () => {
expect(formatter.format(Number('1234.56'))).toBe('1,235'); expect(formatter.format(Number('1234.56'))).toBe('1,235');
}); });
test('number formatting works with comma-dot-in format', () => {
setNumberFormat({ format: 'comma-dot-in', hideFraction: false });
let formatter = getNumberFormat().formatter;
expect(formatter.format(Number('1234567.89'))).toBe('12,34,567.89');
setNumberFormat({ format: 'comma-dot-in', hideFraction: true });
formatter = getNumberFormat().formatter;
expect(formatter.format(Number('1234567.89'))).toBe('12,34,568');
});
test('number formatting works with dot-comma format', () => { test('number formatting works with dot-comma format', () => {
setNumberFormat({ format: 'dot-comma', hideFraction: false }); setNumberFormat({ format: 'dot-comma', hideFraction: false });
let formatter = getNumberFormat().formatter; let formatter = getNumberFormat().formatter;
......
...@@ -188,6 +188,7 @@ export let numberFormats = [ ...@@ -188,6 +188,7 @@ export let numberFormats = [
{ value: 'dot-comma', label: '1.000,33', labelNoFraction: '1.000' }, { value: 'dot-comma', label: '1.000,33', labelNoFraction: '1.000' },
{ value: 'space-comma', label: '1 000,33', labelNoFraction: '1 000' }, { value: 'space-comma', label: '1 000,33', labelNoFraction: '1 000' },
{ value: 'space-dot', label: '1 000.33', labelNoFraction: '1 000' }, { value: 'space-dot', label: '1 000.33', labelNoFraction: '1 000' },
{ value: 'comma-dot-in', label: '1,00,000.33', labelNoFraction: '1,00,000' },
] as const; ] as const;
let numberFormat: { let numberFormat: {
...@@ -220,6 +221,11 @@ export function setNumberFormat({ format, hideFraction }) { ...@@ -220,6 +221,11 @@ export function setNumberFormat({ format, hideFraction }) {
regex = /[^-0-9.]/g; regex = /[^-0-9.]/g;
separator = '.'; separator = '.';
break; break;
case 'comma-dot-in':
locale = 'en-IN';
regex = /[^-0-9.]/g;
separator = '.';
break;
case 'comma-dot': case 'comma-dot':
default: default:
locale = 'en-US'; locale = 'en-US';
......
---
category: Enhancements
authors: [sidvishnoi]
---
Add Indian numbering format (lakh, crore)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment