A span of time, such as 27 days, 4 hours, 12 minutes, and 3 seconds.
A Duration represents a difference from one point in time to another. The duration
may be "negative" if the difference is from a later time to an earlier.
days
The number of days in the duration.
hours
The number of hours in the duration.
in_days
Returns total duration in days.
in_hours
Returns total duration in hours.
in_microseconds
Returns total duration in microseconds.
in_milliseconds
Returns total duration in milliseconds.
in_minutes
Returns total duration in minutes.
in_seconds
Returns total duration in seconds.
is_negative
Returns True if duration is negative.
microseconds
The number of microseconds in the duration.
milliseconds
The number of milliseconds in the duration.
minutes
The number of minutes in the duration.
seconds
The number of seconds in the duration.
abs
Returns absolute (non-negative) Duration.
copy_with
copy_with(
*,
microseconds: int | None = None,
milliseconds: int | None = None,
seconds: int | None = None,
minutes: int | None = None,
hours: int | None = None,
days: int | None = None,
) -> Duration
Returns a copy of this Duration
instance with the given fields replaced
with the new values.
from_unit
from_unit(
*,
days: int = 0,
hours: int = 0,
minutes: int = 0,
seconds: int = 0,
milliseconds: int = 0,
microseconds: int = 0,
) -> Duration
Creates a Duration from individual time units.