Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show number of days left for long lasting contests. #1094

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
16 changes: 13 additions & 3 deletions cms/server/contest/static/cws_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,25 @@ CMS.CWSUtils.prototype.format_timedelta = function(timedelta) {
timedelta = 0;
}


var days = Math.floor(timedelta / 86400);
timedelta %= 86400;
var hours = Math.floor(timedelta / 3600);
timedelta %= 3600;
var minutes = Math.floor(timedelta / 60);
timedelta %= 60;
var seconds = Math.floor(timedelta);

return this.two_digits(hours) + ":"
+ this.two_digits(minutes) + ":"
+ this.two_digits(seconds);
if (days <= 2) {
// If less than 72 hours left, return the exact number of hours, minutes and seconds.
return this.two_digits(days * 24 + hours) + ":"
+ this.two_digits(minutes) + ":"
+ this.two_digits(seconds);
}
else {
// Otherwise only return the number of days.
return days + $("#translation_days").text();
}
};


Expand Down
3 changes: 3 additions & 0 deletions cms/server/contest/templates/contest.html
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ <h1>{% trans %}Welcome{% endtrans %}</h1>
<div style="display: none" id="translation_time_left">
{% trans %}Time left:{% endtrans %}
</div>
<div style="display: none" id="translation_days">
{% trans %}days{% endtrans %}
</div>
<!-- End -->
<div id="main" class="container">
<div class="row">
Expand Down