def convert_from_gps_time(gps_time, gps_week=None):
    """ Convert gps time in ticks to standard time. """

    converted_gps_time = None
    gps_timestamp = float(gps_time)

    if gps_week != None:

        # image date
        converted_gps_time = GPS_START + datetime.timedelta(seconds=int(gps_week) *
                                                            SECS_IN_WEEK + gps_timestamp)

    else:
        # TAI scale with 1970-01-01 00:00:10 (TAI) epoch
        os.environ['TZ'] = 'right/UTC'

        # by definition
        gps_time_as_gps = GPS_START + \
            datetime.timedelta(seconds=gps_timestamp)

        # constant offset
        gps_time_as_tai = gps_time_as_gps + \
            datetime.timedelta(seconds=19)
        tai_epoch_as_tai = datetime.datetime(1970, 1, 1, 0, 0, 10)

        # by definition
        tai_timestamp = (gps_time_as_tai - tai_epoch_as_tai).total_seconds()

        converted_gps_time = (
            datetime.datetime.utcfromtimestamp(tai_timestamp))

    # "right" timezone is in effect
    return converted_gps_time
def convert_from_gps_time ( gps_time , gps_week = None ) : converted_gps_time = None gps_timestamp = float ( gps_time ) if gps_week != None : converted_gps_time = GPS_START + datetime . timedelta ( seconds = int ( gps_week ) * SECS_IN_WEEK + gps_timestamp ) else : os . environ [ 'TZ' ] = 'right/UTC' gps_time_as_gps = GPS_START + datetime . timedelta ( seconds = gps_timestamp ) gps_time_as_tai = gps_time_as_gps + datetime . timedelta ( seconds = 19 ) tai_epoch_as_tai = datetime . datetime ( 1970 , 1 , 1 , 0 , 0 , 10 ) tai_timestamp = ( gps_time_as_tai - tai_epoch_as_tai ) . total_seconds ( ) converted_gps_time = ( datetime . datetime . utcfromtimestamp ( tai_timestamp ) ) return converted_gps_time
Convert gps time in ticks to standard time.