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

    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
1229700
def nsamples_to_hourmin(x, pos):
    '''
    '''

    h, m, s = hourminsec(x/16.0)
    return '{:.0f}h {:2.0f}′'.format(h, m+round(s))
558811
def to_data(s):
  
  if s.startswith('GPSTime'):
    s = 'Gps' + s[3:]

  if '_' in s:
    return "".join([i.capitalize() for i in s.split("_")])
  return s
485855
def run_etime(self):
        """"""
        if self.start_datetime is None or self.end_datetime is None:
            return None

        return self.end_datetime - self.start_datetime
1122674
def utcoffset(self, dt):
        """"""
        tt = _localtime(_mktime((dt.year, dt.month, dt.day,
                 dt.hour, dt.minute, dt.second, dt.weekday(), 0, -1)))
        if tt.tm_isdst > 0: return _dstoffset
        return _stdoffset
601783
def convert_timeval(seconds_since_epoch):
    """"""
    frac, whole = math.modf(seconds_since_epoch)
    microseconds = math.floor(frac * 1000000)
    seconds = math.floor(whole)
    return seconds, microseconds
1067719
def convert_hhmmss(hhmmss):
    """"""
    fields = hhmmss.split(":")
    if len(fields) != 3:
        raise ValueError("Received invalid HH:MM:SS data: {}".format(hhmmss))
    fields = [int(x) for x in fields]
    hours, minutes, seconds = fields
    return (hours * 3600) + (minutes * 60) + seconds
1085226
def utcoffset(self):
        """"""
        if self._tzinfo is None:
            return None
        offset = self._tzinfo.utcoffset(None)
        _check_utc_offset("utcoffset", offset)
        return offset
648576
def convert_timestamp(timestamp):
    """"""
    timestamp = timestamp.strip()
    chunk, millis = timestamp.split(',')
    hours, minutes, seconds = chunk.split(':')
    hours = int(hours)
    minutes = int(minutes)
    seconds = int(seconds)
    seconds = seconds + hours * 60 * 60 + minutes * 60 + float(millis) / 1000
    return seconds
193359
def st_atime(self):
        """"""
        atime = self._st_atime_ns / 1e9
        return atime if self.use_float else int(atime)
1017090
def find_time_base(self, gps, first_ms_stamp):
        ''''''
        t = self._gpsTimeToTime(gps.Week, gps.TimeMS)
        self.set_timebase(t - gps.T*0.001)
        self.timestamp = self.timebase + first_ms_stamp*0.001
127779
def _ligotimegps(s, ns=0):
    
    from lal import LIGOTimeGPS
    try:
        return LIGOTimeGPS(s, ns)
    except TypeError:
        return LIGOTimeGPS(int(s), int(ns))
70114
def localize(self, dt, is_dst=False):
        """"""
        if dt.tzinfo is not None:
            raise ValueError('Not naive datetime (tzinfo is already set)')
        return dt.replace(tzinfo=self)
47079
def to_utc(self, dt):
        """"""
        if dt.tzinfo is None:
            return dt.replace(tzinfo=self.utc)
        return dt.astimezone(self.utc)
345449
def to_local(self, dt):
        """"""
        if dt.tzinfo is None:
            dt = dt.replace(tzinfo=self.utc)
        return dt.astimezone(self.local)
1314438
def isotime(at=None, subsecond=False):
    """"""
    if not at:
        at = utcnow()
    st = at.strftime(_ISO8601_TIME_FORMAT
                     if not subsecond
                     else _ISO8601_TIME_FORMAT_SUBSECOND)
    tz = at.tzinfo.tzname(None) if at.tzinfo else 'UTC'
    st += ('Z' if tz == 'UTC' else tz)
    return st
493297
def datetime_to_time(date, time):
    """"""
    if (255 in date) or (255 in time):
        raise RuntimeError("specific date and time required")

    time_tuple = (
        date[0]+1900, date[1], date[2],
        time[0], time[1], time[2],
        0, 0, -1,
        )
    return _mktime(time_tuple)