From 1b214ae77c92265c0002c02a0f2b16f91364e7a6 Mon Sep 17 00:00:00 2001
From: Michael Vasseur <14887731+vmcj@users.noreply.github.com>
Date: Sun, 26 Oct 2025 16:47:16 +0100
Subject: [PATCH 1/4] Don't display contest time from before/after contest
It looks ugly in some cases and less professional in others where printing
happened much earlier. The exact time is not relevant and could lead to
discussions with teams.
Originally this was only for the team interface but it does add information for
the jury. It's more important to know that something happened before the
contest (or after) and the interpretation of that time as knowing when it
exactly happened.
We still do this in case we explicit set the format such as for the countdown
etc.
---
webapp/src/Twig/TwigExtension.php | 9 ++++++++-
webapp/templates/partials/problem_list.html.twig | 2 +-
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/webapp/src/Twig/TwigExtension.php b/webapp/src/Twig/TwigExtension.php
index 60df1de6cc..5eaed9de59 100644
--- a/webapp/src/Twig/TwigExtension.php
+++ b/webapp/src/Twig/TwigExtension.php
@@ -205,13 +205,20 @@ public function printelapsedminutes(float $start, float $end): string
* 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.
*/
- public function printtime(string|float|null $datetime, ?string $format = null, ?Contest $contest = null): string
+ public function printtime(string|float|null $datetime, ?string $format = null, ?Contest $contest = null, bool $squash = true): string
{
if ($datetime === null) {
$datetime = Utils::now();
}
if ($contest !== null && $this->config->get('show_relative_time')) {
$relativeTime = $contest->getContestTime((float)$datetime);
+ if ($relativeTime < 0 && $squash) {
+ return "Before contest";
+ }
+ if ($relativeTime > $contest->getContestTime($contest->getEndtime())) {
+ // The case where it would be exactly at EndTime is important to display
+ return "After contest";
+ }
$sign = ($relativeTime < 0 ? -1 : 1);
$relativeTime *= $sign;
// We're not showing seconds, while the last minute before
diff --git a/webapp/templates/partials/problem_list.html.twig b/webapp/templates/partials/problem_list.html.twig
index b85f2437df..e98ba39797 100644
--- a/webapp/templates/partials/problem_list.html.twig
+++ b/webapp/templates/partials/problem_list.html.twig
@@ -105,7 +105,7 @@
data-bs-toggle="tooltip"
data-bs-placement="top"
data-bs-html="true"
- title="Between {{ stat.start.timestamp | printtime(null, contest) }} and {{ stat.end.timestamp | printtime(null, contest) }}:
{{ label }}">
+ title="Between {{ stat.start.timestamp | printtime(null, contest, false) }} and {{ stat.end.timestamp | printtime(null, contest, false) }}:
{{ label }}">
{% endfor %}
From 86d19496732b7c06952307b72b3654f504198b60 Mon Sep 17 00:00:00 2001
From: Michael Vasseur <14887731+vmcj@users.noreply.github.com>
Date: Wed, 12 Nov 2025 21:51:23 +0100
Subject: [PATCH 2/4] Handle @eldering his feedback
---
webapp/src/Twig/TwigExtension.php | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/webapp/src/Twig/TwigExtension.php b/webapp/src/Twig/TwigExtension.php
index 5eaed9de59..bdfa6a27b1 100644
--- a/webapp/src/Twig/TwigExtension.php
+++ b/webapp/src/Twig/TwigExtension.php
@@ -212,12 +212,14 @@ public function printtime(string|float|null $datetime, ?string $format = null, ?
}
if ($contest !== null && $this->config->get('show_relative_time')) {
$relativeTime = $contest->getContestTime((float)$datetime);
- if ($relativeTime < 0 && $squash) {
- return "Before contest";
- }
- if ($relativeTime > $contest->getContestTime($contest->getEndtime())) {
- // The case where it would be exactly at EndTime is important to display
- return "After contest";
+ if ($squash) {
+ if ($relativeTime < 0) {
+ return "Before contest";
+ }
+ if ($relativeTime > $contest->getContestTime($contest->getEndtime())) {
+ // The case where it would be exactly at EndTime is important to display
+ return "After contest";
+ }
}
$sign = ($relativeTime < 0 ? -1 : 1);
$relativeTime *= $sign;
From b08f9ef199e54ec22fd56d37da1b1de1f1382a4e Mon Sep 17 00:00:00 2001
From: Michael Vasseur <14887731+vmcj@users.noreply.github.com>
Date: Wed, 12 Nov 2025 21:56:22 +0100
Subject: [PATCH 3/4] Address @meisterT his feedback
---
webapp/src/Twig/TwigExtension.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/webapp/src/Twig/TwigExtension.php b/webapp/src/Twig/TwigExtension.php
index bdfa6a27b1..7f92dc2d79 100644
--- a/webapp/src/Twig/TwigExtension.php
+++ b/webapp/src/Twig/TwigExtension.php
@@ -204,6 +204,7 @@ public function printelapsedminutes(float $start, float $end): string
/**
* 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.
+ * @param bool $squash, When true and contest is given replace time with before/after.
*/
public function printtime(string|float|null $datetime, ?string $format = null, ?Contest $contest = null, bool $squash = true): string
{
From a278786707660f8318f4e7b293cf3cd5dcd66f6d Mon Sep 17 00:00:00 2001
From: Michael Vasseur <14887731+vmcj@users.noreply.github.com>
Date: Wed, 12 Nov 2025 21:57:14 +0100
Subject: [PATCH 4/4] And second remark
---
webapp/src/Twig/TwigExtension.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/webapp/src/Twig/TwigExtension.php b/webapp/src/Twig/TwigExtension.php
index 7f92dc2d79..4ce1f2ac14 100644
--- a/webapp/src/Twig/TwigExtension.php
+++ b/webapp/src/Twig/TwigExtension.php
@@ -204,16 +204,16 @@ public function printelapsedminutes(float $start, float $end): string
/**
* 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.
- * @param bool $squash, When true and contest is given replace time with before/after.
+ * @param bool $maskOutsideContest, When true and contest is given replace time with before/after.
*/
- public function printtime(string|float|null $datetime, ?string $format = null, ?Contest $contest = null, bool $squash = true): string
+ public function printtime(string|float|null $datetime, ?string $format = null, ?Contest $contest = null, bool $maskOutsideContest = true): string
{
if ($datetime === null) {
$datetime = Utils::now();
}
if ($contest !== null && $this->config->get('show_relative_time')) {
$relativeTime = $contest->getContestTime((float)$datetime);
- if ($squash) {
+ if ($maskOutsideContest) {
if ($relativeTime < 0) {
return "Before contest";
}