in reply to Re^3: Converting GPS seconds to readable time&date
in thread Converting GPS seconds to readable time&date
There's really no other foolproof way. I've tried a lot.
Next, if you want to optimize startup time, and also cope with the 'product on a shelf' problem, you have some alternatives:
(1) Grab the leap second file from NIST via FTP on startup if the GPS receiver doesn't know yet. This may be faster than waiting for it, and can be cached so that you only grab it every 6 months. Count the number of leap seconds since 1980.
(2) remember the last number of leap seconds, as well as the data from the GPS receiver that tells you 'pending' leap seconds. If you've not passed a leap second opportunity (December 31 or June 30th), the cache is valid. If you have, and there wasn't one scheduled, the cache is invalid and you have to wait.
I'm sure there are others, but the really only reliable way to convert the GPS time into UTC is to apply the leap second correction. You'll also want to confirm with the GPS data provider that the data is in GPS seconds, not UTC. Many GPS receivers do output UTC in their default mode of operation.
Warner
|
|---|