From 936e4391ad18df06dd8615216ed35c68b6337451 Mon Sep 17 00:00:00 2001 From: Jfreundlich01 Date: Mon, 16 May 2022 18:23:20 -0400 Subject: [PATCH 1/2] everything is woring properly --- .vscode/settings.json | 3 +++ clock.js | 36 ++++++++++++++++++++++++++++++++++++ style.css | 7 +++++++ 3 files changed, 46 insertions(+) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..155422b --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "liveServer.settings.port": 5503 +} \ No newline at end of file diff --git a/clock.js b/clock.js index e69de29..d2cc028 100644 --- a/clock.js +++ b/clock.js @@ -0,0 +1,36 @@ +const hourHand = document.getElementById("hour"); +const minuteHand = document.getElementById("minute"); +const secondHand = document.getElementById("second"); + +//function runs clock +function clockRun(){ + //creates date. Accesses current day and time + const date = new Date(); + //console.log(date) + + //creates hour variable. Prints to military time so out of 24 + let hours = date.getHours() + //console.log(hours) + + //creates minute variable. Prints 0-60. + let minutes = date.getMinutes() + //console.log(minutes) + + // creates seconds variable. Prints 0-60 + let seconds = date.getSeconds() + + //console.log(seconds); + + //gets the seconds to run!! + secondHand.style.transform = "rotate(" + ((seconds/60)*360) + "deg)" + + //get the minutes to run!! + minuteHand.style.transform = "rotate(" + ((minutes/60)*360) + "deg)" + + //gert the hours to run! + hourHand.style.transform = "rotate(" + ((hours/12)*360) + "deg)" + +} + +setInterval(clockRun,1000) + diff --git a/style.css b/style.css index 60816ef..a22c473 100644 --- a/style.css +++ b/style.css @@ -1,14 +1,21 @@ #clock { + position: relative; } #clock img { + position: absolute; + } + #hour { + position: absolute; } #minute { + position: absolute; } #second { + position: absolute; } From 94ac3398b79781654f7a95b2d8ee289e1ee77440 Mon Sep 17 00:00:00 2001 From: Jfreundlich01 Date: Tue, 17 May 2022 09:24:40 -0400 Subject: [PATCH 2/2] fixed hour rotation to go with minutes --- clock.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/clock.js b/clock.js index d2cc028..4bd89fe 100644 --- a/clock.js +++ b/clock.js @@ -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() @@ -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)" }