export const toNumber = (s: string): number => { return parseFloat(s); }; export const numberDE = (n: number): string => { return n.toFixed(2).replace('.', ','); }; export const fromCents = (input: number): number => { return input / 100; }; export const fromCentsDE = (input: number): string => { return formatDE(input / 100); }; export const fromCentsCH = (input: number): string => { return formatCH(input / 100); }; export const toFixed = (n: number, fixed: number): string => { return n.toFixed(fixed); }; export const numFormat = (n: number, locale = 'en-GB', digits = 2): string => { return n.toLocaleString(locale, { minimumFractionDigits: digits, maximumFractionDigits: digits, }); }; export const formatDE = (n: number, digits = 2): string => { return numFormat(n, 'de-DE', digits); }; export const formatCH = (n: number, digits = 2): string => { // Replace the apostrophe with a single quote // there is a bug with Montserrat and Javascript V8 engine and the apostrophe return numFormat(n, 'de-CH', digits).replace(/’/g, "'"); };