Returns the time after our last interval, but before ``when``.
        If ``self`` is an empty list, returns ``None``.
190414
def time_afterwards_preceding(
            self, when: datetime.datetime) -> Optional[datetime.timedelta]:
        
        if self.is_empty():
            return None
        end_time = self.end_datetime()
        if when <= end_time:
            return datetime.timedelta()
        else:
            return when - end_time
1205256
def last_update_time(self, value):
        
        if isinstance(value, (datetime.datetime,)):
            self._last_update_time = value
        else:
            raise ValueError("Expect last_update_time to be a datetime")
386642
def date_in_past(self):
        
        now = datetime.datetime.now()
        return (now.date() > self.date)
916528
def _check_time_backwards(self):
        

        now = time.time()

        if now < self.start:
            self.start = now
            self.end = self.start + self.length
1055780
def delay(self):
        ''''''
        if self._last_checked:
            return self._interval - (time.time() - self._last_checked)
        return self._interval
1088772
def _past_datetime_from(self):
        
        prevDt = self.__localBefore(timezone.localtime(), dt.time.max,
                                    excludeCancellations=True,
                                    excludeExtraInfo=True)
        return prevDt
180494
def last(self):
        """"""
        if len(self._range) == 0:
            raise IndexError("range is empty")
        if self._idx == -1:
            return self._range[0]
        return self._get(self._idx)
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))
1089464
def get_timerange(self, start, end, code=None):
        
        try:
            return self.data.loc[(slice(pd.Timestamp(start), pd.Timestamp(end)), slice(code)), :]
        except:
            return ValueError('CANNOT FOUND THIS TIME RANGE')
488636
def now(self):
		
		if self.use_utc:
			return datetime.datetime.utcnow()
		else:
			return datetime.datetime.now()
150441
def calculated_intervals(self, value):
        
        if not value:
            self._calculated_intervals = TimeIntervals()
            return

        if isinstance(value, TimeInterval):
            value = TimeIntervals([value])
        elif isinstance(value, TimeIntervals):
            pass
        elif isinstance(value, list):
            value = TimeIntervals(value)
        else:
            raise TypeError("Expected list/TimeInterval/TimeIntervals, got {}".format(type(value)))

        for interval in value:
            if interval.end > utcnow():
                raise ValueError("Calculated intervals should not be in the future")

        self._calculated_intervals = value
175291
def prev_date(self):
        
        prevDt = self.__localBefore(timezone.localtime(), dt.time.min)
        if prevDt is not None:
            return prevDt.date()
179078
def from_time(cls, other):
        
        return cls(other.hour, other.minute, other.second, other.microsecond)
1300623
def next_time(self, asc=False):
        
        _time = time.localtime(time.time() + self.next())

        if asc:
            return time.asctime(_time)

        return time.mktime(_time)
781494
function(time) {
          if (this._queue.length === 0) return
          var i = 0, line, oldLines
          while ((line = this._queue[i++]) && time >= line.t2) 1
          oldLines = this._queue.slice(0, i - 1)
          this._queue = this._queue.slice(i - 1)
          if (this._queue.length === 0)
            this._lastValue = oldLines[oldLines.length - 1].v2
        }
452759
def _get_minutes_from_last_update(self, time):
        
        time_from_last_update = time - self.last_update_time
        return int(time_from_last_update.total_seconds() / 60)
222521
def _getFromTime(self, atDate=None):
        
        return getLocalTime(self.date, self.time_from, self.tz)