2024-11-21 22:26:07 +00:00
|
|
|
"""Provides functions for converting timestamps to dates."""
|
2023-04-05 20:57:31 +01:00
|
|
|
|
|
|
|
from datetime import datetime
|
2024-08-04 18:47:43 +01:00
|
|
|
from zoneinfo import ZoneInfo
|
2023-04-05 20:57:31 +01:00
|
|
|
|
|
|
|
|
|
|
|
def timestamp_to_date(timestamp: int) -> str:
|
2024-04-21 16:17:00 +01:00
|
|
|
"""Convert timestamp to date.
|
2024-08-04 18:47:43 +01:00
|
|
|
|
2024-04-21 16:17:00 +01:00
|
|
|
Args:
|
|
|
|
timestamp (int): Timestamp to convert.
|
2024-08-04 18:47:43 +01:00
|
|
|
|
2024-04-21 16:17:00 +01:00
|
|
|
Returns:
|
|
|
|
str: Date in the format YYYY-MM-DD.
|
|
|
|
"""
|
2024-08-04 18:47:43 +01:00
|
|
|
return datetime.fromtimestamp(timestamp=timestamp, tz=ZoneInfo("UTC")).strftime(
|
|
|
|
"%Y-%m-%d"
|
|
|
|
)
|