Convert forecast temperatures based on CONFIG.units (slot + minmax)

This commit is contained in:
Richard Zink committed 2026-10-07 14:17:55 +02:00
1 parent 5e9ddd8590
commit 518988251c
1 file changed
+8 -2
+8 -2
View File
@@ -1780,6 +1780,12 @@ window.weatherThemes = {
} else if (i === 3 && d === 0) {
slotDate.setDate(slotDate.getDate() + 1);
}
var currentUnits = (window.CONFIG && window.CONFIG.units) || 'metric';
var convertTemp = function(c) {
return currentUnits === 'imperial'
? Math.round(c * 9 / 5 + 32) + '\u00b0F'
: Math.round(c) + '\u00b0C';
};
var slotIdx = findHourlyIndex(slotDate, hourly.time);
var slotCode = hourly.weather_code[slotIdx];
var slotTemp = hourly.temperature_2m[slotIdx];
@@ -1787,14 +1793,14 @@ window.weatherThemes = {
slotsHtml += '<div class="weather-slot">' +
'<div class="weather-slot-icon">' + weatherSVG(slotCode) + '</div>' +
'<div class="weather-slot-label">' + slotLabels[i] + '</div>' +
'<div class="weather-slot-temp">' + Math.round(slotTemp) + '°</div>' +
'<div class="weather-slot-temp">' + convertTemp(slotTemp) + '</div>' +
'</div>';
}
forecastHtml += '<div class="weather-day">' +
'<div class="weather-day-header">' +
'<span class="weather-day-name">' + dayLabel + '</span>' +
'<span class="weather-day-minmax">' + Math.round(daily.temperature_2m_min[d]) + '° / ' + Math.round(daily.temperature_2m_max[d]) + '°</span>' +
'<span class="weather-day-minmax">' + convertTemp(daily.temperature_2m_min[d]) + ' / ' + convertTemp(daily.temperature_2m_max[d]) + '</span>' +
'</div>' +
'<div class="weather-day-slots">' + slotsHtml + '</div>' +
'</div>';