Skip to content

Commit

Permalink
add tme to deg function for demo test
Browse files Browse the repository at this point in the history
  • Loading branch information
tinchox5 committed Mar 21, 2023
1 parent fd21c9f commit 175aa42
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,22 @@
<script>
var el = document.querySelector(".minuto")
var minuto = el.style.getPropertyValue("--angle")
function timeToDegrees(hours, minutes, seconds) {
const hourDegrees = (hours % 12) * 30 + (minutes / 2) + (seconds / 120);
const minuteDegrees = minutes * 6 + (seconds / 10);
const secondDegrees = seconds * 6;
return {
hour: hourDegrees,
minute: minuteDegrees,
second: secondDegrees,
};
}

setInterval(() => {
minuto = minuto + 1.7
el.style.setProperty("--angle", minuto++)
const now = new Date();
const degrees = timeToDegrees(now.getUTCHours(), now.getUTCMinutes(), now.getUTCSeconds());
el.style.setProperty("--angle", degrees.second)

}, 1000)
</script>
</body>
Expand Down

0 comments on commit 175aa42

Please sign in to comment.