Lines Matching refs:timedelta
112 .. class:: timedelta
140 timedelta
179 The distinction between aware and naive doesn't apply to :class:`timedelta`
182 .. _datetime-timedelta:
184 :class:`timedelta` Objects
187 A :class:`timedelta` object represents a duration, the difference between two
190 .. class:: timedelta(days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0)
214 >>> from datetime import timedelta
215 >>> delta = timedelta(
226 datetime.timedelta(days=64, seconds=29156, microseconds=10)
241 >>> from datetime import timedelta
242 >>> d = timedelta(microseconds=-1)
249 .. attribute:: timedelta.min
251 The most negative :class:`timedelta` object, ``timedelta(-999999999)``.
254 .. attribute:: timedelta.max
256 The most positive :class:`timedelta` object, ``timedelta(days=999999999,
260 .. attribute:: timedelta.resolution
262 The smallest possible difference between non-equal :class:`timedelta` objects,
263 ``timedelta(microseconds=1)``.
265 Note that, because of normalization, ``timedelta.max`` > ``-timedelta.min``.
266 ``-timedelta.max`` is not representable as a :class:`timedelta` object.
303 | | timedelta.resolution using round-half-to-even.|
311 | | timedelta.resolution using round-half-to-even.|
318 | | :class:`timedelta` object. (3) |
322 | | q is an integer and r is a :class:`timedelta` |
325 | ``+t1`` | Returns a :class:`timedelta` object with the |
329 | | :class:`timedelta`\ (-*t1.days*, |
341 | | :class:`timedelta` object as a constructor |
358 -*timedelta.max* is not representable as a :class:`timedelta` object.
361 String representations of :class:`timedelta` objects are normalized
365 >>> timedelta(hours=-5)
366 datetime.timedelta(days=-1, seconds=68400)
372 when t3 is equal to ``timedelta.max``; in that case the former will produce a result
375 In addition to the operations listed above, :class:`timedelta` objects support
380 Floor division and true division of a :class:`timedelta` object by another
381 :class:`timedelta` object are now supported, as are remainder operations and
383 :class:`timedelta` object by a :class:`float` object are now supported.
386 Comparisons of :class:`timedelta` objects are supported, with some caveats.
391 >>> from datetime import timedelta
392 >>> delta1 = timedelta(seconds=57)
393 >>> delta2 = timedelta(hours=25, seconds=2)
399 For all other comparisons (such as ``<`` and ``>``), when a :class:`timedelta`
408 TypeError: '>' not supported between instances of 'datetime.timedelta' and 'int'
410 In Boolean contexts, a :class:`timedelta` object is
411 considered to be true if and only if it isn't equal to ``timedelta(0)``.
415 .. method:: timedelta.total_seconds()
418 ``td / timedelta(seconds=1)``. For interval units other than seconds, use the
419 division form directly (e.g. ``td / timedelta(microseconds=1)``).
426 Examples of usage: :class:`timedelta`
432 >>> from datetime import timedelta
433 >>> year = timedelta(days=365)
434 >>> another_year = timedelta(weeks=40, days=84, hours=23,
441 Examples of :class:`timedelta` arithmetic::
443 >>> from datetime import timedelta
444 >>> year = timedelta(days=365)
447 datetime.timedelta(days=3650)
452 datetime.timedelta(days=3285)
455 (datetime.timedelta(days=1095), 3)
556 ``timedelta(days=1)``.
581 | ``date2 = date1 + timedelta`` | *date2* is ``timedelta.days`` days removed |
584 | ``date2 = date1 - timedelta`` | Computes *date2* such that ``date2 + |
585 | | timedelta == date1``. (2) |
587 | ``timedelta = date1 - date2`` | \(3) |
596 *date2* is moved forward in time if ``timedelta.days > 0``, or backward if
597 ``timedelta.days < 0``. Afterward ``date2 - date1 == timedelta.days``.
598 ``timedelta.seconds`` and ``timedelta.microseconds`` are ignored.
603 ``timedelta.seconds`` and ``timedelta.microseconds`` are ignored.
606 This is exact, and cannot overflow. timedelta.seconds and
607 timedelta.microseconds are 0, and date2 + timedelta == date1 after.
940 datetime(1970, 1, 1, tzinfo=timezone.utc) + timedelta(seconds=timestamp)
1019 tzinfo=datetime.timezone(datetime.timedelta(seconds=14400)))
1065 ``timedelta(microseconds=1)``.
1126 | ``datetime2 = datetime1 + timedelta`` | \(1) |
1128 | ``datetime2 = datetime1 - timedelta`` | \(2) |
1130 | ``timedelta = datetime1 - datetime2`` | \(3) |
1137 datetime2 is a duration of timedelta removed from datetime1, moving forward in
1138 time if ``timedelta.days`` > 0, or backward if ``timedelta.days`` < 0. The
1140 datetime2 - datetime1 == timedelta after. :exc:`OverflowError` is raised if
1146 Computes the datetime2 such that datetime2 + timedelta == datetime1. As for
1156 the :attr:`~.datetime.tzinfo` attributes are ignored, and the result is a :class:`timedelta`
1283 return ``None`` or a :class:`timedelta` object with magnitude less than one day.
1293 ``None`` or a :class:`timedelta` object with magnitude less than one day.
1388 timestamp = (dt - datetime(1970, 1, 1)) / timedelta(seconds=1)
1434 >>> from datetime import tzinfo, timedelta, datetime
1438 ... return timedelta(hours=-6, minutes=-39)
1577 from datetime import timedelta, datetime, tzinfo, timezone
1585 return timedelta(hours=4)
1591 return timedelta(hours=4, minutes=(30 if dt.fold else 0))
1593 return timedelta(hours=4, minutes=30)
1607 return dt + timedelta(hours=4, minutes=30)
1609 return dt + timedelta(hours=4)
1613 return timedelta(0)
1682 ``timedelta(microseconds=1)``, although note that arithmetic on
1778 datetime.time(4, 23, 1, tzinfo=datetime.timezone(datetime.timedelta(seconds=14400)))
1866 return ``None`` or a :class:`timedelta` object with magnitude less than one day.
1876 ``None``, or a :class:`timedelta` object with magnitude less than one day.
1892 >>> from datetime import time, tzinfo, timedelta
1895 ... return timedelta(hours=1)
1897 ... return timedelta(0)
1909 datetime.timedelta(0)
1954 Return offset of local time from UTC, as a :class:`timedelta` object that is
1960 return ``None``. Else the value returned must be a :class:`timedelta` object
1961 strictly between ``-timedelta(hours=24)`` and ``timedelta(hours=24)``
1980 Return the daylight saving time (DST) adjustment, as a :class:`timedelta`
1984 Return ``timedelta(0)`` if DST is not in effect.
1985 If DST is in effect, return the offset as a :class:`timedelta` object
2012 return timedelta(0)
2022 return timedelta(hours=1)
2024 return timedelta(0)
2210 The *offset* argument must be specified as a :class:`timedelta`
2212 be strictly between ``-timedelta(hours=24)`` and
2213 ``timedelta(hours=24)``, otherwise :exc:`ValueError` is raised.
2229 The *dt* argument is ignored. The return value is a :class:`timedelta`
2242 *offset* is ``timedelta(0)``, the name is "UTC", otherwise it is a string in
2247 Name generated from ``offset=timedelta(0)`` is now plain `'UTC'`, not
2264 The UTC timezone, ``timezone(timedelta(0))``.
2525 :meth:`utcoffset` returns ``timedelta(hours=-3, minutes=-30)``, ``%z`` is