Last active
April 3, 2022 02:33
-
-
Save jeremiahajohnson/eca97484db88bcf6b124 to your computer and use it in GitHub Desktop.
Python function to take GPS week and GPS seconds and return a UTC datetime string in the format "YYYY-MM-DD HH:MM:SS"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def weeksecondstoutc(gpsweek,gpsseconds,leapseconds): | |
import datetime, calendar | |
datetimeformat = "%Y-%m-%d %H:%M:%S" | |
epoch = datetime.datetime.strptime("1980-01-06 00:00:00",datetimeformat) | |
elapsed = datetime.timedelta(days=(gpsweek*7),seconds=(gpsseconds+leapseconds)) | |
return datetime.datetime.strftime(epoch + elapsed,datetimeformat) | |
weeksecondstoutc(1811,164196.732,16) ## --> '2014-09-22 21:36:52' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you @zfb132!