Skip to content

Commit

Permalink
fixed hour rotation to go with minutes
Browse files Browse the repository at this point in the history
  • Loading branch information
Jfreundlich01 committed May 17, 2022
1 parent 936e439 commit 94ac339
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions clock.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const secondHand = document.getElementById("second");
function clockRun(){
//creates date. Accesses current day and time
const date = new Date();
//console.log(date)
console.log(date)

//creates hour variable. Prints to military time so out of 24
let hours = date.getHours()
Expand All @@ -19,16 +19,20 @@ function clockRun(){
// creates seconds variable. Prints 0-60
let seconds = date.getSeconds()

let secondRotation = (seconds/60)
let minuteRotation = (minutes/60)
let hourRotation = (((minuteRotation) + hours)/12)

//console.log(seconds);

//gets the seconds to run!!
secondHand.style.transform = "rotate(" + ((seconds/60)*360) + "deg)"
secondHand.style.transform = "rotate(" + (secondRotation * 360) + "deg)"

//get the minutes to run!!
minuteHand.style.transform = "rotate(" + ((minutes/60)*360) + "deg)"
minuteHand.style.transform = "rotate(" + (minuteRotation * 360) + "deg)"

//gert the hours to run!
hourHand.style.transform = "rotate(" + ((hours/12)*360) + "deg)"
hourHand.style.transform = "rotate(" + (hourRotation * 360) + "deg)"

}

Expand Down

0 comments on commit 94ac339

Please sign in to comment.