mirror of
https://git.vectorsigma.ru/public/tubearchivist.git
synced 2026-08-05 02:19:23 +00:00
index date published as iso timestamp, #902
This commit is contained in:
@@ -8,7 +8,7 @@ import os
|
||||
import random
|
||||
import string
|
||||
import subprocess
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timezone
|
||||
from time import sleep
|
||||
from typing import Any
|
||||
from urllib.parse import urlparse
|
||||
@@ -106,13 +106,14 @@ def requests_headers() -> dict[str, str]:
|
||||
def date_parser(timestamp: int | str) -> str:
|
||||
"""return formatted date string"""
|
||||
if isinstance(timestamp, int):
|
||||
date_obj = datetime.fromtimestamp(timestamp)
|
||||
date_obj = datetime.fromtimestamp(timestamp, tz=timezone.utc)
|
||||
elif isinstance(timestamp, str):
|
||||
date_obj = datetime.strptime(timestamp, "%Y-%m-%d")
|
||||
date_obj = date_obj.replace(tzinfo=timezone.utc)
|
||||
else:
|
||||
raise TypeError(f"invalid timestamp: {timestamp}")
|
||||
|
||||
return date_obj.date().isoformat()
|
||||
return date_obj.isoformat()
|
||||
|
||||
|
||||
def time_parser(timestamp: str) -> float:
|
||||
|
||||
Reference in New Issue
Block a user