import numeral from 'numeral';

// ----------------------------------------------------------------------
// load a locale
numeral.register('locale', 'id', {
  delimiters: {
      thousands: '.',
      decimal: ','
  },
  abbreviations: {
      thousand: 'k',
      million: 'm',
      billion: 'b',
      trillion: 't'
  },
  ordinal : function (number: number) {
      return number === 1 ? 'er' : 'ème';
  },
  currency: {
      symbol: 'Rp '
  }
});

// switch between locales
numeral.locale('id');

export function fCurrency(number: string | number) {
  return numeral(number).format('$0,0');
}

export function fPercent(number: number) {
  return numeral(number / 100).format('0.0%');
}

export function fNumber(number: string | number) {
  return numeral(number).format();
}

export function fShortenNumber(number: string | number) {
  return numeral(number).format('0.00a').replace('.00', '');
}

export function fData(number: string | number) {
  return numeral(number).format('0.0 b');
}
