import clock from 'clock' ; import document from 'document' ; clock . granularity = 'seconds' ; let hourHand = document . getElementById ( 'hours' ) as GroupElement ; let minHand = document . getElementById ( 'mins' ) as GroupElement ; let secHand = document . getElementById ( 'secs' ) as GroupElement ; function hoursToAngle ( hours , minutes ) { let hourAngle = ( 360 / 12 ) * hours ; let minAngle = ( 360 / 12 / 60 ) * minutes ; return hourAngle + minAngle ; } function minutesToAngle ( minutes ) { return ( 360 / 60 ) * minutes ; } function secondsToAngle ( seconds ) { return ( 360 / 60 ) * seconds ; } function updateClock ( ) { let today = new Date ( ) ; let hours = today . getHours ( ) % 12 ; let mins = today . getMinutes ( ) ; let secs = today . getSeconds ( ) ; hourHand . groupTransform . rotate . angle = hoursToAngle ( hours , mins ) ; minHand . groupTransform . rotate . angle = minutesToAngle ( mins ) ; secHand . groupTransform . rotate . angle = secondsToAngle ( secs ) ; } clock . ontick = ( ) => updateClock ( ) ;