views:

116

answers:

2

In C++ on Windows, given a city, lets say london or newyork or sydney or singapore etc.. how do I find the UTC offset for each of them, ie the function should be able to accept a city name and return the UTC offset in the current scenario ie taking into account daylight savings. Any ideas how this can be done using win32 APIs

+1  A: 

Sounds like you want an API for searching the zoneinfo / tz database..?

Don't know if there is a library with precisely the interface you want. But reading it and searching it yourself would not be difficult. It's just a flat file database, text with one record per line.

http://en.wikipedia.org/wiki/Zone.tab

Hostile Fork
More specifically, can I get the timezeone the city is currently observing given the city name in windows?
soccerfan
A: 

If you can get a latitude and longitude for the input city, you can use http://www.earthtools.org/timezone-1.1/<latitude>/<longitude> to determine the time zone that applies there. Specs are at http://www.earthtools.org/webservices.htm.

mobrule