/** * Units-aware formatting. * * Every weather output path funnels through these helpers so that a single * `UnitPreferences` object controls how temperature, wind, pressure, * precipitation, distance/visibility, and clock times are rendered. * * Two families of helpers exist: * - `format*From*` take a value in a known canonical/SI source unit and * convert + label it (used for the NOAA path, where values arrive in SI). * - `*Label` + `withLabel` just attach the correct label to a value that is * already in the target unit (used for the Open-Meteo path, where the API * is asked to return values in the requested unit — no re-conversion). */ import { UnitPreferences } from '../config/units.js'; import { QuantitativeValue } from '../types/noaa.js'; import { DateTime } from 'luxon'; export declare function temperatureLabel(prefs: UnitPreferences): string; export declare function windSpeedLabel(prefs: UnitPreferences): string; export declare function precipitationLabel(prefs: UnitPreferences): string; export declare function pressureLabel(prefs: UnitPreferences): string; export declare function distanceLabel(prefs: UnitPreferences): string; /** The Open-Meteo request tokens matching the current preferences. */ export declare function openMeteoUnitParams(prefs: UnitPreferences): { temperature_unit: 'celsius' | 'fahrenheit'; wind_speed_unit: 'mph' | 'kmh' | 'ms' | 'kn'; precipitation_unit: 'inch' | 'mm'; }; /** NOAA forecast endpoint units token (`us` = imperial, `si` = metric). */ export declare function noaaUnitsParam(prefs: UnitPreferences): 'us' | 'si'; export declare function convertTemperatureFromC(celsius: number, prefs: UnitPreferences): number; export declare function convertWindFromMps(mps: number, prefs: UnitPreferences): number; export declare function convertPressureFromPa(pa: number, prefs: UnitPreferences): number; export declare function convertPrecipFromMm(mm: number, prefs: UnitPreferences): number; export declare function convertDistanceFromKm(km: number, prefs: UnitPreferences): number; /** Format a value that is ALREADY in the target unit, attaching the label. */ export declare function withLabel(value: number, label: string, decimals?: number): string; /** * Convert an Open-Meteo `snowfall` (or `snowfall_sum`) value to the * preferred precipitation unit. * * Snowfall is the other field besides `pressure_msl` that does not follow * `openMeteoUnitParams`'s `precipitation_unit` request: Open-Meteo converts * `snowfall` to inches when `precipitation_unit=inch` is sent, but otherwise * reports it in **cm** — not mm like `precipitation`/`rain`/`showers`. The * API's own `current_units` metadata confirms this: `"snowfall": "cm"` * alongside `"precipitation": "mm"`. Same class of trap as the * `pressure_msl` conversion in `currentConditionsHandler.ts`. */ export declare function snowfallToPrecipUnit(value: number, prefs: UnitPreferences): number; export declare function formatTemperatureFromC(celsius: number, prefs: UnitPreferences): string; export declare function formatWindFromMps(mps: number, prefs: UnitPreferences): string; export declare function formatPressureFromPa(pa: number, prefs: UnitPreferences): string; export declare function formatPrecipFromMm(mm: number, prefs: UnitPreferences): string; /** * The visibility figure exactly as `formatVisibilityFromM` prints it — in the * preferred unit, rounded to the one decimal it renders at — so a caller that * bands the descriptor can key on the number the reader sees. Returns the * number, not the string; `formatVisibilityFromM` renders from this. */ export declare function visibilityDisplayValue(meters: number, prefs: UnitPreferences): number; export declare function formatVisibilityFromM(meters: number, prefs: UnitPreferences): string; export declare function formatDistanceFromKm(km: number, prefs: UnitPreferences): string; /** Elevation/height from a metres source: feet for imperial, metres for metric. */ export declare function formatElevationFromM(meters: number, prefs: UnitPreferences): string; /** Height from a feet source (e.g. cloud base, mixing height). */ export declare function formatHeightFromFt(feet: number, prefs: UnitPreferences): string; export declare function formatTemperatureQV(qv: QuantitativeValue | undefined, prefs: UnitPreferences): string; export declare function formatWindSpeedQV(qv: QuantitativeValue | undefined, prefs: UnitPreferences): string; export declare function formatVisibilityQV(qv: QuantitativeValue | undefined, prefs: UnitPreferences): string; export declare function formatPressureQV(qv: QuantitativeValue | undefined, prefs: UnitPreferences): string; /** * Format the time-of-day portion of a Date according to the preferred clock * format (12h vs 24h), optionally in a specific IANA timezone. */ export declare function formatClockTime(date: Date, prefs: UnitPreferences, timeZone?: string): string; /** * Format a Luxon DateTime's time-of-day honoring the 12h/24h preference. * Used for sunrise/sunset lines that are parsed with an explicit zone. */ export declare function formatLuxonTime(dt: DateTime, prefs: UnitPreferences): string; //# sourceMappingURL=unitFormat.d.ts.map