From 518988251cbed7c66c7901201b32a66e1f6917fa Mon Sep 17 00:00:00 2001 From: Richard Zink Date: Wed, 7 Oct 2026 14:17:55 +0200 Subject: [PATCH] Convert forecast temperatures based on CONFIG.units (slot + minmax) --- index.html | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index dcd683c..07d078e 100644 --- a/index.html +++ b/index.html @@ -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 += '
' + '
' + weatherSVG(slotCode) + '
' + '
' + slotLabels[i] + '
' + - '
' + Math.round(slotTemp) + '°
' + + '
' + convertTemp(slotTemp) + '
' + '
'; } forecastHtml += '
' + '
' + '' + dayLabel + '' + - '' + Math.round(daily.temperature_2m_min[d]) + '° / ' + Math.round(daily.temperature_2m_max[d]) + '°' + + '' + convertTemp(daily.temperature_2m_min[d]) + ' / ' + convertTemp(daily.temperature_2m_max[d]) + '' + '
' + '
' + slotsHtml + '
' + '
';