So my previous timezone script needed a makeover. It seems that my client wanted their users to be able to take the thin client systems home. Since they boot embeddedNT and access an NFuse/CSG server, the raw connectivity would work without a problem. Finding the correct timezone and time and setting the same on the client would be a problem, however.
For the internal script, all subnet/timezone information is set in the script, and the timezone determination is therefore straightforward. This was trickier. Since the thin clients would be plugged into home networks, they would get private IP addresses from the SOHO router. The external IP assigned to their cable/DSL gateway would be all that I could use to determine the local timezone of the client.
I found MaxMind. They offer IP-to-country/state/city databases. It's possible to purchase a fixed database in a variety of formats, a subscription to same, or access to an HTTP-based webservice that is measured in queries. 50,000 queries for $20. The price was right. So we can now map IP addresses to cities and states with relatively little hassle. MaxMind provides longitude and latitude coordinates with the dataset, but no timezone information. I then found another company offering a fixed CSV file with 70,000+ city/state/areacode/zipcode/timezone entries in the US alone. If it wasn't distributed in a self-extracting win32 executable and quoted it would be better, but it's otherwise perfect.
So a client connects from a public IP, and a query is launched to MaxMind that brings in the closest US city, which is then matched against the CSV database, and the timezone code is returned to the client in the same format that is used to set the timezone when the thin client is running on the WAN. Voila. This was developed on Linux, but runs with ActivePerl on W32 without alteration.
You can find the script on groove: groove.jpj.net/ext-tz.txt