Source code for fastiot.core.time

from datetime import datetime, timezone


[docs]def get_time_now() -> datetime: return ensure_tzinfo(datetime.utcnow())
[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)