Skip to content

Commit

Permalink
Show elapsed minutes on scoreboard
Browse files Browse the repository at this point in the history
  • Loading branch information
vmcj committed Aug 31, 2023
1 parent 8b7fd31 commit 77d0b6b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions webapp/src/Twig/TwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public function getFilters(): array
return [
new TwigFilter('printtimediff', $this->printtimediff(...)),
new TwigFilter('printremainingminutes', $this->printremainingminutes(...)),
new TwigFilter('printelapsedminutes', $this->printelapsedminutes(...)),
new TwigFilter('printtime', $this->printtime(...)),
new TwigFilter('printHumanTimeDiff', $this->printHumanTimeDiff(...)),
new TwigFilter('printtimeHover', $this->printtimeHover(...), ['is_safe' => ['html']]),
Expand Down Expand Up @@ -174,6 +175,16 @@ public function printremainingminutes(float $start, float $end): string
}
}

public function printelapsedminutes(float $start, float $end): string
{
$minutesElapsed = floor(($end - $start)/60);
if ($minutesElapsed == 1) {
return '1 minute ago';
} else {
return $minutesElapsed . ' minutes ago';
}
}

/**
* Print a time formatted as specified. The format is according to date().
* @param Contest|null $contest If given, print time relative to that contest start.
Expand Down
2 changes: 2 additions & 0 deletions webapp/templates/partials/scoreboard.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
{{ now | printremainingminutes(current_contest.endtime) }}
{% else %}
{% if current_contest.freezeData.started %}
{% set now = 'now'|date('U') %}
started:
{{ current_contest.starttime | printelapsedminutes(now) }} at
{% else %}
starts:
{% endif %}
Expand Down

0 comments on commit 77d0b6b

Please sign in to comment.