I am consuming the international weather forecasts via Wunderground’s XML API:
http://wiki.wunderground.com/index.php/API_-_XML
Looking at an output for Kabul, Afghanistan for instance:
http://api.wunderground.com/auto/wui/geo/ForecastXML/index.xml?query=OAKB
I notice that there is no UTC offset. The closest that I can see is this:
<tz_short>AFT</tz_short>
Which identifies the current TimeZone is AFT. The problem I see is that there is no universally accepted time zone abbreviations, so I cannot take these abbreviations and look up and offset from C#’s TimeZoneInfo objects.
Is there a listing of Wunderground’s Time Zones abbreviations/names/offsets so I can map their Time Zones to the TimeZoneInfo objects, or is there a better way to get this information? I will need to use the TimeZoneInfo so I can calculate daylight savings time for different locations internationally.
Here is an idea of what you can do to acquire a UTC offset.
Use the
epochfield from the XML output, which will be in UNIX time (number of seconds since 1970-01-01 00:00). This time will be in UTC/GMT. Then, either by converting the contents of theprettyfield, or by using the day/month/year/hour/minute/second fields, determine the difference between the published local time and the epoch time. This will give you your UTC offset. There is also aisdstfield to tell you whether or not the zone is honoring DST at the moment.Unfortunately I don’t know of a comprehensive list of time zone abbreviations, so using the method above to determine the offset and DST is probably your best option. Good luck!