[time-nuts] GPS seconds conversion on an Arduino

jimlux jimlux at earthlink.net
Sun May 14 11:48:08 EDT 2017


On 5/13/17 6:58 PM, 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.
>

I don't know that this conversion is that hard on an Arduino, except 
perhaps the daylight time (just because that's such a complex irregular 
thing)

There's only 604,800 seconds in a week. that fits in a long quite 
nicely. If you don't need to work too far into the past, you need a 
table of weeks with appropriate metadata->what calendar date it 
corresponds to, and whether there's a feb 29 or leap second.
(or do it with arithmetic for the leap years)




More information about the time-nuts mailing list