File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed
internal/templates/partials Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change 262
262
"lang" : {
263
263
"type" : " string"
264
264
},
265
+ "forecast" : {
266
+ "type" : " boolean" ,
267
+ "default" : false ,
268
+ "description" : " Whether to include 3 day forecast data"
269
+ },
265
270
"default" : {
266
271
"type" : " boolean"
267
272
}
Original file line number Diff line number Diff line change @@ -79,9 +79,10 @@ templ weatherIcon(ID int) {
79
79
}
80
80
}
81
81
82
- func forecastItemData (datetime int ) (bool , string ) {
83
- t := time.Unix (int64 (datetime), 0 )
84
- now := time.Now ().In (t.Location ())
82
+ func forecastItemData (datetime , tzOffset int ) (bool , string ) {
83
+ loc := time.FixedZone (" owm" , tzOffset)
84
+ t := time.Unix (int64 (datetime), 0 ).In (loc)
85
+ now := time.Now ().In (loc)
85
86
isToday := t.Year () == now.Year () &&
86
87
t.Month () == now.Month () &&
87
88
t.Day () == now.Day ()
@@ -118,7 +119,11 @@ templ WeatherLocation(weatherData weather.Location) {
118
119
<div class =" weather--forecast" >
119
120
for _ , f := range weatherData.Forecast .List {
120
121
{{
121
- isToday , forecastDay := forecastItemData (f.DT )
122
+ if len (f.Data ) == 0 {
123
+ continue
124
+ }
125
+
126
+ isToday , forecastDay := forecastItemData (f.DT , weatherData.Timezone )
122
127
if isToday {
123
128
continue
124
129
}
You can’t perform that action at this time.
0 commit comments