Skip to content

Commit 69c4110

Browse files
committed
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.
1 parent f73e6a7 commit 69c4110

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

webapp/src/Twig/TwigExtension.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,14 +205,24 @@ public function printelapsedminutes(float $start, float $end): string
205205
/**
206206
* Print a time formatted as specified. The format is according to date().
207207
* @param Contest|null $contest If given, print time relative to that contest start.
208+
* @param bool $maskOutsideContest When true and contest is given replace time with before/after.
208209
*/
209-
public function printtime(string|float|null $datetime, ?string $format = null, ?Contest $contest = null): string
210+
public function printtime(string|float|null $datetime, ?string $format = null, ?Contest $contest = null, bool $maskOutsideContest = true): string
210211
{
211212
if ($datetime === null) {
212213
$datetime = Utils::now();
213214
}
214215
if ($contest !== null && $this->config->get('show_relative_time')) {
215216
$relativeTime = $contest->getContestTime((float)$datetime);
217+
if ($maskOutsideContest) {
218+
if ($relativeTime < 0) {
219+
return "Before contest";
220+
}
221+
if ($relativeTime > $contest->getContestTime($contest->getEndtime())) {
222+
// The case where it would be exactly at EndTime is important to display
223+
return "After contest";
224+
}
225+
}
216226
$sign = ($relativeTime < 0 ? -1 : 1);
217227
$relativeTime *= $sign;
218228
// We're not showing seconds, while the last minute before

webapp/templates/partials/problem_list.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
data-bs-toggle="tooltip"
106106
data-bs-placement="top"
107107
data-bs-html="true"
108-
title="Between {{ stat.start.timestamp | printtime(null, contest) }} and {{ stat.end.timestamp | printtime(null, contest) }}:<br/>{{ label }}">
108+
title="Between {{ stat.start.timestamp | printtime(null, contest, false) }} and {{ stat.end.timestamp | printtime(null, contest, false) }}:<br/>{{ label }}">
109109
</div>
110110
{% endfor %}
111111
</div>

0 commit comments

Comments
 (0)