MCPcopy Create free account
hub / github.com/dateutil/dateutil / within_delta

Function within_delta

src/dateutil/utils.py:62–69  ·  view source on GitHub ↗

Useful for comparing two datetimes that may have a negligible difference to be considered equal.

(dt1, dt2, delta)

Source from the content-addressed store, hash-verified

60
61
62def within_delta(dt1, dt2, delta):
63 """
64 Useful for comparing two datetimes that may have a negligible difference
65 to be considered equal.
66 """
67 delta = abs(delta)
68 difference = dt1 - dt2
69 return -delta <= difference <= delta

Calls

no outgoing calls