The easiest way to convert a GPS computed time, that you get from the receiver is to add the number of leap seconds reported by the GPS receiver's alminac. This takes about 20 minutes to get on a cold startup, and a few seconds on a warm one.

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


In reply to Re^4: Converting GPS seconds to readable time&date by Anonymous Monk
in thread Converting GPS seconds to readable time&date by flamey

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.