Get weather for given date on given location (REST API)

My goal ist to get the weather of a given day (e.g. 2022-01-14) and a given location (without knowing the timezone) using the "forecastDaily" dataSet. The API does not seem to accept timestamps without date information so I use UTC midnight as dailyStart (e.g. "2022-01-14T00:00:00Z") and dailyEnd (e.g. "2022-01-15T00:00:00Z") . This seems to work for most regions, like with the ones with a positive longitude, but the more I go west, the API returns 2 days in the "days" list of "forecastDaily" and in some extremes (like Hawaii) the wrong (previous) day is returned from the API.

Specific example:

  • dailyStart: 2022-01-14T00:00:00Z
  • dailyEnd: 2022-01-15T00:00:00Z
  • request weather for Kiribati (UTC+14): returns day with forecastStart 2022-01-13T10:00:00Z -> this is what I want
  • request weather for Hawaii (UTC-10): returns day with forecastStart 2022-01-13T10:00:00Z -> this is not what I want, as this is the weather for 2022-01-13 and not 2022-01-14

As Hawaii and Kiribati are about the same longitude I also cannot make any assumptions based on longitude alone. As the API doesn't return the local timezone (as the DarkSky API has been doing) I also cannot use this info that. I would have to have full knowledge of where the timezone boundaries are. The core problem is that I have to provide a "timezoned" parameter for dailyStart and dailyEnd. I would want to provide just the date, like "2022-01-14".

Is there no easy way to get the weather for any place on earth solely based on the date?

The days in the daily forecast start at the first hour of the day in the timezone specified in the timeZone parameter. Usually that means midnight, but in time zones where Daylight Savings Time skip the midnight hour it could be 1 AM.

When you specify a dailyStart parameter, that time is truncated to the start of the day in that same time zone since day forecasts always start at the beginning of the day. No matter what time you specify it is always truncated to the start of the day to give a full day's forecast.

If you specify your dailyStart in UTC, that time is first translated to the specified time zone and then truncated to the start of the day. In your Hawaii example above, the dailyStart of 2022-01-14T00:00:00Z (in UTC) would be translated to the equivalent local time of 2022-01-13T14:00:00-10:00 (in UTC-10) and then truncated to start of day (midnight) local time which is 2022-01-13T00:00:00-10:00 which is 2022-01-13:10:00:00Z in UTC.

WeatherKit does not return the timezone because it takes the time zone as a parameter and uses what the caller specifies.

Get weather for given date on given location (REST API)
 
 
Q