Returns an "absolute" value for a timedelta, always representing a
    time distance.
194702
def abs_timedelta(delta):
    """"""
    if delta.days < 0:
        now = _now()
        return now - (now + delta)
    return delta
18710
def get_delta(value):
    
    if isinstance(value, (int, float)):
        return timedelta(seconds=value)
    elif isinstance(value, timedelta):
        return value
    raise Exception('Invalid delta')
803802
def _add_timedelta(self, delta):
        
        if isinstance(delta, pendulum.Period):
            return self.add(
                years=delta.years,
                months=delta.months,
                weeks=delta.weeks,
                days=delta.remaining_days,
                hours=delta.hours,
                minutes=delta.minutes,
                seconds=delta.remaining_seconds,
                microseconds=delta.microseconds,
            )
        elif isinstance(delta, pendulum.Duration):
            return self.add(
                years=delta.years, months=delta.months, seconds=delta.total_seconds()
            )

        return self.add(seconds=delta.total_seconds())
583905
def _subtract_timedelta(self, delta):
        
        if isinstance(delta, pendulum.Duration):
            return self.subtract(
                years=delta.years,
                months=delta.months,
                weeks=delta.weeks,
                days=delta.remaining_days,
            )

        return self.subtract(days=delta.days)
92662
def pace(self):
        """"""
        secs_per_km = self.duration / (self.distance / 1000)
        return time.strftime('%M:%S', time.gmtime(secs_per_km))
808562
def ToTimedelta(self):
    """"""
    return timedelta(
        seconds=self.seconds, microseconds=_RoundTowardZero(
            self.nanos, _NANOS_PER_MICROSECOND))
380539
def _coerce_scalar_to_timedelta_type(r, unit='ns', box=True, errors='raise'):
    """"""

    try:
        result = Timedelta(r, unit)
        if not box:
            # explicitly view as timedelta64 for case when result is pd.NaT
            result = result.asm8.view('timedelta64[ns]')
    except ValueError:
        if errors == 'raise':
            raise
        elif errors == 'ignore':
            return r

        # coerce
        result = NaT

    return result
1178156
def timediff(time):
    """"""
    now = datetime.datetime.utcnow()
    diff = now - time
    diff_sec = diff.total_seconds()
    return diff_sec
711911
def validity_duration(self):
        
        if self._proto.HasField('expireMillis'):
            return timedelta(milliseconds=self._proto.expireMillis)
        return None
950736
def timesince(self, now=None):
        
        from django.utils.timesince import timesince as timesince_
        return timesince_(self.timestamp, now)
369416
def get_time_position(self, time):
        
        if time < self._start or time > self._finish:
            raise ValueError("time argument out of bounds")
        return (time - self._start) / (self._resolution / self._zoom_factor)
1287352
def utcfromtimestamp(cls, t):
        ""
        t, frac = divmod(t, 1.0)
        us = int(frac * 1e6)

        # If timestamp is less than one microsecond smaller than a
        # full second, us can be rounded up to 1000000.  In this case,
        # roll over to seconds, otherwise, ValueError is raised
        # by the constructor.
        if us == 1000000:
            t += 1
            us = 0
        y, m, d, hh, mm, ss, weekday, jday, dst = _time.gmtime(t)
        ss = min(ss, 59)    # clamp out leap seconds if the platform has them
        return cls(y, m, d, hh, mm, ss, us)
1338409
def advance_time_delta(timedelta):
    """"""
    assert(utcnow.override_time is not None)
    try:
        for dt in utcnow.override_time:
            dt += timedelta
    except TypeError:
        utcnow.override_time += timedelta
9202
def _timestamp_instants_eq(a, b):
    """"""
    assert isinstance(a, datetime)
    if not isinstance(b, datetime):
        return False
    # datetime's __eq__ can't compare a None offset and a non-None offset. For these equivalence semantics, a None
    # offset (unknown local offset) is treated equivalently to a +00:00.
    if a.tzinfo is None:
        a = a.replace(tzinfo=OffsetTZInfo())
    if b.tzinfo is None:
        b = b.replace(tzinfo=OffsetTZInfo())
    # datetime's __eq__ implementation compares instants; offsets and precision need not be equal.
    return a == b
627855
def timing(self, stat, delta, rate=1):
        """"""
        return self.send(stat, "%d|ms" % delta, rate)
1189708
def time(self, t=None):
        """"""
        if t is None:
            return self._time
        self._time = t
        return self
767883
def to_seconds(value, strict=True, force_int=True):
    
    if isinstance(value, int):
        return value  # assuming it's seconds
    elif isinstance(value, timedelta):
        seconds = value.total_seconds()
        if force_int:
            seconds = int(round(seconds))
        return seconds
    elif isinstance(value, str):
        hours, minutes, seconds = _parse(value, strict)
    elif isinstance(value, tuple):
        check_tuple(value, strict)
        hours, minutes, seconds = value
    else:
        raise TypeError(
            'Value %s (type %s) not supported' % (
                value, type(value).__name__
            )
        )

    if not (hours or minutes or seconds):
        raise ValueError('No hours, minutes or seconds found')

    result = hours*3600 + minutes*60 + seconds
    return result