View as Markdown

API reference: @salmonui/core/format

Formatterinterface

import type { Formatter } from '@salmonui/core/format';
interface Formatter {
    readonly locale: string;
    readonly currency: string;
    readonly timeZone: string | undefined;
    format(value: unknown, format?: string | FormatOptions, type?: ColumnType): string;
    number(value: unknown, format?: string | FormatOptions): string;
    date(value: unknown, format?: string | FormatOptions): string;
    dateTime(value: unknown, format?: string | FormatOptions): string;
    money(value: unknown, fractionDigits?: number, currency?: string): string;
    percent(value: unknown, fractionDigits?: number): string;
}
Formatter members (9)
NameSignatureDescription
localereadonly locale: string;
currencyreadonly currency: string;
timeZonereadonly timeZone: string | undefined;
formatformat(value: unknown, format?: string | FormatOptions, type?: ColumnType): string;

Formats like a column format: number presets (N2, C, P1), number patterns (#,##0.00), date skeletons (yMMMd) and styles (short), date patterns (dd/MM/yyyy HH:mm), or FormatOptions. type defaults to date for Date values and number for numbers.

numbernumber(value: unknown, format?: string | FormatOptions): string;
datedate(value: unknown, format?: string | FormatOptions): string;
dateTimedateTime(value: unknown, format?: string | FormatOptions): string;
moneymoney(value: unknown, fractionDigits?: number, currency?: string): string;
percentpercent(value: unknown, fractionDigits?: number): string;