Skip to main content

delta_resolution

Round a :class:~datetime.datetime to the resolution of timedelta.

If the :class:`~datetime.timedelta` is in days, the
:class:`~datetime.datetime` will be rounded to the nearest days,
if the :class:`~datetime.timedelta` is in hours the
:class:`~datetime.datetime` will be rounded to the nearest hour,
and so on until seconds, which will just return the original
:class:`~datetime.datetime`.
def delta_resolution(
dt: datetime,
delta: timedelta
) - > datetime

Round a :class:~datetime.datetime to the resolution of timedelta.

Parameters

NameTypeDescription
dtdatetimeThe datetime object to be rounded or truncated based on the provided delta.
deltatimedeltaThe time interval used to determine the rounding resolution (e.g., days, hours, or minutes).

Returns

TypeDescription
datetimeA new datetime object truncated to the specified resolution, or the original datetime if the resolution is in seconds.