feat: remove time_ago filter
This commit is contained in:
parent
bd31e1cede
commit
48fcf8985a
2 changed files with 2 additions and 22 deletions
|
@ -273,7 +273,7 @@
|
|||
</h3>
|
||||
|
||||
<div class="right_menu">
|
||||
<a href="{{ thread.url }}" title="{{ thread.created_at }}">{{ thread.created_at | time_ago }}</a> ·
|
||||
<a href="{{ thread.url }}" title="{{ thread.created_at }}">{{ thread.created_at }}</a> ·
|
||||
<a href="{{ url_for('threads.thread', id=thread['id']) + '#' + thread['id'] }}">Anchor</a>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -347,7 +347,7 @@
|
|||
</h3>
|
||||
|
||||
<div class="right_menu">
|
||||
<a href="{{ descendant.url }}" title="{{ descendant.created_at }}">{{ descendant.created_at | time_ago }}</a> ·
|
||||
<a href="{{ descendant.url }}" title="{{ descendant.created_at }}">{{ descendant.created_at }}</a> ·
|
||||
<a href="{{ url_for('threads.thread', id=thread['id']) + '#' + descendant['id'] }}">Anchor</a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
20
threads.py
20
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()
|
||||
|
|
Loading…
Reference in a new issue