Lines Matching refs:timedelta
7 __all__ = ("date", "datetime", "time", "timedelta", "timezone", "tzinfo",
190 hh, mm = divmod(off, timedelta(hours=1))
191 mm, ss = divmod(mm, timedelta(minutes=1))
233 h, rest = divmod(offset, timedelta(hours=1))
234 m, rest = divmod(rest, timedelta(minutes=1))
449 td = timedelta(hours=tz_comps[0], minutes=tz_comps[1],
499 # If offset isn't None or timedelta, raises TypeError.
507 if not isinstance(offset, timedelta):
509 "or timedelta, not '%s'" % (name, type(offset)))
510 if not -timedelta(1) < offset < timedelta(1):
512 "-timedelta(hours=24) and timedelta(hours=24)" %
573 class timedelta:
578 - add, subtract timedelta
580 - compare to timedelta
584 returning a timedelta, and addition or subtraction of a datetime
585 and a timedelta giving a datetime.
684 raise OverflowError("timedelta # of days is too large: %d" % d)
741 if isinstance(other, timedelta):
743 # our __class__ here, but need a real timedelta
744 return timedelta(self._days + other._days,
752 if isinstance(other, timedelta):
754 # our __class__ here, but need a real timedelta
755 return timedelta(self._days - other._days,
761 if isinstance(other, timedelta):
767 # our __class__ here, but need a real timedelta
768 return timedelta(-self._days,
784 # our __class__ here, but need a real timedelta
785 return timedelta(self._days * other,
791 return timedelta(0, 0, _divide_and_round(usec * a, b))
801 if not isinstance(other, (int, timedelta)):
804 if isinstance(other, timedelta):
807 return timedelta(0, 0, usec // other)
810 if not isinstance(other, (int, float, timedelta)):
813 if isinstance(other, timedelta):
816 return timedelta(0, 0, _divide_and_round(usec, other))
819 return timedelta(0, 0, _divide_and_round(b * usec, a))
822 if isinstance(other, timedelta):
824 return timedelta(0, 0, r)
828 if isinstance(other, timedelta):
831 return q, timedelta(0, 0, r)
834 # Comparisons of timedelta objects with other.
837 if isinstance(other, timedelta):
843 if isinstance(other, timedelta):
849 if isinstance(other, timedelta):
855 if isinstance(other, timedelta):
861 if isinstance(other, timedelta):
867 assert isinstance(other, timedelta)
888 timedelta.min = timedelta(-999999999)
889 timedelta.max = timedelta(days=999999999, hours=23, minutes=59, seconds=59,
891 timedelta.resolution = timedelta(microseconds=1)
907 __add__, __radd__, __sub__ (add/radd only with timedelta arg)
1144 "Add a date to a timedelta."
1145 if isinstance(other, timedelta):
1155 """Subtract two dates, or a date and a timedelta."""
1156 if isinstance(other, timedelta):
1157 return self + timedelta(-other.days)
1161 return timedelta(days1 - days2)
1220 date.resolution = timedelta(days=1)
1235 "datetime -> timedelta, positive for east of UTC, negative for west of UTC"
1239 """datetime -> DST offset as timedelta, positive for east of UTC.
1466 myhhmm = self._hour * 60 + self._minute - myoff//timedelta(minutes=1)
1467 othhmm = other._hour * 60 + other._minute - otoff//timedelta(minutes=1)
1482 h, m = divmod(timedelta(hours=self.hour, minutes=self.minute) - tzoff,
1483 timedelta(hours=1))
1484 assert not m % timedelta(minutes=1), "whole minute"
1485 m //= timedelta(minutes=1)
1575 """Return the timezone offset as timedelta, positive east of UTC
1597 """Return 0 if DST is not in effect, or the DST offset (as timedelta
1666 time.resolution = timedelta(microseconds=1)
1776 trans = result - probe1 - timedelta(0, max_fold_seconds)
1778 y, m, d, hh, mm, ss = converter(t + trans // timedelta(0, 1))[:6]
1874 t = (self - epoch) // timedelta(0, 1)
1877 return (datetime(y, m, d, hh, mm, ss) - epoch) // timedelta(0, 1)
1964 ts = (self - _EPOCH) // timedelta(seconds=1)
1970 return timezone(timedelta(seconds=gmtoff), zone)
2066 """Return the timezone offset as timedelta positive east of UTC (negative west of
2088 """Return 0 if DST is not in effect, or the DST offset (as timedelta
2182 "Add a datetime and a timedelta."
2183 if not isinstance(other, timedelta):
2185 delta = timedelta(self.toordinal(),
2203 "Subtract two datetimes, or a datetime and a timedelta."
2205 if isinstance(other, timedelta):
2213 base = timedelta(days1 - days2,
2238 self._hashcode = hash(timedelta(days, seconds, self.microsecond) - tzoff)
2282 datetime.resolution = timedelta(microseconds=1)
2303 if not isinstance(offset, timedelta):
2304 raise TypeError("offset must be a timedelta")
2312 raise ValueError("offset must be a timedelta "
2313 "strictly between -timedelta(hours=24) and "
2314 "timedelta(hours=24).")
2344 >>> tz = timezone(timedelta(hours=-5), 'EST')
2346 "datetime.timezone(datetime.timedelta(-1, 68400), 'EST')"
2390 _maxoffset = timedelta(hours=24, microseconds=-1)
2397 if delta < timedelta(0):
2402 hours, rest = divmod(delta, timedelta(hours=1))
2403 minutes, rest = divmod(rest, timedelta(minutes=1))
2413 UTC = timezone.utc = timezone._create(timedelta(0))
2418 timezone.min = timezone._create(-timedelta(hours=23, minutes=59))
2419 timezone.max = timezone._create(timedelta(hours=23, minutes=59))
2430 # Now some derived rules, where k is a duration (timedelta).
2443 # This follows from #2, and that datetime.timetz+timedelta preserves tzinfo.