class timedelta – Represents a duration
A timedelta object represents a duration, or the difference between two
datetime
or date
instances.
Note that time
objects do not support arithmetic, due to
their cyclical, non-unique nature.
- class datetime.timedelta(days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0)
Construct a timedelta object representing a duration or a difference between two points in time.
The arguments must all be integers or floats, but may be positive or negative. They are subsequently combined together to form the final timedelta. That is to say, the following are all equivalent:
timedelta(days=1, seconds=3600) timedelta(days=1, hours=1) timedelta(minutes=1500)
- days
The number of days in the duration. This is an integer value.
- seconds
The number of seconds in the duration. This is an integer value.
- microseconds
The number of microseconds in the duration. This is an integer value.
- min
The largest negative representable timedelta,
timedelta(days=-999999999, seconds=0, microseconds=0)
.
- max
The largest positive representable timedelta,
timedelta(days=999999999, seconds=86399, microseconds=999999)
.
- resolution
The smallest possible difference between non-equal timedelta objects,
timedelta(microseconds=1)
.
- total_seconds()
Return the total number of seconds contained in the duration, as a float.
- isoformat()
Return a string representing the duration in ISO 8601 format.