Search code examples
c#azureasp.net-coreazure-maps

Microsoft Azure Map – Weather Preview


Hello

I’m calling Weather - Get Hourly Forecast API, using C# back-end. As {query} I’m passing different LAT/LON coordinates from around the world and retrieve their forecasts. https://learn.microsoft.com/en-us/rest/api/maps/weather/gethourlyforecastpreview#hourlyforecast

Question: How can I retrieve the forecast with the date/time zone of location, that I’m checking? Right now, I can only get a forecast with the date/time of my initial request location.

Documentation is not providing information about any parameter, that could be pass, to change this.

Any help will be appreciated!


Solution

  • That API returns the "date" property for each forecast in the ISO 8601 format, including the timezone offset. So, while it does not explicitly list a timezone as a string, you can determine its timezone by parsing the offset from UTC.

    If you are willing to make a separate API call, you can use the Get Timezone by Coordinates endpoint to pass in your lat/long and get the detailed zone info:

    Docs: https://learn.microsoft.com/en-us/rest/api/maps/timezone/gettimezonebycoordinates

    Endpoint: https://atlas.microsoft.com/timezone/byCoordinates/json?api-version=1.0&query={query}