apnadmin/Macslow--clocks — pull request #2 by bradland (2014-03-10 20:21:52+00:00)
Title: Correct hour-hand geometry for 24-hour format.

This is a dupe of the correction offered on Hacker News. Thanks for posting these, they're great!

This particular clock only uses the hour hand, but because it's a 24-hour clock, the math required is different. It looks like this snippet of code was reused from the others (12-hour clocks). The design was updated to 24-hour, but the math for the hour hand wasn't. Fortunately, the math for a 24-hour clock is simple:

360 degrees divided by the number of seconds in 24-hours (86400) gives you your rotation value: 0.004166666 degrees of rotation per second.

Now all you need to know is the number of seconds that have elapsed for the current time:

hour_rotate_angle = (0.004166666*((tDate.getHours()*3600)+(tDate.getMinutes()*60)+tDate.getSeconds()));

With an update to lines 58 and 92 with this code, the 24-hour clock works.