fix: show rain icon for likely hourly precipitation
All checks were successful
CI / Lint, typecheck and build (push) Successful in 9m55s

This commit is contained in:
zv
2026-06-14 12:52:42 +02:00
parent bc8c346a7b
commit d572c9cc53
3 changed files with 34 additions and 17 deletions

View File

@@ -20,6 +20,17 @@ export function getForecastCondition(code: number | null, language: Language) {
return translate(language, getForecastConditionKey(code));
}
function isDryWeatherCode(code: number | null) {
return code === null || (code >= 0 && code <= 3) || code === 45 || code === 48;
}
export function getEffectiveHourlyWeatherCode(hour: Pick<HourlyForecast, "weatherCode" | "precipitation" | "precipitationProbability">) {
const hasMeasuredPrecipitation = (hour.precipitation ?? 0) > 0;
const hasLikelyPrecipitation = (hour.precipitationProbability ?? 0) >= 70;
if (isDryWeatherCode(hour.weatherCode) && (hasMeasuredPrecipitation || hasLikelyPrecipitation)) return 61;
return hour.weatherCode;
}
export function formatForecastTemperature(value: number | null, language: Language, unit: TemperatureUnit = DEFAULT_TEMPERATURE_UNIT) {
if (value === null) return "—";
return formatTemperature(value, language, unit);