ENHANCEMENT: clearer use of time
This commit is contained in:
parent
3e69582786
commit
3c5ef172b0
|
@ -54,23 +54,26 @@ class Twig
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addFilters() {
|
public function addFilters() {
|
||||||
$secondsToInterval = new TwigFilter('interval', function(int $time) {
|
$secondsToInterval = new TwigFilter('interval', function(int|float $time) {
|
||||||
|
$return = '';
|
||||||
|
|
||||||
$days = floor($time / (60 * 60 * 24));
|
$days = floor($time / (60 * 60 * 24));
|
||||||
$time -= $days * (60 * 60 * 24);
|
$time -= $days * (60 * 60 * 24);
|
||||||
|
$return .= ($days != 0) ? "{$days}d " : '';
|
||||||
|
|
||||||
$hours = floor($time / (60 * 60));
|
$hours = floor($time / (60 * 60));
|
||||||
$time -= $hours * (60 * 60);
|
$time -= $hours * (60 * 60);
|
||||||
|
$return .= ($hours != 0) ? "{$hours}h " : '';
|
||||||
|
|
||||||
$minutes = floor($time / 60);
|
$minutes = floor($time / 60);
|
||||||
$time -= $minutes * 60;
|
$time -= $minutes * 60;
|
||||||
|
$return .= ($minutes != 0) ? "{$minutes}m " : '';
|
||||||
|
|
||||||
$seconds = floor($time);
|
$time = round($time, 3);
|
||||||
$time -= $seconds;
|
$return .= ($time != 0) ? "{$time}s " : '';
|
||||||
|
|
||||||
return "{$days}d {$hours}h {$minutes}m {$seconds}s";
|
return $return;
|
||||||
});
|
});
|
||||||
$this->environment->addFilter($secondsToInterval);
|
|
||||||
|
|
||||||
$parseTags = new TwigFilter('parsetags', function(string $text) {
|
$parseTags = new TwigFilter('parsetags', function(string $text) {
|
||||||
$results = [];
|
$results = [];
|
||||||
preg_match_all('/\[([A-Za-z0-9 \-]+)\]/', $text, $results);
|
preg_match_all('/\[([A-Za-z0-9 \-]+)\]/', $text, $results);
|
||||||
|
@ -82,6 +85,7 @@ class Twig
|
||||||
return $text;
|
return $text;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$this->environment->addFilter($secondsToInterval);
|
||||||
$this->environment->addFilter($parseTags);
|
$this->environment->addFilter($parseTags);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
<button class="accordion-button{% if loop.index != 1 %} collapsed{% endif %}" type="button" data-bs-toggle="collapse" data-bs-target="#run-{{ run.id }}" aria-expanded="{% if loop.index != 1 %}true{% else %}false{% endif %}" aria-controls="run-{{ run.id }}">
|
<button class="accordion-button{% if loop.index != 1 %} collapsed{% endif %}" type="button" data-bs-toggle="collapse" data-bs-target="#run-{{ run.id }}" aria-expanded="{% if loop.index != 1 %}true{% else %}false{% endif %}" aria-controls="run-{{ run.id }}">
|
||||||
<div>
|
<div>
|
||||||
<div class="d-md-inline d-block text-left">{{ run.timestamp | date("d/m/Y H:i:s") }}</div>
|
<div class="d-md-inline d-block text-left">{{ run.timestamp | date("d/m/Y H:i:s") }}</div>
|
||||||
<div class="d-md-inline d-block text-left">(exit code: {{ run.exitcode }} | runtime: {{ run.runtime | format_number({fraction_digit: 3}) }})</div>
|
<div class="d-md-inline d-block text-left">(exit code: {{ run.exitcode }} | runtime: {{ run.runtime | interval }})</div>
|
||||||
{% if 'M' in run.flags %}
|
{% if 'M' in run.flags %}
|
||||||
<div class="d-md-inline d-block text-left">Manual Run</div>
|
<div class="d-md-inline d-block text-left">Manual Run</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
Loading…
Reference in New Issue