Skip to content

Commit

Permalink
info: include stats timestamp on detailed page
Browse files Browse the repository at this point in the history
This makes debugging easier.
  • Loading branch information
nijel committed Nov 30, 2023
1 parent ac01217 commit 3537b3d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 6 additions & 1 deletion weblate/templates/snippets/info.html
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,12 @@
{% endif %}

<div class="panel panel-default">
<div class="panel-heading"><h4 class="panel-title">{% trans "String statistics" %}</h4></div>
<div class="panel-heading">
<span class="pull-right flip text-muted">
{{ stats.stats_timestamp|naturaltime }}
</span>
<h4 class="panel-title">{% trans "String statistics" %}</h4>
</div>
<table class="table">
<thead>
<tr>
Expand Down
5 changes: 4 additions & 1 deletion weblate/trans/templatetags/translations.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import re
from collections import defaultdict
from datetime import date
from datetime import date, datetime

from django import template
from django.contrib.humanize.templatetags.humanize import intcomma
Expand Down Expand Up @@ -687,6 +687,9 @@ def naturaltime(value, now=None):
For date and time values shows how many seconds, minutes or hours ago compared to
current timestamp returns representing string.
"""
# float is what time() returns
if isinstance(value, float):
value = datetime.fromtimestamp(value, tz=timezone.get_current_timezone())
# datetime is a subclass of date
if not isinstance(value, date):
return value
Expand Down

0 comments on commit 3537b3d

Please sign in to comment.