0

Is there a simple way to get leap seconds between gps and utc time through an API or python library which is automatically update if the leap seconds change over the years ?

VLAZ
  • 26,331
  • 9
  • 49
  • 67
  • fwiw, you'll only get quality GPS time from an onboard device; if the device is accessed through a network, you'll find you're reimplementing [NTP](https://en.wikipedia.org/wiki/Network_Time_Protocol), which the underlying operating system almost-certainly makes use of – ti7 Feb 16 '22 at 17:57
  • What do you mean? GPS and UTC are synchronized (same leap seconds, on same time). Unix time doesn't consider leap second, so you need a table about when leap seconds are introduced. Nobody known the future of leap seconds, and nobody should trust an API to be still available in next few years – Giacomo Catenazzi Feb 17 '22 at 08:24
  • related: [How to get current date and time from GPS unsegment time in python](https://stackoverflow.com/q/33415475/10197418) – FObersteiner Oct 19 '22 at 08:34

1 Answers1

-1

Currently, the leap seconds between UTC and GPS is 18 seconds. This 18 seconds was applied on 31/12/2016. Nobody knows when the next change is required because the leap seconds are irregular and unpredictable.

But there is one thing: leap seconds are always applied either on December 31st or June 30th.

There is no API I know about to check this. I think you have to check these dates on your own, if new leap seconds are applied.

Edit: I just found this file from Paris Obs. IERS Center. You can read and parse this file in python. The GPS-UTC Leap seconds is the difference between the line "44239.0 1 1 1980 19" (which is the beginning year of GPS Time) and the last line.

randn
  • 5
  • 3