microblog/app/utils/datetime.py

13 lines
264 B
Python
Raw Normal View History

2022-07-11 10:48:38 +00:00
from datetime import datetime
from datetime import timezone
from dateutil.parser import isoparse
def parse_isoformat(isodate: str) -> datetime:
return isoparse(isodate).astimezone(timezone.utc)
def now() -> datetime:
return datetime.now(timezone.utc)