dailyStatistics(for:startDay:endDay:including:)
Returns daily weather statistics for the requested location, for each day from the start day to the end day, inclusively.
Declaration
final func dailyStatistics<each T>(for location: CLLocation, startDay: Int, endDay: Int, including dataSets: repeat DailyWeatherStatisticsQuery<each T>) async throws -> (repeat DailyWeatherStatistics<each T>) where repeat each T : Decodable, repeat each T : Encodable, repeat each T : Equatable, repeat each T : SendableParameters
- location:
The requested location.
- startDay:
The first day of the span, between 1 and 366.
- endDay:
The last day of the span, between 1 and 366.
Return Value
The requested daily weather statistics
Discussion
The statistics returned for each day are derived from weather data recorded over the past decades, to the present date. Each item returned represents statistics for a particular day of the year, in UTC.
This is a variadic API in which any combination of data sets can be requested and returned as a tuple. The following example will return statistics for the first 10 days of the year.
let (dailyPrecipitationStatistics, dailyTemperatureStatistics) = try await service.dailyStatistics(for: newYork, startDay: 1, endDay: 10, including: .precipitation, .temperature)If startDay is greater than endDay, then a wrap around will occur. This next example will return statistics for days 365, 366, 1, and 2.
let (dailyPrecipitationStatistics, dailyTemperatureStatistics) = try await service.dailyStatistics(for: newYork, startDay: 365, endDay: 2, including: .precipitation, .temperature)