Skip to content

Commit

Permalink
add st,nd,rd,th to the day #98
Browse files Browse the repository at this point in the history
  • Loading branch information
MathieuNls committed Jan 8, 2016
1 parent 7836fce commit 978dc55
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion application/views/time.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
<div class="row">

<div class="col-sm-12">
<span class="months"></span>,
<span class="days"></span>
<span class="months"></span>,
<span class="years"></span>
</div>

Expand Down
12 changes: 11 additions & 1 deletion assets/js/time.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,23 @@ function getTime() {
'total': t,
'years':years,
'months':months,
'days': days,
'days': days + "<sup>" + nth(days) + "</sup>",
'hours': hours,
'minutes': minutes,
'seconds': seconds
};
}

function nth(d) {
if(d>3 && d<21) return 'th';
switch (d % 10) {
case 1: return "st";
case 2: return "nd";
case 3: return "rd";
default: return "th";
}
}

function initializeClock(id, endtime) {
var clock = document.getElementById(id);
var daysSpan = clock.querySelector('.days');
Expand Down

0 comments on commit 978dc55

Please sign in to comment.