export function toNumber(value) {
  if (typeof value === 'number') { return value; }

  if (value instanceof Date) { return value.valueOf(); }

  if (typeof value === 'string') {
    const commaIndex = value.indexOf(',');
    const dotIndex   = value.indexOf('.');
    let parsed       = value;

    // Removes the thousands separators
    parsed = parsed.replace(' ', '');
    if (commaIndex < dotIndex) {
      parsed = parsed.replace(',', '');
    } else {
      parsed = parsed.replace('.', '');
    }

    // normalizes decimal seperator to a dot
    parsed = parsed.replace(',', '.');

    return parseFloat(parsed);
  }

  return null;
}

@@ -1,8 +1,292 @@
+import $ from 'jquery';%0A%0Aconst THOUSANDS_REGEX = /(%5Cd+)(%5Cd%7B3%7D)/;%0A%0Afunction addThousandSeperators(integer) %7B%0A  let string = integer.toString();%0A%0A  while (integer %3E= 1000 && THOUSANDS_REGEX.test(string)) %7B%0A    string = string.replace(THOUSANDS_REGEX, '$1.$2');%0A  %7D%0A%0A  return string;%0A%7D%0A%0A
 export f
@@ -918,12 +918,955 @@
 urn null;%0A%7D%0A
+%0Aexport function formatNumber(value, %7B decimals %7D = %7B%7D) %7B%0A  const originalValue = value;%0A  value = toNumber(value);%0A%0A  if (typeof value !== 'number' %7C%7C isNaN(value)) %7B return originalValue; %7D%0A%0A  const integerValue = Math.floor(value);%0A  const decimalValue = value - integerValue;%0A%0A  const integerStringValue = addThousandSeperators(integerValue);%0A%0A  if (decimalValue %3E 0 %7C%7C decimals %3E 0) %7B%0A    let decimalStringValue = decimalValue.toFixed(decimals).slice(2);%0A    return %60$%7BintegerStringValue%7D,$%7BdecimalStringValue%7D%60;%0A  %7D else %7B%0A    return integerStringValue;%0A  %7D%0A%7D%0A%0Aexport function formatDate(value, options) %7B%0A  if (!(value instanceof Date)) %7B return value; %7D%0A  if (options === null %7C%7C typeof object !== 'object') %7B%0A    options = %7B%7D;%0A  %7D%0A  options = $.extend(%7B%0A    year:   'numeric',%0A    month:  '2-digit',%0A    day:    '2-digit',%0A    hour:   'numeric',%0A    minute: 'numeric'%0A  %7D, options);%0A  return value.toLocaleString('nl-NL', options);%0A%7D%0A

add format-date convertion and helper