Use exisiting functon to parse datetime

pull/235/head
Ivan Habunek 2022-11-21 08:15:49 +01:00
rodzic 0d20a4878b
commit 0b671be0c6
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: F5F0623FF5EBCB3D
1 zmienionych plików z 2 dodań i 7 usunięć

Wyświetl plik

@ -7,6 +7,7 @@ import sys
from datetime import datetime, timezone from datetime import datetime, timezone
from textwrap import wrap from textwrap import wrap
from wcwidth import wcswidth from wcwidth import wcswidth
from toot.tui.utils import parse_datetime
from toot.utils import format_content, get_text, parse_html from toot.utils import format_content, get_text, parse_html
from toot.wcstring import wc_wrap from toot.wcstring import wc_wrap
@ -149,19 +150,13 @@ def print_search_results(results):
print_out("<yellow>Nothing found</yellow>") print_out("<yellow>Nothing found</yellow>")
def utc_to_local(utc_dt):
return utc_dt.replace(tzinfo=timezone.utc).astimezone()
def print_status(status, width): def print_status(status, width):
reblog = status['reblog'] reblog = status['reblog']
content = reblog['content'] if reblog else status['content'] content = reblog['content'] if reblog else status['content']
media_attachments = reblog['media_attachments'] if reblog else status['media_attachments'] media_attachments = reblog['media_attachments'] if reblog else status['media_attachments']
in_reply_to = status['in_reply_to_id'] in_reply_to = status['in_reply_to_id']
time = status['created_at'] time = parse_datetime(status['created_at'])
time = datetime.strptime(time, "%Y-%m-%dT%H:%M:%S.%fZ")
time = utc_to_local(time)
time = time.strftime('%Y-%m-%d %H:%M %Z') time = time.strftime('%Y-%m-%d %H:%M %Z')
username = "@" + status['account']['acct'] username = "@" + status['account']['acct']