diff --git a/webapp/src/Twig/TwigExtension.php b/webapp/src/Twig/TwigExtension.php
index 60df1de6cc..4ce1f2ac14 100644
--- a/webapp/src/Twig/TwigExtension.php
+++ b/webapp/src/Twig/TwigExtension.php
@@ -204,14 +204,24 @@ 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 $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): 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 ($maskOutsideContest) {
+ 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;
// 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 %}