import { LocaleTag } from './Locale.js'; /** * Wraps `Intl.NumberFormat` with the active locale (`Locale.get()` if omitted). */ export declare function formatNumber(value: number, options?: Intl.NumberFormatOptions, locale?: LocaleTag): string; /** * Formats a number as currency. The `currency` code is **required and has no default** — * the caller must always specify it (e.g. `'KRW'`, `'USD'`). Currency selection is domain knowledge, * and this utility does not assume a default. * * @note If `options` contains `currency` or `style`, they will override the explicit `currency` argument. */ export declare function formatCurrency(value: number, currency: string, options?: Intl.NumberFormatOptions, locale?: LocaleTag): string; /** * Wraps `Intl.DateTimeFormat` with the active locale. Accepts a Date object or * an ISO `YYYY-MM-DD` date string (parsed as local time, not UTC). * * A value that can't be resolved to a real date (malformed string, or an * already-Invalid `Date`) degrades to `String(value)` rather than throwing — * `Intl.DateTimeFormat.format()` throws `RangeError` on an Invalid Date, and this * utility is called from render paths where an uncaught throw blanks the whole * component. * * ⚠This degrade is **deliberately not symmetric** with {@link formatCurrency}, which * throws `RangeError` on an invalid currency code. A date arrives as *data* — from an * API, a user, a stale cache — so a bad one is an expected runtime state. A currency * code is written by the developer at the call site, so a bad one is a bug that should * surface at the first render rather than be papered over with a wrong-looking amount. */ export declare function formatDate(value: Date | string, options?: Intl.DateTimeFormatOptions, locale?: LocaleTag): string; /** * Formats a date range with the active locale, via `Intl.DateTimeFormat#formatRange` — the * locale decides the separator and drops the parts the two ends share (`Mar 6 – Apr 3, 2026`, * `2026. 3. 6. ~ 4. 3.`). Accepts Date objects or ISO `YYYY-MM-DD` strings (local time). * * Like {@link formatDate}, an end that can't be resolved to a real date degrades instead of * throwing: both invalid → the two raw values joined with ` – `; one invalid → that raw value * stands in for its formatted side. */ export declare function formatDateRange(start: Date | string, end: Date | string, options?: Intl.DateTimeFormatOptions, locale?: LocaleTag): string; /** * Reads a number the way a person types it, in any locale — the inverse of {@link formatNumber}. * Returns `null` for text that is not a number; never a partial number (`"1,5x"` is `null`, not 1.5). * * Which separator is the decimal one: * - `.` and `,` both present → the **last** one is decimal, the other groups (`1.234,5` and * `1,234.5` are both 1234.5). * - one separator, repeated → it groups (`1.234.567` → 1234567). * - a single `.` → decimal (`0.125` stays 0.125 on a comma-decimal page — people type dots). * - a single `,` → decimal, except when the locale writes decimals with `.` and exactly three * digits follow (`1,234` on an English page → 1234). * * Grouping (by either separator, spaces or apostrophes) must come in threes after a first group of * one to three digits — `1,23,4` is `null`. A leading `+`, `-` or `−` sets the sign. * * An exponent may follow, as in a native number input: `e` or `E`, an optional sign, digits * (`1e7`, `1.5e-6`, `2E+3`). The separator rules above apply to the part before it (`1,5e3` on a * comma-decimal page is 1500); the exponent is never grouped. `e5`, `1e` and `1e+` are `null`. * Reading exponents also lets every string `String(number)` writes come back (`1e-7`, `1e+21`). * `locale` defaults to the active `Locale`. */ export declare function parseNumber(text: string, locale?: LocaleTag): number | null; /** How a date is written in a text field: ISO `YYYY-MM-DD`, or the locale's numeric order (`10/02/2026`, `02.10.2026`). */ export type DateTextFormat = 'iso' | 'locale'; /** * Writes an ISO `YYYY-MM-DD` date the way {@link parseDate} reads it back: `iso` keeps it as is; * `locale` uses the locale's numeric order with two-digit month and day (`10/02/2026` in `en-US`, * `02.10.2026` in `de`). A string that is not an ISO date is returned unchanged. */ export declare function formatDateText(iso: string, format?: DateTextFormat, locale?: LocaleTag): string; /** The pattern a person should type for `format` — `YYYY-MM-DD`, or e.g. `MM/DD/YYYY` for `locale` in `en-US`. */ export declare function dateTextPattern(format?: DateTextFormat, locale?: LocaleTag): string; /** * Reads a date the way people type it into a field and returns it as ISO `YYYY-MM-DD`, or `null` * when the text is not a real date (`2026-02-30` is `null`). Accepted, whatever `format` is: * - `2026-10-02`, `2026/10/02`, `2026.10.02`, `2026. 10. 2.` — a four-digit first part is year-month-day; * - `20261002` — eight digits are year, month, day. * * `format` decides the rest: with `iso`, three parts are year-month-day and two parts (`10-02`) * are month-day; with `locale`, both follow the locale's numeric order (`10/02/2026` and `10/02` * in `en-US`, `02.10.2026` and `2.10` in `de`). Two parts take the year of `referenceDate` * (today by default). Two-digit years are not read. */ export declare function parseDate(text: string, options?: { format?: DateTextFormat; locale?: LocaleTag; referenceDate?: Date; }): string | null; /** * Reads a date and a time of day as people type them and returns local `YYYY-MM-DDTHH:mm`, or `null`. * The date part is anything {@link parseDate} reads; the time follows a space or `T` as `HH:mm` * (`9:05`, `09:05`, `09:05:30` — seconds are dropped). With `seconds`, the result is * `YYYY-MM-DDTHH:mm:ss` and typed seconds are kept (`:00` when none are typed). Text with only a date * takes `defaultTime` (`00:00` unless given). An hour above 23, or a minute or second above 59, is `null`. */ export declare function parseDateTime(text: string, options?: { format?: DateTextFormat; locale?: LocaleTag; referenceDate?: Date; defaultTime?: string; seconds?: boolean; }): string | null; /** * Writes local `YYYY-MM-DDTHH:mm` (or a longer ISO date-time) as `{date} HH:mm`, the date part as * {@link formatDateText} writes it — `{date} HH:mm:ss` with `seconds`. */ export declare function formatDateTimeText(isoLocal: string, format?: DateTextFormat, locale?: LocaleTag, seconds?: boolean): string; /** * Reads a period of days as people type it — `2026-10-01 ~ 2026-10-31`, `2026-10-01 – 10-31`, * the ISO interval `2026-10-01/2026-10-31`, or a single day (a one-day range) — and returns * `{ start, end }` as ISO dates, earlier first, or `null`. Each day is read by {@link parseDate}; a * short second day (`10-31`) takes the first day's year, or the next year when it would otherwise * fall before the first day (`2025-12-20 ~ 01-05`). */ export declare function parseDateRange(text: string, options?: { format?: DateTextFormat; locale?: LocaleTag; referenceDate?: Date; }): { start: string; end: string; } | null; /** Writes a period as `{start} – {end}`, each day as {@link formatDateText} writes it. */ export declare function formatDateRangeText(start: string, end: string, format?: DateTextFormat, locale?: LocaleTag): string; /** * Reads a period with times of day — `2026-10-01 09:00 ~ 2026-10-31 18:00`, `2026-10-01 09:00 ~ 18:00` * (a time alone ends on the first day), the ISO interval `2026-10-01T09:00/2026-10-31T18:00`, or the * day forms {@link parseDateRange} reads — and returns `{ start, end }` as local `YYYY-MM-DDTHH:mm`, * earlier first, or `null`. A day typed without a time takes `startTime` (default `00:00`) at the * start and `endTime` (default `23:59`) at the end, so a period of days covers them whole; one day * alone runs from `startTime` to `endTime` that day. A short second day takes the first day's year, * or the next year when it would otherwise fall before the first day. With `seconds`, both ends are * `YYYY-MM-DDTHH:mm:ss` (see {@link parseDateTime}). */ export declare function parseDateTimeRange(text: string, options?: { format?: DateTextFormat; locale?: LocaleTag; referenceDate?: Date; startTime?: string; endTime?: string; seconds?: boolean; }): { start: string; end: string; } | null; /** Writes a period with times as `{start} – {end}`, each as {@link formatDateTimeText} writes it. */ export declare function formatDateTimeRangeText(start: string, end: string, format?: DateTextFormat, locale?: LocaleTag, seconds?: boolean): string;