Created
August 21, 2015 19:48
-
-
Save CharlieRa/4e455605511a37c27e73 to your computer and use it in GitHub Desktop.
Script que convierte una fecha de GPS con epoch del 6 de Enero de 1980 a GMT 0 y GMT -3 de Santiago de Chile
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
#!/usr/bin/python | |
# Usage: python convert.py <gpsDate> - ej formato: 1858349648 | |
import datetime | |
import sys | |
# 1858 3 49648 | |
def convert(gpsDate): | |
epochDate = datetime.datetime.strptime("1980-1-6 00:00:00","%Y-%m-%d %H:%M:%S") | |
# print epochDate | |
week = gpsDate[0:4] | |
days = gpsDate[4:5] | |
seconds = gpsDate[5:] | |
# print "semanas:"+week+" dias: "+days+" segundos: "+seconds | |
addDays=(int(week)*7)+int(days) | |
d = datetime.timedelta(days=int(addDays)) | |
epochDate = epochDate + d | |
gmt = epochDate + datetime.timedelta(seconds=int(seconds)) | |
gmtSantiago = gmt - datetime.timedelta(seconds=int(10800)) | |
print "GMT 0: "+str(gmt) | |
print "GMT-3: "+str(gmtSantiago) | |
return "--------------------------" | |
if __name__ == "__main__": | |
try: | |
val = int(sys.argv[1]) | |
print convert(sys.argv[1]) | |
except ValueError: | |
print("Ingrese solo numero enteros positivos") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment