Skip to content
Snippets Groups Projects
Commit 1bc5ae80 authored by Thijs Kinkhorst's avatar Thijs Kinkhorst
Browse files

Better formatting of expiration in the admin interface

Previously, would show inappropriate precision, like "0.0598134 hours ago"
or "1490532.4129 hours from now" depending on the expiration date.
parent 83936282
No related branches found
No related tags found
No related merge requests found
......@@ -296,6 +296,7 @@ class Template extends Response
$twig = new Twig_Environment($loader, $options);
$twig->addExtension(new Twig_Extensions_Extension_I18n());
$twig->addExtension(new \Twig\Extensions\DateExtension());
$twig->addFunction(new TwigFunction('moduleURL', [Module::class, 'getModuleURL']));
......
......@@ -116,16 +116,13 @@
{{ entity.entityid|escape('html') }}
{%- endif -%}
</a>
{%- if entity.expire is defined %}
{%- if entity.expire < date().timestamp %}
<span class="entity-expired"> (expired {{ ((date().timestamp - entity.expire) / 3600) }} hours ago)</span>
{%- else %}
{%- set expiration = (entity.expire - date().timestamp) / 3600 %}
({% trans %}expires in {{ expiration }} hours{% endtrans %})
{%- endif -%}
{%- endif -%}
{% if entity.expire is defined %}
{% if entity.expire < date().timestamp %}
<span class="entity-expired"> ({% trans %}expired{% endtrans %} {{ entity.expire | time_diff }})</span>
{% else %}
<span class="entity-expires"> ({% trans %}expires{% endtrans %} {{ entity.expire | time_diff }})</span>
{% endif %}
{% endif %}
</li>
{% endfor %}
</ul>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment