Skip to content

Instantly share code, notes, and snippets.

@esquinas
Created January 12, 2019 19:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save esquinas/bb6c0a017fe1d648fedead2c1d67c1d2 to your computer and use it in GitHub Desktop.
Save esquinas/bb6c0a017fe1d648fedead2c1d67c1d2 to your computer and use it in GitHub Desktop.
Quick SI/APA euro currency formatting in functional JavaScript.
const intlSpanishFormatter = Intl.NumberFormat('es-ES', { style: 'currency', currency: 'EUR'});
const PreventGroupingOfFourIntegerDigits = function ({type, value }, idx, parts) {
(idx === (parts.length - 7) && value.length < 2 && (parts[idx + 1].value = ''));
return value;
};
intlSpanishFormatter.formatToParts(1234.56).map(PreventGroupingOfFourIntegerDigits).join('');
@esquinas
Copy link
Author

Make a custom und-UN-x-siapa locale?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment