After more testing I have found that this is tied to the user's Region/country setting. My user in Germany was able to get the correct temperatures for Dresden when she changed her region setting on her iPhone to USA. I also saw that, if I change my region to Germany, I get incorrect temperatures, and when I change it back to USA I get correct temperatures for Germany. I went on to check every region in the App Store and found 100 out of the 172 regions/countries working and 72 not working.
Post
Replies
Boosts
Views
Activity
Hi! Can you please share how you got WeatherKit to give you the gust value in your sample output above? I've been trying to get this from my query but I always get 0.00000 for gust. I can see all the other values. Note: I am using WeatherKit to obtain historical data (not forecast data), but it does work for the regular wind speed and other parameters, just not gust. Thanks!
I've see this before and in my case it was because Date() returns the date at UTC and NOT the local date. So, depending on the time of day that the Date() function is called and where the device is located, you might get a date result that is NOT the local date of the device! It took me a while to figure this one out. To avoid problems with this, you would need to pass the local date to WeatherKit if you want to startDate to be the current date at the device's location. Luckily, there is a nice extension on StackOverflow that gives you a Date().localDate() function that fixes this issue. https://stackoverflow.com/questions/28404154/swift-get-local-date-and-time
Is this currently working? When I try this code with a date range shorter than 10 days I get back the historical high and low temperatures for the first and last date only; not for all the dates in the date range. Sample code is the same as the one given by @JohnOfSF above. Here's a sample output:
Aborting silent interpolation: additional missing products that need to be fetched from the server anyway; location=CLLocationCoordinate2D(latitude: 37.77, longitude: -122.41), missing products=[WeatherDaemon.WeatherProduct.forecastDaily]
days count=4, date range=2023-10-18 07:00:00 +0000 to 2023-10-21 07:00:00 +0000, first condition=Mostly Clear, first high=28.52 °C, first low=14.12 °C, last condition=Partly Cloudy, last high=19.17 °C, last low=13.05 °C
Note the missing data for the days in between 10/18/2023 and 10/21/2023. Is this how this is supposed to work? If so, what is the point of providing a data range? Is there a different call/function I should be using to get all the data for the entire date range?
I have a similar issue but I have gotten a step further. I am using a call similar to the one posted by @Jklr above. I am using this:
let weather = try await weatherService.weather(for: location, including: .daily(startDate: startDate, endDate: endDate))
When I try a date range greater than 10 days, I get an error. This, I suppose, makes sense since the docs say we are limited to pulling 10 days at a time. So I tried the call with a startDate of 5 days ago and an endDate of 1 day ago. This got me a bit further. I actually got some data! The returned the data is below:
days count=4, date range=2023-10-18 07:00:00 +0000 to 2023-10-21 07:00:00 +0000, first condition=Mostly Clear, first high=28.52 °C, first low=14.12 °C, last condition=Partly Cloudy, last high=19.17 °C, last low=13.05 °C
Question is - why does it not return data for each day in the requested date range? It only returns data for the startDate and the endDate - not the days in between. Is this how this is supposed to work? Shouldn't it return a list of dates with high and low temps for each day; not just the first and last conditions?
Also - why is there a 10 day limit for historical data? I can understand a 10 day limit for future forecasts but why limit historical???