Skip to content

Commit

Permalink
Show elapsed minutes on scoreboard instead of minutes left
Browse files Browse the repository at this point in the history
See: #2064
  • Loading branch information
vmcj committed Sep 19, 2023
1 parent 2be7100 commit cfad1a5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions webapp/src/Twig/TwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,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 @@ -162,15 +162,15 @@ public function printtimediff(float $start, ?float $end = null): string
return Utils::printtimediff($start, $end);
}

public function printremainingminutes(float $start, float $end): string
public function printelapsedminutes(float $start, float $end): string
{
$minutesRemaining = floor(($end - $start)/60);
if ($minutesRemaining < 1) {
return 'less than 1 minute to go';
} elseif ($minutesRemaining == 1) {
return '1 minute to go';
$minutesElapsed = floor(($end - $start)/60);
if ($minutesElapsed < 1) {
return 'started less than 1 minute ago';
} elseif ($minutesElapsed == 1) {
return 'started 1 minute ago';
} else {
return $minutesRemaining . ' minutes to go';
return 'started' . $minutesElapsed . ' minutes ago';
}
}

Expand Down
2 changes: 1 addition & 1 deletion webapp/templates/partials/scoreboard.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
contest over, waiting for results
{% elseif static %}
{% set now = 'now'|date('U') %}
{{ now | printremainingminutes(current_contest.endtime) }}
{{ current_contest.starttime | printelapsedminutes(now) }}
{% else %}
{% if current_contest.freezeData.started %}
started:
Expand Down

0 comments on commit cfad1a5

Please sign in to comment.