I want to convert from Unix Time to GPS Time, i.e. calculate the number of weeks since the beginning of the GPS epoch (January 6, 1980) in Python. I am not looking for the weeks in a year but the weeks since 1980.
To start my attempt has been to get the number of seconds elapsed by using time.time() to return the time since the 1970 epoch known as Unix time and subtract it from the number of seconds elapsed between that epoch and GPS start date.
This returns a correct value, in seconds, for the time since 1980 but I would like the GPS week number. Is there a standard Python function that returns this?
NOTES
GPS date is expressed as a week number since epoch and a seconds-into-week number. The GPS Epoch is different - January 6, 1980 00:00:00. Furthermore, "GPS counts weeks" since the epoch - A GPS week is defined to start on Sunday. NOTE: January 6 is the first Sunday of 1980. 1
The Unix time system has an Epoch of January 1, 1970 00:00:00 and ISO defines the first week of the year as - "The one which contains the fourth day of January, which is equivalent to saying that it's the first week to overlap the new year by at least four days".
There are other time systems, most notably J2000. Converting from one time system to another is non-trivial.
To deal with GPS Time, Perl provides the DateTime::Precise library, which performs common time and date operations with additional GPS operations. The question again is, does Python provide a similar library?