roboluke-tasks/app/utils/datetime.py

19 lines
371 B
Python
Raw Normal View History

2023-04-05 21:57:31 +02:00
#!/usr/bin/env python3
2024-04-21 17:03:39 +02:00
import pytz
2023-04-05 21:57:31 +02:00
from datetime import datetime
def timestamp_to_date(timestamp: int) -> str:
2024-04-21 17:03:39 +02:00
"""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=pytz.utc).strftime("%Y-%m-%d")