~ihabunek/toot-discuss

tooi: EventList: align relative timestamps to 2 characters v1 APPLIED

Lexi Winter: 1
 EventList: align relative timestamps to 2 characters

 1 files changed, 4 insertions(+), 4 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~ihabunek/toot-discuss/patches/48477/mbox | git am -3
Learn more about email & git

[PATCH tooi] EventList: align relative timestamps to 2 characters Export this patch

This makes the formatting align a bit more nicely for the most common
timestamps, which will be 1-2 digit minutes or hours.
---
 tooi/widgets/event_list.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tooi/widgets/event_list.py b/tooi/widgets/event_list.py
index a96763b..8300f34 100644
--- a/tooi/widgets/event_list.py
+++ b/tooi/widgets/event_list.py
@@ -127,14 +127,14 @@ class EventListItem(ListItem, can_focus=True):
        if self.ctx.config.relative_timestamps:
            diff = datetime.now(timezone.utc) - self.event.created_at
            if (days := diff / timedelta(days=1)) >= 1:
                timestamp = f"{int(days)}d"
                timestamp = f"{int(days):>2}d"
            elif (hours := diff / timedelta(hours=1)) >= 1:
                timestamp = f"{int(hours)}h"
                timestamp = f"{int(hours):>2}h"
            elif (minutes := diff / timedelta(minutes=1)) >= 1:
                timestamp = f"{int(minutes)}m"
                timestamp = f"{int(minutes):>2}m"
            else:
                seconds = diff / timedelta(seconds=1)
                timestamp = f"{int(seconds)}s"
                timestamp = f"{int(seconds):>2}s"
        else:
            timestamp = format_datetime(self.event.created_at)

-- 
2.43.0