mirror of
https://github.com/DMOJ/online-judge.git
synced 2024-11-25 16:32:37 +08:00
Remove widgets/relative-time.html
fragment
This commit is contained in:
parent
08bcb3c231
commit
9c9a6d556a
@ -2,6 +2,9 @@ import functools
|
||||
|
||||
from django.template.defaultfilters import date, time
|
||||
from django.templatetags.tz import localtime
|
||||
from django.utils.html import escape
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.utils.timezone import utc
|
||||
from django.utils.translation import gettext as _
|
||||
|
||||
from . import registry
|
||||
@ -22,11 +25,8 @@ registry.filter(localtime_wrapper(time))
|
||||
|
||||
|
||||
@registry.function
|
||||
@registry.render_with('widgets/relative-time.html')
|
||||
def relative_time(time, **kwargs):
|
||||
return {
|
||||
'time': time,
|
||||
'format': kwargs.get('format', _('N j, Y, g:i a')),
|
||||
'rel_format': kwargs.get('rel', _('{time}')),
|
||||
'abs_format': kwargs.get('abs', _('on {time}')),
|
||||
}
|
||||
abs_time = date(time, kwargs.get('format', _('N j, Y, g:i a')))
|
||||
return mark_safe(f'<span data-iso="{time.astimezone(utc).isoformat()}" class="time-with-rel"'
|
||||
f' title="{escape(abs_time)}" data-format="{escape(kwargs.get("rel", _("{time}")))}">'
|
||||
f'{escape(kwargs.get("abs", _("on {time}")).replace("{time}", abs_time))}</span>')
|
||||
|
@ -1,6 +0,0 @@
|
||||
{% spaceless %}
|
||||
<span data-iso="{{ time|utc|date('c') }}" class="time-with-rel" title="{{ time|date(format) }}"
|
||||
data-format="{{ rel_format }}">
|
||||
{{ abs_format.replace('{time}', time|date(format)) }}
|
||||
</span>
|
||||
{% endspaceless %}
|
Loading…
Reference in New Issue
Block a user