Skip to content

Commit fa2a8d9

Browse files
committed
Shorten calculation of "hour"
1 parent 7ebfaf7 commit fa2a8d9

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

clock/js/experiment.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,7 @@ $(function(){
2424
function startClock() {
2525
var angle = 360/60,
2626
date = new Date(),
27-
hour = (function() {
28-
var h = date.getHours();
29-
if(h > 12) {
30-
h = h - 12;
31-
}
32-
return h
33-
})(),
27+
hour = date.getHours() % 12,
3428
minute = date.getMinutes(),
3529
second = date.getSeconds(),
3630
hourAngle = (360/12) * hour + (360/(12*60)) * minute;
@@ -41,4 +35,4 @@ $(function(){
4135
$('#hour')[0].style[prop] = 'rotate('+hourAngle+'deg)';
4236
}
4337
}
44-
});
38+
});

0 commit comments

Comments
 (0)