mirror of
https://git.sr.ht/~tsileo/microblog.pub
synced 2024-11-19 21:24:27 +00:00
16 lines
347 B
Python
16 lines
347 B
Python
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)
|
|
|
|
|
|
def as_utc(dt: datetime) -> datetime:
|
|
return dt.replace(tzinfo=timezone.utc)
|