Skip to content

Commit

Permalink
Local time in toot timeline
Browse files Browse the repository at this point in the history
  • Loading branch information
mmmmmmbeer authored and ihabunek committed Nov 8, 2022
1 parent 8b274ee commit 3315a87
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions toot/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import re
import sys

from datetime import datetime
from datetime import datetime, timezone
from textwrap import wrap
from wcwidth import wcswidth

Expand Down Expand Up @@ -147,6 +147,10 @@ def print_search_results(results):
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):
reblog = status['reblog']
content = reblog['content'] if reblog else status['content']
Expand All @@ -155,7 +159,8 @@ def print_status(status, width):

time = status['created_at']
time = datetime.strptime(time, "%Y-%m-%dT%H:%M:%S.%fZ")
time = time.strftime('%Y-%m-%d %H:%M%z')
time = utc_to_local(time)
time = time.strftime('%Y-%m-%d %H:%M %Z')

username = "@" + status['account']['acct']
spacing = width - wcswidth(username) - wcswidth(time)
Expand Down

0 comments on commit 3315a87

Please sign in to comment.