13 lines
349 B
Python
13 lines
349 B
Python
from datetime import datetime
|
|
from zoneinfo import ZoneInfo
|
|
|
|
|
|
# TODO Add documentation
|
|
def get_unix_timestamp(date: datetime, to_utc: bool = False) -> int:
|
|
return int((date if not to_utc else date.replace(tzinfo=ZoneInfo("UTC"))).timestamp())
|
|
|
|
|
|
# TODO Add documentation
|
|
def get_utc_now() -> datetime:
|
|
return datetime.now(tz=ZoneInfo("UTC"))
|