Return the value at the specified gps time
493865
def at_time(self, time, nearest_sample=False):
        
        if nearest_sample:
            time += self.delta_t / 2.0
        return self[int((time-self.start_time)*self.sample_rate)]
633456
def _get_time(header, keys, name):
        
        for key in keys:
            try:
                date_value = header.pop(key)
            except KeyError:
                continue
            try:
                # String to convert
                return to_timestamp(parse(date_value))
            except TypeError:
                # Already number
                return float(date_value)
        raise UnsupportedOperation(name)
693484
def _StrftimeGm(value, unused_context, args):
    
    time_tuple = time.gmtime(value)
    return _StrftimeHelper(args, time_tuple)
675344
def get(self):
        """"""
        if self.timer() > self.deadline:
            self.value = None
        return self.value
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
310176
def longitude(self, value):
        """"""
        self._longitude = math.radians(float(value))

        # update time_zone
        if abs((value / 15.0) - self.time_zone) > 1:
            # if time_zone doesn't match the longitude update the time_zone
            self.time_zone = value / 15.0
495908
def value(self):
        
        return (
            -self.enable_device.value
            if self.phase_device.is_active else
            self.enable_device.value
        )
769796
def now(self, when=None):
        
        if when is None:
            when = _TaskManager().get_time()
        tup = time.localtime(when)

        self.value = (tup[0]-1900, tup[1], tup[2], tup[6] + 1)

        return self
327844
def validate_gps(value):
    """"""
    try:
        latitude, longitude, altitude = value.split(',')
        vol.Coerce(float)(latitude)
        vol.Coerce(float)(longitude)
        vol.Coerce(float)(altitude)
    except (TypeError, ValueError, vol.Invalid):
        raise vol.Invalid(
            'GPS value should be of format "latitude,longitude,altitude"')
    return value
127779
def _ligotimegps(s, ns=0):
    
    from lal import LIGOTimeGPS
    try:
        return LIGOTimeGPS(s, ns)
    except TypeError:
        return LIGOTimeGPS(int(s), int(ns))
1056524
def get_time(self):
        
        if isinstance(self.path, pathlib.Path):
            thetime = self.path.stat().st_mtime
        else:
            thetime = np.nan
        return thetime
275635
def _get_date(data, position, dummy0, opts, dummy1):
    """"""
    end = position + 8
    millis = _UNPACK_LONG(data[position:end])[0]
    return _millis_to_datetime(millis, opts), end
244379
def pttl(self, key):
        
        """
        Returns time to live in milliseconds if output_ms is True, else returns seconds.
        """
        key = self._encode(key)
        if key not in self.redis:
            # as of redis 2.8, -2 is returned if the key does not exist
            return long(-2) if self.strict else None
        if key not in self.timeouts:
            # as of redis 2.8, -1 is returned if the key is persistent
            # redis-py returns None; command docs say -1
            return long(-1) if self.strict else None

        time_to_live = get_total_milliseconds(self.timeouts[key] - self.clock.now())
        return long(max(-1, time_to_live))
1097151
def access_time(self):
    """"""
    if self._stat_info is None:
      return None

    timestamp = int(self._stat_info.st_atime)
    return dfdatetime_posix_time.PosixTime(timestamp=timestamp)
1296143
def check_time(value):
    """"""
    if value is None:
        return None
    if isinstance(value, (time.struct_time, tuple)):
        return value
    if isinstance(value, datetime.datetime):
        return value.timetuple()
    if isinstance(value, datetime.date):
        res = datetime.datetime.utcnow()
        res.replace(year=value.year, month=value.month, day=value.day)
        return res.timetuple()
    if isinstance(value, datetime.time):
        return datetime.datetime.combine(datetime.date.today(),
                                         value).timetuple()
    if isinteger(value):
        # Handle integer as timestamp
        return time.gmtime(value)
    if isinstance(value, basestring):
        if value.lower() == 'now':
            return time.gmtime()
        # TODO: parsinng some popular strings
    raise ValueError("Unsupported time representation:" + repr(value))
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
302160
def get_time_at(time_in=None, time_at=None, out_fmt='%Y-%m-%dT%H:%M:%S'):
    '''
    
    '''
    dt = get_timestamp_at(time_in=time_in, time_at=time_at)
    return time.strftime(out_fmt, time.localtime(dt))