Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion webapp/src/Twig/TwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading