[time-nuts] GPS seconds conversion on an Arduino

Magnus Danielson magnus at rubidium.dyndns.org
Sun May 14 06:24:13 EDT 2017

Hi Mark,

You don't need to boil everything into one single number before 
decomposing it into another form.

If you start with the years, well, the different sums at most offset you 
by 1 as you branch to the next year at somewhat misaligned dates.
Similar with GPS weeks etc.

If you think it through, you can make a first rough estimate, and 
correct it step-wise, making sure the ripple rules is properly applied.

Operating in de-composed form isn't all that hard. It is however 
important to make test-benches that can check the dates over a wide 
range of years. I typically do many centuries, to make sure I got the 
Julian ripple rules right.

I made one function which was a bit handy, giving the amount of leap 
days since epoch. In this case you would not only need the Julian but 
also the Gregorian, and the difference between them would be... your 
leap day adjustment.


On 05/14/2017 03:58 AM, Mark Sims wrote:
> Converting GPS seconds to Gregorian date/time on the Arduino will be an arduous task.  You take GPS seconds and add it to the GPS starring epoch to get a Julian date.  Then add in the number of leap seconds as a fraction of a day to get UTC and possibly add in a time zone offset for local time.  Don't forget to do daylight savings time conversion...  Then convert the result to Gregorian date/time for display.
> The problem is the Arduino floating point library is single precision only and does not have the resolution needed to handle the numbers involved.  Doing it with integer arithmetic (long longs) opens up a whole new can of worms.
> _______________________________________________
> time-nuts mailing list -- time-nuts at febo.com
> To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
> and follow the instructions there.

More information about the time-nuts mailing list