Spaces:
Running
Running
l'horloge est legerement décalée. le 1 a la place du 12 etc... remplacer les formules par des equations tres simples
30d8d56
verified
| // 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); |