我猜 :
根据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.
因此,我们必须定义 agps_epoch
并减去给定的闰秒才能获得 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, 10, 6, 6, 830000, tzinfo=<UTC>)
>>>gps_datetime(2077, 295584830.0,18.0).timestamp()
1572429966.83
但我与您的预期结果相差甚远(1572430625230
即使以 ms 表示)
不要忘记pip install pytz