Search code examples
timestampunix-timestampepochgps-time

Leap seconds in timestamp


The UNIX Epoch includes leap seconds.

But do we add those leap seconds or are they removed from the timestamp?

From the GPS epoch, which doesn't include the leap seconds, to convert a UNIX timestamp to a GPS timestamp, do I need to include or remove the leap seconds from the UNIX timestamp?


Solution

  • GPS system time has counted all the leap seconds, POSIX time has not counted them, therefore from any given epoch (including the GPS epoch of 1980-01-06T00:00:00 GPS time = 1980-01-06T00:00:00 UTC = 1980-O1-06T00:00:00 POSIX time) GPS will have counted more seconds than POSIX. See http://www.ucolick.org/~sla/leapsecs/right+gps.html for existing code that handles this and http://www.ucolick.org/~sla/leapsecs/amsci.html for plots of the time scales.