/** * Anzeigeformate fuer die Finanzen. Betraege sind immer ganze Cent (Ganzzahl), nie Gleitkomma-Euro. */ // Einmal anlegen (neu anlegen ist teuer); de-DE liefert "1.234,56 €" mit geschuetztem Leerzeichen const euroFormat = new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }) /** Cent als deutscher Euro-Betrag, z. B. 123456 -> "1.234,56 €", -449 -> "−4,49 €" (echtes Minuszeichen U+2212). */ export function euroDe(cents) { if (!Number.isSafeInteger(cents)) throw new Error('Betrag muss eine ganze Zahl in Cent sein.') const text = euroFormat.format(Math.abs(cents) / 100) return cents < 0 ? `−${text}` : text }