我的猜测:
根据https://en.wikipedia.org/wiki/Epoch_(computing)#Notable_epoch_dates_in_computing,GPS时代是1980年1月6日,GPS counts weeks (a week is defined to start on Sunday) and 6 January is the first Sunday of 1980
根据http://leapsecond.com/java/gpsclock.htm,GPS time was zero at 0h 6-Jan-1980 and since it is not perturbed by leap seconds GPS is now ahead of UTC by 18 seconds.
因此,我们必须定义一个gps_epoch
并减去给定的leap秒才能获得utc日期时间
from datetime import datetime,timedelta
import pytz
def gps_datetime(time_week,time_ms,leap_seconds):
gps_epoch = datetime(1980,1,6,tzinfo=pytz.utc)
# gps_time - utc_time = leap_seconds
return gps_epoch + timedelta(weeks=time_week,milliseconds=time_ms,seconds=-leap_seconds)
以您的示例
>>>gps_datetime(2077,295584830.0,18.0)
datetime.datetime(2019,10,30,830000,tzinfo=<UTC>)
>>>gps_datetime(2077,18.0).timestamp()
1572429966.83
但是,我离您的预期结果还很遥远(1572430625230
即使以毫秒表示)
别忘了pip install pytz
本文链接:https://www.f2er.com/3166168.html