Commit 57248606 authored by Florian Pagnoux's avatar Florian Pagnoux
Browse files

Properly format AF

parent 36bb2338
......@@ -8,6 +8,10 @@ it('formatNumber should format currencies in a French style', () => {
expect(formatNumber(3000, {style: 'currency', currency: 'EUR'})).toEqual('3\xa0000,00\xa0€')
});
it('formatNumber should format anciens francs', () => {
expect(formatNumber(3000, {style: 'currency', currency: 'AFRF'})).toEqual('3\xa0000,00\xa0AF')
});
it('formatDate should format dates in a French style', () => {
expect(formatDate('2019-02-01')).toEqual('01/02/2019')
});
......@@ -5,9 +5,17 @@ import 'intl/locale-data/jsonp/fr.js';
Intl.DateTimeFormat = IntlPolyfill.DateTimeFormat;
export function formatNumber(value, options) {
if (options && options.currency == 'AFRF') {
return formatAFRF(value, options)
}
return (new Intl.NumberFormat('fr', options)).format(value)
}
export function formatDate(value) {
return new Intl.DateTimeFormat('fr', {timeZone: 'UTC'}).format(new Date(value))
}
function formatAFRF(value, options) {
const {currency, ...otherOptions} = options
return formatNumber(value, {currency: 'FRF', ...otherOptions}).replace('F', 'AF')
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment