Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GPS Time Representation library

I am looking for a Java library that handles conversion to/from GPS Time.

GPS Time has an epoch of 6 January 1980, and does not have leap seconds, so it differs from the more standard time representations. Here is the relevant description from wikipedia:

While most clocks are synchronized to Coordinated Universal Time (UTC), the atomic clocks on the satellites are set to GPS time. The difference is that GPS time is not corrected to match the rotation of the Earth, so it does not contain leap seconds or other corrections which are periodically added to UTC. GPS time was set to match Coordinated Universal Time (UTC) in 1980, but has since diverged. The lack of corrections means that GPS time remains at a constant offset with International Atomic Time (TAI) (TAI - GPS = 19 seconds). Periodic corrections are performed on the on-board clocks to correct relativistic effects and keep them synchronized with ground clocks.

The GPS navigation message includes the difference between GPS time and UTC, which as of 2009 is 15 seconds due to the leap second added to UTC December 31, 2008. Receivers subtract this offset from GPS time to calculate UTC and specific timezone values. New GPS units may not show the correct UTC time until after receiving the UTC offset message. The GPS-UTC offset field can accommodate 255 leap seconds (eight bits) which, given the current rate of change of the Earth's rotation (with one leap second introduced approximately every 18 months), should be sufficient to last until approximately the year 2300.

As opposed to the year, month, and day format of the Gregorian calendar, the GPS date is expressed as a week number and a seconds-into-week number. The week number is transmitted as a ten-bit field in the C/A and P(Y) navigation messages, and so it becomes zero again every 1,024 weeks (19.6 years). GPS week zero started at 00:00:00 UTC (00:00:19 TAI) on January 6, 1980, and the week number became zero again for the first time at 23:59:47 UTC on August 21, 1999 (00:00:19 TAI on August 22, 1999). To determine the current Gregorian date, a GPS receiver must be provided with the approximate date (to within 3,584 days) to correctly translate the GPS date signal. To address this concern the modernized GPS navigation message uses a 13-bit field, which only repeats every 8,192 weeks (157 years), thus lasting until the year 2137 (157 years after GPS week zero).

I'd rather not have to roll my own; I don't see anything in Joda time indicating it can handle GPS encoded dates.. is there a way to extend it?

like image 659
I82Much Avatar asked Jun 14 '10 14:06

I82Much


People also ask

What format is GPS time?

GPS time is expressed with a resolution of 1.5 seconds as a week number and a time of week count (TOW). Its zero point (week 0, TOW 0) is defined to be 1980-01-06T00:00Z. The TOW count is a value ranging from 0 to 403,199 whose meaning is the number of 1.5 second periods elapsed since the beginning of the GPS week.

Does GPS give UTC time?

GPS time was set to match UTC in 1980, but has since diverged. The lack of corrections means that GPS time remains at a constant offset with International Atomic Time (TAI) (TAI – GPS = 19 seconds). Periodic corrections are performed to the on-board clocks to keep them synchronized with ground clocks.

What is GPS timestamp?

GPS reference time is referenced to UTC with zero point defined as midnight on the night of January 5, 1980. The time stamp consists of the number of weeks since that zero point and the number of seconds since the last week number change (0 to 604,799).

How many GPS Leap seconds are there?

The Global Positioning System (GPS) system uses GPS Time, which does not include these leap seconds. GPS time started on the 1st January, 1980, and was accurate to UTC at this point. Since then, there have been 18 leap seconds introduced, such that there is now an 18 second difference between GPS time and UTC time.


1 Answers

JSR-310 has classes TAIInstant and UTCInstant which would help solve this problem (as GPS time scale is a variation of TAI). These are located in the ThreeTen-Extra project.

like image 114
JodaStephen Avatar answered Sep 29 '22 07:09

JodaStephen