From f377d0b1c8084b681ef5d9b62234f8b7bd26759c Mon Sep 17 00:00:00 2001 From: ztimson Date: Wed, 24 Jun 2026 16:31:07 -0400 Subject: [PATCH] Fixing current forecast --- server/src/forecast.mjs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server/src/forecast.mjs b/server/src/forecast.mjs index 73b1c85..9b7a753 100644 --- a/server/src/forecast.mjs +++ b/server/src/forecast.mjs @@ -175,8 +175,10 @@ export async function get24HourForecast(currentSensors) { // Second pass — apply solar heating now that we have sun_elevation per slot for (const slot of enriched) { if (slot.sunrise && slot.sunset) { - const t = new Date(slot.time).getTime(); - slot.daytime = t >= new Date(slot.sunrise).getTime() && t < new Date(slot.sunset).getTime(); + const t = slot.time instanceof Date ? slot.time.getTime() : new Date(slot.time).getTime(); + const rise = slot.sunrise instanceof Date ? slot.sunrise.getTime() : new Date(slot.sunrise).getTime(); + const set = slot.sunset instanceof Date ? slot.sunset.getTime() : new Date(slot.sunset).getTime(); + slot.daytime = t >= rise && t < set; } else { slot.daytime = (slot.sun_elevation ?? 0) > 0; }