Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: update params

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I probably misunderstand you but for now I'll assume you meant because of the new parameter added.

I don't think we should add basic parameters but only use a @param in case we really need to explain that parameter which I would say is actually an anti-pattern or in case of arrays where we need to show the type of the array.

*/
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
2 changes: 1 addition & 1 deletion webapp/templates/partials/problem_list.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -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) }}:<br/>{{ label }}">
title="Between {{ stat.start.timestamp | printtime(null, contest, false) }} and {{ stat.end.timestamp | printtime(null, contest, false) }}:<br/>{{ label }}">
</div>
{% endfor %}
</div>
Expand Down
Loading