feat: add weather unit preferences
Some checks failed
CI / Lint, test, typecheck and build (push) Has been cancelled
Some checks failed
CI / Lint, test, typecheck and build (push) Has been cancelled
This commit is contained in:
@@ -3,11 +3,13 @@ import { translate } from "@/lib/i18n";
|
||||
import {
|
||||
DEFAULT_TEMPERATURE_UNIT,
|
||||
DEFAULT_WIND_SPEED_UNIT,
|
||||
DEFAULT_PRECIPITATION_UNIT,
|
||||
formatPrecipitation,
|
||||
formatTemperature,
|
||||
formatWindSpeed,
|
||||
} from "@/lib/weather-utils";
|
||||
import type { DailyForecast, HourlyForecast } from "@/types/forecast";
|
||||
import type { TemperatureUnit, WindSpeedUnit } from "@/types/units";
|
||||
import type { PrecipitationUnit, TemperatureUnit, WindSpeedUnit } from "@/types/units";
|
||||
|
||||
export function getForecastConditionKey(code: number | null): TranslationKey {
|
||||
if (code === 0) return "forecast.condition.clear";
|
||||
@@ -47,9 +49,13 @@ export function formatForecastTemperature(
|
||||
return formatTemperature(value, language, unit);
|
||||
}
|
||||
|
||||
export function formatForecastRainfall(value: number | null, language: Language) {
|
||||
export function formatForecastRainfall(
|
||||
value: number | null,
|
||||
language: Language,
|
||||
unit: PrecipitationUnit = DEFAULT_PRECIPITATION_UNIT,
|
||||
) {
|
||||
if (value === null) return "—";
|
||||
return `${new Intl.NumberFormat(language === "pl" ? "pl-PL" : "en-GB", { maximumFractionDigits: 1 }).format(value)} mm`;
|
||||
return formatPrecipitation(value, language, unit);
|
||||
}
|
||||
|
||||
export function formatForecastWind(
|
||||
|
||||
Reference in New Issue
Block a user