Sunday, September 13, 2015

Get Windows TimeZoneInfo from Latitude and Longitude


In a web app I have people enter their address, then I use Google's geocode API to get their latitude and longitude. Next, I would like to get their Windows time zone name using these coordinates so I can deal with Daylight Savings Time correctly via the .Net TimeZoneInfo object.
I played with several of the available time zone web services to get the time zone name such as:
The issue is that these all return either just the offset from GMT, or the TZID (a.k.a. Olson) time zone name, not the Windows Time Zone name.
There is a listing at this following link that translates from Windows to TZID names, but not in the opposite direction since many of the TZID names are missing. For example, if the TZID I get from the first step is "Africa/Lusaka" then the table won't find an equivalent Windows Time Zone Name.
So my question is, does anyone know of a service that can return a Windows Time Zone Name via lat/lon or if there is a complete listing or translation service to convert between the two naming formats?
Note: I have reviewed all the similar questions here, but none have completely solved this issue.
shareimprove this question

2 Answers

One workaround would be to get the Olson name and then use Noda Time to perform the relevant time zone calculations, as that's based on the Olson names.
We're not quite "done" with Noda Time yet, but we're getting closer and closer to a 1.0 release - and you could always limit yourself to the time zone part if you wanted, and do the rest in .NET. That would isolate you from any areas we're still sorting out, such as formatting, parsing and the best API to expose for performing arithmetic. Admittedly I'd like to hope that the rest of the API appeals to you and entices you in... or that you'd want to comment on it and tell us how you'd want to use it :)
I'm hoping to add DateTime and DateTimeOffset conversions into the codebase in the next couple of days - if you can ping the mailing list with exactly what you need, I can try to accommodate you.
Apologies that this is only a workaround rather than a full fix. I will investigate providing more Windows zone name mapping information in Noda Time - that uses CLDR as well, but with more information from the Olson database, we may be able to find equivalents easily.
shareimprove this answer
   
Duke Nukem Forever is going to get finished first. –  Hans Passant Aug 16 '11 at 23:02
1 
@Hans: Nope, I'm absolutely determined (and making progress) - and Noda Time doesn't need to be completely finished, just enough to perform all the required time zone conversions, and that's already done. –  Jon Skeet Aug 16 '11 at 23:03 
1 
@Downvoters: Care to comment? In what way is this unhelpful? Given the absence of other options, why not use a small part of Noda Time? –  Jon Skeet Aug 17 '11 at 5:41
Just found this online which may be a solution. Will investigate further:
shareimprove this answer

Your Answer http://stackoverflow.com/questions/7084246/get-windows-timezoneinfo-from-latitude-and-longitude?rq=1