diff --git a/src/routes/weather/week/[location]/+page.svelte b/src/routes/weather/week/[location]/+page.svelte index 79799b0..3bb4081 100644 --- a/src/routes/weather/week/[location]/+page.svelte +++ b/src/routes/weather/week/[location]/+page.svelte @@ -1,26 +1,39 @@ Weather | Open-Meteo.com - +
+
- {#await weatherDaily then wd} - {#each wd.daily.time as time, index (index)} + {#if fetchedDaily} + {#each fetchedDaily.dailyDates as time, index (index)} {@const selected = time.getDate() === selectedDay.getDate()} - {#if wd.daily.temperature_2m_max.values(index) != null && !isNaN(Number(wd.daily.temperature_2m_max - .values(index)! - .toFixed(1)))} + {@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)}
= (params.temperature_unit === 'celsius' ? 30 : 104) ? 'white' : 'black'}`} + style="background-color: {getColor( + tempMax, + String(params.temperature_unit) + )}; color: {tempMin < (params.temperature_unit === 'celsius' ? 4 : 7) || + tempMin >= (params.temperature_unit === 'celsius' ? 30 : 104) + ? 'white' + : 'black'}" > - {wd.daily.temperature_2m_max.values(index)?.toFixed(1)} + {tempMax.toFixed(1)} {params.temperature_unit === 'celsius' ? '°C' : '°F'}
= (params.temperature_unit === 'celsius' ? 30 : 104) ? 'white' : 'black'}`} + style="background: {getColor( + tempMin, + String(params.temperature_unit) + )}; color: {tempMin < (params.temperature_unit === 'celsius' ? 4 : 7) || + tempMin >= (params.temperature_unit === 'celsius' ? 30 : 104) + ? 'white' + : 'black'}" > - {wd.daily.temperature_2m_min.values(index)?.toFixed(1)} + {tempMin.toFixed(1)} {params.temperature_unit === 'celsius' ? '°C' : '°F'}
@@ -371,8 +880,7 @@
- - {Number((wd.daily.sunshine_duration.values(index) ?? 0) / 3600).toFixed(0)}h + {Number((sunDuration ?? 0) / 3600).toFixed(0)}h
@@ -385,19 +893,17 @@
- {Number(wd.daily.precipitation_sum.values(index)).toFixed( - 1 - )}{params.precipitation_unit === 'mm' ? 'mm' : "'"} + {Number(precipSum).toFixed(1)}{params.precipitation_unit === 'mm' ? 'mm' : "'"} {/if} {/each} - {:catch error} -

{error.message}

- {/await} + {/if} -
+ + +

{selectedDay.toLocaleDateString('en-GB', { weekday: 'long' })} @@ -410,219 +916,217 @@ : ''}

+
-
- - - - - {#await weather then weather} + + + + + {#each chartOptions as option, i (i)} + + {/each} + + + + {#if fetchedHourly} + {@const hourly = fetchedHourly.hourly} + {@const dates = fetchedHourly.hourlyDates} +
+

Hourly Details

+
+
+
Weather Week {location.name}
+ + + - - {#each weather.indexes as index, j (j)} + + {#each dates as date, i (i)} + {@const isNow = isCurrentHour(date)} + {@const isMidnight = date.getHours() === 0} - {/each} - - - - - {#each weather.indexes as index, j (j)} - {@const now = - weather.hourlyTime[index].getDate() === today.getDate() && - weather.hourlyTime[index].getHours() === today.getHours()} - + {pad(date.getHours())} + {/each} - + - - {#each weather.indexes as index, j (j)} - {@const temp = weather.entries?.[0]?.values?.[index]} - - {#if temp !== undefined && !isNaN(temp)} - + + + + + {#each dates as date, i (i)} + {@const wCode = hourly.weather_code[i]} + {@const isNow = isCurrentHour(date)} + {@const daytime = isDaytimeHour(date.getHours())} + {@const isMidnight = date.getHours() === 0} + {/each} - {#each weather.entries as entry, i (i)} - - - {#each weather.indexes as index, j (j)} - {#if entry.values && !isNaN(entry.values[index])} - - {/if} - {/each} - - {/each} - {#if winddir} - - - + + + {#each dates as date, i (i)} + {@const temp = hourly.temperature_2m[i]} + {@const isNow = isCurrentHour(date)} + {@const isMidnight = date.getHours() === 0} + + {/each} + + + + + + {#each dates as date, i (i)} + {@const val = hourly.precipitation[i]} + {@const isNow = isCurrentHour(date)} + {@const isMidnight = date.getHours() === 0} + + {/each} + + + + + + {#each dates as date, i (i)} + {@const prob = hourly.precipitation_probability[i]} + {@const isNow = isCurrentHour(date)} + {@const isMidnight = date.getHours() === 0} + + {/each} + + + + + + {#each dates as date, i (i)} + {@const wind = hourly.windspeed_10m[i]} + {@const isNow = isCurrentHour(date)} + {@const isMidnight = date.getHours() === 0} + + {/each} + + + + + + {#each dates as date, i (i)} + {@const hum = hourly.relative_humidity_2m[i]} + {@const isNow = isCurrentHour(date)} + {@const isMidnight = date.getHours() === 0} + + {/each} + + + + + + {#each dates as date, i (i)} + {@const windDir = hourly.winddirection_10m[i]} + {@const isNow = isCurrentHour(date)} + {@const isMidnight = date.getHours() === 0} + + + + {:else} + - {/if} - {/each} - - {/if} - {/await} - -
Hourly weather details for {location.name}
TimeTime{weather.hourlyTime[index].getHours() < 10 ? '0' : ''}{weather.hourlyTime[ - index - ].getHours()}
Icons - -
Temp graph{temp?.toFixed(0)} + - {/if} + + +
{entry.title}{entry.name === 'precipitation' || entry.name === 'temperature_2m' - ? entry.values![index].toFixed(1) - : entry.values![index]}
Wind Dir.
Temperature - {#each weather.indexes as index, j (j)} - {#if weather.windDirections && !isNaN(weather.windDirections[index])} - + {temp?.toFixed(1) ?? '-'} +
Precipitation + {val?.toFixed(1) ?? '-'} +
Precip Prob. + {prob?.toFixed(0) ?? '-'} +
Wind + {wind?.toFixed(0) ?? '-'} +
Rel. Hum. + {hum?.toFixed(0) ?? '-'} +
Wind Dir. + {#if windDir != null && !isNaN(windDir)} +
+ -
+ + {/each} + + + +
+ {/if} + + + +
+
- {#await weatherDaily then wd} - {@const sunrise = new Date(Number(wd.daily.sunrise.valuesInt64(selectedDayIndex)) * 1000)} - {@const sunset = new Date(Number(wd.daily.sunset.valuesInt64(selectedDayIndex)) * 1000)} -
-
- - - Sunrise: {pad(sunrise.getHours())}:{pad(sunrise.getMinutes())} + + + {#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())} +
-
- - - - Sunset: {pad(sunset.getHours())}:{pad(sunset.getMinutes())} -
-
- {/await} + {/if} + {/if} + +
@@ -639,7 +1143,7 @@ }} > {modelSelected?.label} @@ -658,15 +1162,6 @@