1 | const CURRENCY_FORMATTER: Intl.NumberFormat = new Intl.NumberFormat('de-DE', {
|
2 | currency: 'EUR',
|
3 | maximumFractionDigits: 2,
|
4 | minimumFractionDigits: 2,
|
5 | });
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | const DATE_FORMATTER: Intl.DateTimeFormat = new Intl.DateTimeFormat('de-DE');
|
13 |
|
14 | export class Filters {
|
15 | public static currency(value: number): string {
|
16 | if (isNaN(value) === false && typeof value === 'number') {
|
17 | return CURRENCY_FORMATTER.format(value);
|
18 | } else {
|
19 | throw new Error('Value is not a number!');
|
20 | }
|
21 | }
|
22 |
|
23 | public static date(value: Date): string {
|
24 | if (value instanceof Date) {
|
25 | return DATE_FORMATTER.format(value);
|
26 | } else {
|
27 | throw new Error('Value is not a date!');
|
28 | }
|
29 | }
|
30 | }
|