[time-nuts] How best to compute local time from GPS

Hal Murray hmurray at megapathdsl.net
Tue Mar 25 00:01:43 EDT 2008


> 1 Is there a reasonable way to determine the local time zone from the
> GPS sentences? 

None that I know of.

But given that you have GPS you probably know where you are.  If you had a 
map of the globe with the time zone boundaries drawn on it, you should be 
able to figure out which zone you are currently in.

That sounds like a fun project.  I'll bet somebody has done it.  Try google.

It would be fun to watch it tick over as you drove across the line.  (and 
watch it stutter if you could find a road that went along the boundary)


> 2. If I have to store the time zone from the user's input, are the
> DST calculations reasonably straightforward these days? 

It is pretty easy if you are willing to call a subroutine and have space for 
that routine and it's data.

The typical programming environments for everything bigger than a tiny system 
includes the time conversion routines in libc and an extensive collection of 
time zone tables.

The user input is to pick your time zone from a big list.  There are several 
versions of the tables.  I haven't kept up with why they forked.  On my 
system, one set has 547 entries.  (There are probably many duplicates in 
there.)  There are 12 in the US subdirectory, 53 in Europe.  They are roughly 
1K each.

I'd start with the man pages for strftime, ctime, and friends.  google will 
find copies if you don't have a *nix system handy.


> 4. In general, is it better to let the user turn DST on and off or
> try to do it automatically? (I live in Arizona, which doesn't worship
> DST, so I have no experience in this matter.) 

DST is covered by the above mentioned package.

You need to install a new set of tables whenever Congress changes the rules.


I haven't looked at any of the modern timezone tables.  Many years ago, I was 
looking at the Tenex time conversion code.  There was a big comment at the 
top claiming that it did everything.  There was a small footnote saying that 
it didn't handle war time.


The wiki page that Matthew Smith mentioned looks good to me.


-- 
These are my opinions, not necessarily my employer's.  I hate spam.






More information about the time-nuts mailing list