mirror of
https://gitlab.com/SIGBUS/nyaa.git
synced 2024-12-22 04:59:59 +00:00
updated time display
This commit is contained in:
parent
2005174358
commit
1d0177480e
|
@ -98,6 +98,18 @@ def _generate_query_string(term, category, filter, user):
|
|||
return params
|
||||
|
||||
|
||||
@app.template_filter('utc_time')
|
||||
def get_utc_timestamp(datetime_str):
|
||||
''' Returns a UTC POSIX timestamp, as seconds '''
|
||||
UTC_EPOCH = datetime.utcfromtimestamp(0)
|
||||
return int((datetime.strptime(datetime_str, '%Y-%m-%dT%H:%M:%S') - UTC_EPOCH).total_seconds())
|
||||
|
||||
|
||||
@app.template_filter('display_time')
|
||||
def get_display_time(datetime_str):
|
||||
return datetime.strptime(datetime_str, '%Y-%m-%dT%H:%M:%S').strftime('%Y-%m-%d %H:%M')
|
||||
|
||||
|
||||
@app.route('/rss', defaults={'rss': True})
|
||||
@app.route('/', defaults={'rss': False})
|
||||
def home(rss):
|
||||
|
|
|
@ -74,7 +74,7 @@
|
|||
</td>
|
||||
<td class="text-center">{{ torrent.filesize | filesizeformat(True) }}</td>
|
||||
{% if use_elastic %}
|
||||
<td class="text-center" {#data-timestamp="{{ torrent.created_time|int }}"#}>{{ torrent.created_time }}</td>
|
||||
<td class="text-center" data-timestamp="{{ torrent.created_time | utc_time }}">{{ torrent.created_time | display_time }}</td>
|
||||
{% else %}
|
||||
<td class="text-center" data-timestamp="{{ torrent.created_utc_timestamp|int }}">{{ torrent.created_time.strftime('%Y-%m-%d %H:%M') }}</td>
|
||||
{% endif %}
|
||||
|
|
Loading…
Reference in a new issue