Duration#
- class Duration(seconds, nanoseconds=0)#
Bases:
objectA nonnegative duration with nanosecond precision.
Construct a duration from seconds and an additional nanosecond count.
- Parameters:
- Returns:
Duration – Their sum, within the native duration range.
Examples
>>> Duration(1, 500_000_000).as_millis() 1500
Methods
Return total whole milliseconds, truncating any smaller unit.
Return total whole nanoseconds, truncating any smaller unit.
Return total whole seconds, truncating any smaller unit.
Construct a duration from a nonnegative integer count of milliseconds.
Construct a duration from a nonnegative integer count of nanoseconds.
Construct a duration from a nonnegative integer count of seconds.
- as_millis()#
Return total whole milliseconds, truncating any smaller unit.
- as_nanos()#
Return total whole nanoseconds, truncating any smaller unit.
- as_secs()#
Return total whole seconds, truncating any smaller unit.
- static from_millis(milliseconds)#
Construct a duration from a nonnegative integer count of milliseconds.
- static from_nanos(nanoseconds)#
Construct a duration from a nonnegative integer count of nanoseconds.
- static from_secs(seconds)#
Construct a duration from a nonnegative integer count of seconds.