hourlyStatistics(for:forHoursIn:including:)
Returns hourly weather statistics for the requested location, for each hour within the specified date interval.
Declaration
final func hourlyStatistics<each T>(for location: CLLocation, forHoursIn interval: DateInterval, including dataSets: repeat HourlyWeatherStatisticsQuery<each T>) async throws -> (repeat HourlyWeatherStatistics<each T>) where repeat each T : Decodable, repeat each T : Encodable, repeat each T : Equatable, repeat each T : SendableParameters
- location:
The requested location.
- interval:
The date interval for which to obtain hourly weather statistics.
Return Value
The requested hourly weather statistics.
Discussion
The statistics returned for each hour are derived from weather data recorded over the past decades, to the present date. Each item returned represents statistics for a particular hour of the year, in UTC. For example, if the hours of December 31, UTC time, are within the span, the statistics returned for those particular hours will be taken from data recorded over the years for hours 8737 to 8760 of the year, or 8761 to 8784 if December 31 of the span falls on a leap year.
This is a variadic API in which any combination of data sets can be requested and returned as a tuple. Here’s an example:
let hourlyTemperatureStatistics = try await service.hourlyStatistics(for: newYork, forHoursIn: interval, including: .temperature)