Source code for fastiot.core.time
from datetime import datetime, timezone
[docs]def ensure_tzinfo(v):
# if TZ isn't provided, we assume UTC, but you can do w/e you need
if v.tzinfo is None:
return v.replace(tzinfo=timezone.utc)
# else we convert to utc
return v.astimezone(timezone.utc)