{#if fetchedDaily}
{#each fetchedDaily.dailyDates as time, index (index)}
{@const selected = time.getDate() === selectedDay.getDate()}
{@const tempMax = fetchedDaily.daily.temperature_2m_max[index]}
{@const tempMin = fetchedDaily.daily.temperature_2m_min[index]}
{@const wCode = fetchedDaily.daily.weather_code[index]}
{@const sunDuration = fetchedDaily.daily.sunshine_duration[index]}
{@const precipSum = fetchedDaily.daily.precipitation_sum[index]}
{#if tempMax != null && !isNaN(tempMax)}
{/if}
{/each}
{/if}
{selectedDay.toLocaleDateString('en-GB', { weekday: 'long' })}
{selectedDay.getDate() === new Date(today.getTime() - 24 * 60 * 60 * 1000).getDate()
? ' (Yesterday)'
: ''}
{selectedDay.getDate() === today.getDate() ? ' (Today)' : ''}
{selectedDay.getDate() === new Date(today.getTime() + 24 * 60 * 60 * 1000).getDate()
? ' (Tomorrow)'
: ''}
{#each chartOptions as option, i (i)}
{/each}
{#if fetchedHourly}
{@const hourly = fetchedHourly.hourly}
{@const dates = fetchedHourly.hourlyDates}
Hourly Details
{/if}
{#if fetchedDaily}
{@const sunriseTs = fetchedDaily.daily.sunrise[selectedDayIndex]}
{@const sunsetTs = fetchedDaily.daily.sunset[selectedDayIndex]}
{#if sunriseTs && sunsetTs}
{@const sunrise = new Date(sunriseTs * 1000)}
{@const sunset = new Date(sunsetTs * 1000)}
Sunrise: {pad(sunrise.getHours())}:{pad(sunrise.getMinutes())}
Sunset: {pad(sunset.getHours())}:{pad(sunset.getMinutes())}