From 48fcf8985ab49c8458a52f09d63fd707ccece45e Mon Sep 17 00:00:00 2001 From: Ayo Ayco Date: Sat, 18 May 2024 12:49:46 +0200 Subject: [PATCH] feat: remove time_ago filter --- templates/threads.html | 4 ++-- threads.py | 20 -------------------- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/templates/threads.html b/templates/threads.html index 28d9c46..978b9ab 100644 --- a/templates/threads.html +++ b/templates/threads.html @@ -273,7 +273,7 @@
- {{ thread.created_at | time_ago }} · + {{ thread.created_at }} · Anchor
@@ -347,7 +347,7 @@
- {{ descendant.created_at | time_ago }} · + {{ descendant.created_at }} · Anchor
diff --git a/threads.py b/threads.py index 9dac51d..7d627eb 100755 --- a/threads.py +++ b/threads.py @@ -42,26 +42,6 @@ def middleware(): if year != attribution['year']: attribution['current_year'] = year -@threads.app_template_filter('time_ago') -def time_ago(date): - now = datetime.now() - date_obj = datetime.strptime(date, '%Y-%m-%dT%H:%M:%S.%fZ') - delta = now - date_obj - days = delta.days - if days == 0: - return 'just today' - elif days == 1: - return 'yesterday' - elif days < 7: - return str(days) + ' days ago' - elif days < 28: - weeks = int(days) // 7 - if (weeks == 1): - return 'a week ago' - else: - return str(weeks) + ' weeks ago' - return date_obj.strftime('%b %d, %Y') - @threads.route('/') def home(): statuses = fetch_statuses()