roboluke-tasks/app/utils/datetime.py

19 lines
396 B
Python
Raw Permalink Normal View History

2023-04-05 21:57:31 +02:00
#!/usr/bin/env python3
from zoneinfo import ZoneInfo
2023-04-05 21:57:31 +02:00
from datetime import datetime
def timestamp_to_date(timestamp: int) -> str:
"""Convert timestamp to date.
Args:
timestamp (int): Timestamp to convert.
Returns:
str: Date in the format YYYY-MM-DD.
"""
return datetime.fromtimestamp(timestamp=timestamp, tz=ZoneInfo("UTC")).strftime("%Y-%m-%d")