from datetime import datetime
def is_date_aware(dt):
"""Determine if a datetime object is timezone aware."""
if not isinstance(dt, datetime):
raise TypeError('Datetime specified is not a datetime object.')
return dt.tzinfo is not None and dt.tzinfo.utcoffset(dt) is not None
Posted: March 21, 2023
Return to the snippets listing