[title]NTP with auto detection of timezone and DST[/title]
In this code an implementation of NTP client and auto-detection classes for actual timezone. To avoid too large assemblies, I did not use any XML or JSON parsing classes. If your application is using XML or JSON parsing, the use of those here could reduce code size.
The code refreshes local time with NTP server in a configurable number of hours. I noticed that on my device with 10 hours the clock gets drifted in couple of seconds. Use 5-6 hours for refresh. This is the main reason I wrote this code… I did not implement a refresh when DST turns on or off. If anyone adds that, please share.
The code here works on NetduinoPlus device, and should easily deployed on any FEZ device.
How it Works:
By quering geobytes.com and askGeo.com I am finding the actual time-zone of the device:
Through geobytes.com I am finding my location in the world
Through askGeo.com I am finding the timezone data of this location
This auto-detection will work if the device is connected to the internet through standard NAT configuration, but with remote proxies the auto-detection will be
wrong as it will detect the timezone of the proxy itself. For most applications however it is good enough.
Don’t expect a GPS accuracy for your location. It will probably get you the name of city/town where your ISP is, and not your actual location, still for timezone purposes this good enough.
In this code an API Key that is registered to the author of this code.
Please modify it to your registered key <<<<
Search below for <<<< to location of where you need to put your key
You may use the code, modify or include in any project you have, posted in the hope it will be useful.
Please read http://www.geobytes.com Terms and Conditions