feat: describe current sky in weather hero

This commit is contained in:
zv
2026-06-14 11:00:25 +02:00
parent 4b28e281c1
commit a9b0c65527
4 changed files with 26 additions and 7 deletions

View File

@@ -237,11 +237,25 @@ export function getWeatherMoodFromData(station: SynopStation, date = new Date())
return "mild";
}
export function getWeatherDescription(station: SynopStation, language: Language = "pl", condition?: CurrentWeatherCondition) {
function getForecastConditionDescription(code: number | null, language: Language) {
if (code === 0) return translate(language, "forecast.condition.clear");
if (code === 1 || code === 2) return translate(language, "forecast.condition.partlyCloudy");
if (code === 3) return translate(language, "forecast.condition.cloudy");
if (code === 45 || code === 48) return translate(language, "forecast.condition.fog");
if (code !== null && code >= 51 && code <= 57) return translate(language, "forecast.condition.drizzle");
if (code !== null && ((code >= 61 && code <= 67) || (code >= 80 && code <= 82))) return translate(language, "forecast.condition.rain");
if (code !== null && ((code >= 71 && code <= 77) || code === 85 || code === 86)) return translate(language, "forecast.condition.snow");
if (code !== null && code >= 95) return translate(language, "forecast.condition.thunderstorm");
return null;
}
export function getWeatherDescription(station: SynopStation, language: Language = "pl", condition?: CurrentWeatherCondition, forecastWeatherCode?: number | null) {
if (condition === "thunderstorm") return translate(language, "weather.thunderstorm");
if (condition === "snow") return translate(language, "weather.currentSnow");
if (condition === "rain") return translate(language, "weather.currentRain");
if ((station.windSpeed ?? 0) >= 8) return translate(language, "weather.strongWind");
const forecastDescription = getForecastConditionDescription(forecastWeatherCode ?? null, language);
if (forecastDescription) return forecastDescription;
if ((station.humidity ?? 0) >= 90) return translate(language, "weather.humid");
return translate(language, "weather.calm");
}