To reduce the probability of miusing datetime.utcnow() versus datetime.now(timezone.utc) as well as improve testability, a service should be implemented that can be used to query the current date and time.
class IDateTimeProvider(Protocol):
def utcnow(self) -> datetime: ...
To reduce the probability of miusing
datetime.utcnow()
versusdatetime.now(timezone.utc)
as well as improve testability, a service should be implemented that can be used to query the current date and time.