From 14032410ad7b57b54601bbbddef30a6e7783af44 Mon Sep 17 00:00:00 2001 From: Michael Vasseur <14887731+vmcj@users.noreply.github.com> Date: Thu, 31 Aug 2023 08:15:30 +0200 Subject: [PATCH] Show elapsed minutes on scoreboard instead of minutes left See: https://github.com/DOMjudge/domjudge/issues/2064 --- webapp/src/Twig/TwigExtension.php | 16 ++++++++-------- webapp/templates/partials/scoreboard.html.twig | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/webapp/src/Twig/TwigExtension.php b/webapp/src/Twig/TwigExtension.php index 3161547716..eeda610b61 100644 --- a/webapp/src/Twig/TwigExtension.php +++ b/webapp/src/Twig/TwigExtension.php @@ -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']]), @@ -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'; } } diff --git a/webapp/templates/partials/scoreboard.html.twig b/webapp/templates/partials/scoreboard.html.twig index cdfa19de11..48c211ed4c 100644 --- a/webapp/templates/partials/scoreboard.html.twig +++ b/webapp/templates/partials/scoreboard.html.twig @@ -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: