This repository has been archived on 2024-04-03. You can view files and clone it, but cannot push or open issues or pull requests.
OLD-GZod01.fr_Source_Code-OLD/main-site/time.html

98 lines
2.3 KiB
HTML
Raw Normal View History

2023-03-25 09:29:34 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Fira+Code:wght@300;400;500&display=swap" rel="stylesheet">
<title>Clock</title>
<style>
body, html {
font-family: 'Fira Code', monospace;
}
body {
margin: 0;
background-color: #121869;
color: white;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.clock {
display: none;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100%;
position: relative;
top: -4em;
}
.time {
display: flex;
font-size: 500%;
}
.date {
font-size: 200%;
display: flex;
justify-content: center;
margin-top: 1em;
}
</style>
</head>
<body>
<div id="clock" class="clock">
<div class="time">
<div id="hours"></div>
<div class="sep">:</div>
<div id="minutes"></div>
<div class="sep">:</div>
<div id="seconds"></div>
</div>
<div class="date">
<div id="date-formated"></div>
</div>
</div>
<div class="actions">
</div>
<script>
const hours = document.getElementById('hours')
const minutes = document.getElementById('minutes')
const seconds = document.getElementById('seconds')
const dateFormated = document.getElementById('date-formated')
const clock = document.getElementById('clock')
let addPaddings = val => {
let str = val.toString()
if (str.length === 1) {
return '0' + str
}
return str
}
let tick = () => {
clock.style.display = 'flex'
let date = new Date()
hours.innerHTML = addPaddings(date.getHours())
minutes.innerHTML = addPaddings(date.getMinutes())
seconds.innerHTML = addPaddings(date.getSeconds())
dateFormated.innerHTML = (new Date()).toLocaleString('en', {year: 'numeric', month: 'long', day: 'numeric', weekday: 'long'})
}
tick()
setInterval(() => {
tick()
}, 1000)
</script>
</body>
</html>