Skip to content
Open
Show file tree
Hide file tree
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
49 changes: 25 additions & 24 deletions webapp/src/Twig/TwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function printtime(string|float|null $datetime, ?string $format = null, ?
if ($datetime === null) {
$datetime = Utils::now();
}
if ($contest !== null && $this->config->get('show_relative_time')) {
if ($contest !== null) {
$relativeTime = $contest->getContestTime((float)$datetime);
if ($maskOutsideContest) {
if ($relativeTime < 0) {
Expand All @@ -121,31 +121,32 @@ public function printtime(string|float|null $datetime, ?string $format = null, ?
return "After contest";
}
}
$sign = ($relativeTime < 0 ? -1 : 1);
$relativeTime *= $sign;
// We're not showing seconds, while the last minute before
// contest start should show as "-0:01", so if there's a
// nonzero amount of seconds before the contest, we have to
// add a minute.
$s = $relativeTime % 60;
$relativeTime = ($relativeTime - $s) / 60;
if ($sign < 0 && $s > 0) {
$relativeTime++;
}
$m = $relativeTime % 60;
$relativeTime = ($relativeTime - $m) / 60;
$h = $relativeTime;
if ($sign < 0) {
return sprintf("-%d:%02d", $h, $m);
} else {
return sprintf("%d:%02d", $h, $m);
}
} else {
if ($format === null) {
$format = $this->config->get('time_format');
if ($this->config->get('show_relative_time')) {
$sign = ($relativeTime < 0 ? -1 : 1);
$relativeTime *= $sign;
// We're not showing seconds, while the last minute before
// contest start should show as "-0:01", so if there's a
// nonzero amount of seconds before the contest, we have to
// add a minute.
$s = $relativeTime % 60;
$relativeTime = ($relativeTime - $s) / 60;
if ($sign < 0 && $s > 0) {
$relativeTime++;
}
$m = $relativeTime % 60;
$relativeTime = ($relativeTime - $m) / 60;
$h = $relativeTime;
if ($sign < 0) {
return sprintf("-%d:%02d", $h, $m);
} else {
return sprintf("%d:%02d", $h, $m);
}
}
return Utils::printtime($datetime, $format);
}
if ($format === null) {
$format = $this->config->get('time_format');
}
return Utils::printtime($datetime, $format);
}

#[AsTwigFilter('printHumanTimeDiff')]
Expand Down
2 changes: 1 addition & 1 deletion webapp/templates/partials/clarification_list.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<tr class="{% if team is defined and team.unreadClarifications.contains(clarification) %}unseen{% endif %}">
<td>
<a data-ajax-modal data-ajax-modal-after="markSeen" href="{{ link }}">
{{ clarification.submittime | printtime(null, clarification.contest) }}
{{ clarification.submittime | printtime(format: null, contest: clarification.contest, maskOutsideContest: true) }}
</a>
</td>

Expand Down
Loading