# curious/khan-exercises forked from Khan/khan-exercises

### Subversion checkout URL

You can clone with
or
.
Fetching contributors…

Cannot retrieve contributors at this time

88 lines (84 sloc) 3.54 KB
 Telling time
randRange( 1, 12 ) randRange( 0, 11 ) * 5 MINUTE > 5 ? MINUTE : "0" + "" + MINUTE randFromArray([ "a.m.", "p.m." ])

What time is it?

init({ range: [ [-4, 4 ], [ -4, 4 ] ], scale: 25 }); clock = addAnalogClock({ hour: HOUR, minute: MINUTE, minuteTicks: 0, showLabels: false }); clock.draw();
init({ range: [ [-5, 5], [-3, 3] ], scale: 25 });

The time is HOUR : NICE_MINUTE AM_PM

a 12-hour time in hours and minutes

clock.drawLabels();
path([ [-3, -1], [3, -1], [3, 1], [-3, 1], [-3, -1] ]); graph.time = label( [0, -0.1], "\\Huge{\\phantom{00}:\\phantom{00}}", "center" );

The small hand is for the hour, and the big hand is for the minutes.

The hour hand is pointing at HOUR, so the hour is HOUR.

The hour hand is between HOUR and HOUR + 1 === 13 ? 1 : HOUR + 1, so the hour is HOUR.

The hour hand is close to but hasn't passed HOUR + 1 === 13 ? 1 : HOUR + 1, so the hour is still HOUR.

graph.time.remove(); var padding = HOUR < 10 ? "\\phantom{0}" : ""; graph.time = label([0, -0.1], "\\Huge{" + padding + HOUR + ":\\phantom{00}}", "center" );

The minute hand starts pointing straight up for 0 minutes, and it makes a complete circle in one hour (passing by all 12 numbers in 60 minutes).

For each number that the minute hand passes, add \dfrac{60}{12} = 5 minutes.

The minute hand is pointing at (MINUTE / 5) === 0 ? 12: MINUTE / 5 , which represents 05 \times (MINUTE / 5) === 0 ? 12: MINUTE / 5 = MINUTE minutes.

graph.time.remove(); var padding = MINUTE < 10 ? "0" : ""; graph.time = label([0, -0.1], "\\Huge{" + HOUR + ":" + padding + MINUTE + "}", "center" );

The time is HOUR:NICE_MINUTE.

Something went wrong with that request. Please try again.