Weather forecast one day short

Using WeatherKit I want to get a 5-day forecast starting tomorrow, however, I only get 4 elements in the forecast. What am I missing here?

public func updateWeather()async{
        guard locationManager.location != nil else {locationManager.updateLocation(); return}
        if self.needsUpdating{
            
            let startOfToday = Calendar.current.startOfDay(for: Date())
            let endOfToday = startOfToday+24*3600

            let firstDay:Date = endOfToday+1
            let lastDay:Date = firstDay+(5*24*3600)
            futureWeather = try? await WeatherService.shared.weather(for: locationManager.location!,
           including: .daily(startDate: firstDay, endDate: lastDay)
            )
            
        }
    }
Answered by TheMisfit68 in 770208022

I think I figured it out now, the documentation says that the data for the 'endDate' parameter is excluded from the request. Very confusing especially with the 'including' parameter from the weather method in front of it.

What dates come back in the forecast? Is it tomorrow, t+1, t+2, t+3 and t+4? Or is it tomorrow, t+1, t+2, t+3?

Can you print out the response and see what's coming back?

Have you tried fiddling with the dates? Maybe try 6 * 24 * 3600?

Accepted Answer

I think I figured it out now, the documentation says that the data for the 'endDate' parameter is excluded from the request. Very confusing especially with the 'including' parameter from the weather method in front of it.

Weather forecast one day short
 
 
Q