Spaces:
Running
Running
File size: 1,035 Bytes
30d8d56 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
// Clock functionality
function updateClock() {
const now = new Date();
const hours = now.getHours() % 12;
const minutes = now.getMinutes();
const seconds = now.getSeconds();
// Calculate degrees for clock hands
// Corrected hour calculation (12 should be at top)
const hourDeg = ((hours * 30) + (minutes * 0.5)) - 180;
const minuteDeg = minutes * 6;
const secondDeg = seconds * 6;
// Rotate clock hands
document.querySelector('.hour-hand').style.transform = `translateX(-50%) rotate(${hourDeg}deg)`;
document.querySelector('.minute-hand').style.transform = `translateX(-50%) rotate(${minuteDeg}deg)`;
document.querySelector('.second-hand').style.transform = `translateX(-50%) rotate(${secondDeg}deg)`;
// Update digital display
const timeString = now.toLocaleTimeString();
document.querySelector('.current-time-display').textContent = `Current Time: ${timeString}`;
}
// Initialize clock and update every second
updateClock();
setInterval(updateClock, 1000); |