• Home
  • Raw
  • Download

Lines Matching refs:timedelta

97 .. class:: timedelta
124 The distinction between naive and aware doesn't apply to :class:`timedelta`
130 timedelta
137 .. _datetime-timedelta:
139 :class:`timedelta` Objects
142 A :class:`timedelta` object represents a duration, the difference between two
145 .. class:: timedelta([days[, seconds[, microseconds[, milliseconds[, minutes[, hours[, weeks]]]]]]])
176 >>> from datetime import timedelta
177 >>> d = timedelta(microseconds=-1)
184 .. attribute:: timedelta.min
186 The most negative :class:`timedelta` object, ``timedelta(-999999999)``.
189 .. attribute:: timedelta.max
191 The most positive :class:`timedelta` object, ``timedelta(days=999999999,
195 .. attribute:: timedelta.resolution
197 The smallest possible difference between non-equal :class:`timedelta` objects,
198 ``timedelta(microseconds=1)``.
200 Note that, because of normalization, ``timedelta.max`` > ``-timedelta.min``.
201 ``-timedelta.max`` is not representable as a :class:`timedelta` object.
239 | ``+t1`` | Returns a :class:`timedelta` object with the |
242 | ``-t1`` | equivalent to :class:`timedelta`\ |
254 | | ``datetime.timedelta(D[, S[, U]])``, where D |
270 -*timedelta.max* is not representable as a :class:`timedelta` object.
273 String representations of :class:`timedelta` objects are normalized
277 >>> timedelta(hours=-5)
278 datetime.timedelta(-1, 68400)
282 In addition to the operations listed above :class:`timedelta` objects support
286 Comparisons of :class:`timedelta` objects are supported with the
287 :class:`timedelta` object representing the smaller duration considered to be the
288 smaller timedelta. In order to stop mixed-type comparisons from falling back to
289 the default comparison by object address, when a :class:`timedelta` object is
294 :class:`timedelta` objects are :term:`hashable` (usable as dictionary keys), support
295 efficient pickling, and in Boolean contexts, a :class:`timedelta` object is
296 considered to be true if and only if it isn't equal to ``timedelta(0)``.
300 .. method:: timedelta.total_seconds()
314 >>> from datetime import timedelta
315 >>> year = timedelta(days=365)
316 >>> another_year = timedelta(weeks=40, days=84, hours=23,
324 (datetime.timedelta(3650), 10)
327 (datetime.timedelta(3285), 9)
330 (datetime.timedelta(1095), 3)
403 ``timedelta(days=1)``.
428 | ``date2 = date1 + timedelta`` | *date2* is ``timedelta.days`` days removed |
431 | ``date2 = date1 - timedelta`` | Computes *date2* such that ``date2 + |
432 | | timedelta == date1``. (2) |
434 | ``timedelta = date1 - date2`` | \(3) |
443 *date2* is moved forward in time if ``timedelta.days > 0``, or backward if
444 ``timedelta.days < 0``. Afterward ``date2 - date1 == timedelta.days``.
445 ``timedelta.seconds`` and ``timedelta.microseconds`` are ignored.
450 This isn't quite equivalent to date1 + (-timedelta), because -timedelta in
451 isolation can overflow in cases where date1 - timedelta does not.
452 ``timedelta.seconds`` and ``timedelta.microseconds`` are ignored.
455 This is exact, and cannot overflow. timedelta.seconds and
456 timedelta.microseconds are 0, and date2 + timedelta == date1 after.
758 ``timedelta(microseconds=1)``.
809 | ``datetime2 = datetime1 + timedelta`` | \(1) |
811 | ``datetime2 = datetime1 - timedelta`` | \(2) |
813 | ``timedelta = datetime1 - datetime2`` | \(3) |
820 datetime2 is a duration of timedelta removed from datetime1, moving forward in
821 time if ``timedelta.days`` > 0, or backward if ``timedelta.days`` < 0. The
823 datetime2 - datetime1 == timedelta after. :exc:`OverflowError` is raised if
829 Computes the datetime2 such that datetime2 + timedelta == datetime1. As for
832 This isn't quite equivalent to datetime1 + (-timedelta), because -timedelta
833 in isolation can overflow in cases where datetime1 - timedelta does not.
841 the :attr:`~.datetime.tzinfo` attributes are ignored, and the result is a :class:`timedelta`
945 return ``None``, or a :class:`timedelta` object representing a whole number of
953 ``None``, or a :class:`timedelta` object representing a whole number of minutes
1030 >>> from datetime import tzinfo, timedelta, datetime
1032 ... def utcoffset(self, dt): return timedelta(minutes=-399)
1116 >>> from datetime import timedelta, datetime, tzinfo
1119 ... return timedelta(hours=1) + self.dst(dt)
1123 ... self.dston = d - timedelta(days=d.weekday() + 1)
1125 ... self.dstoff = d - timedelta(days=d.weekday() + 1)
1127 ... return timedelta(hours=1)
1129 ... return timedelta(0)
1135 ... return timedelta(hours=2) + self.dst(dt)
1138 ... self.dston = d - timedelta(days=d.weekday() + 1)
1140 ... self.dstoff = d - timedelta(days=d.weekday() + 1)
1142 ... return timedelta(hours=1)
1144 ... return timedelta(0)
1152 datetime.timedelta(0)
1154 datetime.timedelta(0, 3600)
1157 datetime.timedelta(0, 3600)
1159 datetime.timedelta(0, 7200)
1209 ``timedelta(microseconds=1)``, although note that arithmetic on
1305 return ``None`` or a :class:`timedelta` object representing a whole number of
1313 ``None``, or a :class:`timedelta` object representing a whole number of minutes
1326 >>> from datetime import time, tzinfo, timedelta
1329 ... return timedelta(hours=1)
1331 ... return timedelta(0)
1342 datetime.timedelta(0)
1387 :class:`timedelta` object specifying a whole number of minutes in the range
1405 ``None`` if DST information isn't known. Return ``timedelta(0)`` if DST is not
1406 in effect. If DST is in effect, return the offset as a :class:`timedelta` object
1433 return timedelta(0)
1443 return timedelta(hours=1)
1445 return timedelta(0)
1757 ``timedelta(hours=-3, minutes=-30)``, ``%z`` is replaced with the string