TimeDelta.resolution

Overview:

  • The timedelta class represents a quantity of time.

  • The attribute timedelta.resolution is the smallest quantity that can be represented using the datetime.timedelta class.

  • The value of timedelta.resolution is currently one microsecond.

  • A microsecond is one millionth of one second.

Example:

# Example Python program that prints the 
# smallest quantity of time supported  
# by the class timedelta 
from datetime import timedelta

# Construct a duration of 1 hours, 2 minutes, 3 seconds and 
# 4 microseconds and print it
someTime = timedelta(hours=1, minutes=2, seconds=3, microseconds=4)
print(someTime)
print(type(someTime))

# Print the smallest supported time duration 
print(timedelta.resolution)
print(type(timedelta.resolution))

 

Output:

1:02:03.000004

<class 'datetime.timedelta'>

0:00:00.000001

<class 'datetime.timedelta'>

 


Copyright 2023 © pythontic.com