Ron McLeod wrote:Are you working with a single device or a fleet of devices?
Is the device constantly moving or is it stationary at times?
What is the speed at which the device moves?
What accuracy do you need?
In how large of an area do you need to operate?
How do you determine the long and lat - GPS?
Does the device always have network connectivity? What types?
Ron McLeod wrote:If the device doesn't move, then at most you will only need a single dip to determine the time zone (maybe not even one if the time zone for the device's location is well known).
What you really need is a way to determine when daylight savings time (summer time) starts and ends (if applicable for that time zone).
There are around 80 countries in the world which use daylight savings, so it would not be to burdensome to manually maintain a database -- this would help with your future requirement as well. Otherwise, if you want to use the API to discover when the time offset changes, you would need to dip it once per day at most just past the time of day when the change would occur.
Ron McLeod wrote:If you simply need to display the correctly adjusted time on a browser, then let the browser take care of that. It already knows the time zone and when to adjust for daylight savings time for its locale.
For example, my browser shows that the current time is using PST and 200 days in the future, it will be using PDT.
Current Date: Sun Apr 19 2015 16:08:14 GMT-0700 (Pacific Standard Time)
Future Date: Thu Nov 05 2015 15:08:14 GMT-0800 (Pacific Daylight Time)
Ron McLeod wrote:In my example there is no system (server?) Put that code in file on the client platform and run it from here (for example: file:///Z:/html/date-test.html).
For your application, the system would always provide the time to the client/browser as UTC, not knowing/caring what time zone it is in. The client displays the appropriate date/time based on it's locale.