fix: show rain icon for likely hourly precipitation
All checks were successful
CI / Lint, typecheck and build (push) Successful in 9m55s
All checks were successful
CI / Lint, typecheck and build (push) Successful in 9m55s
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user