improved clock widget

This commit is contained in:
Youen Toupin 2022-04-10 19:47:11 +02:00
parent 184f1cee33
commit 81c2d82e1d
2 changed files with 10 additions and 4 deletions

View File

@ -1,9 +1,15 @@
div.clock {
text-align: center;
}
div.clock div.date {
display: inline-block;
text-aligne: center;
}
div.clock p.time {
display: inline-block;
font-size: 3rem;
margin-left: 0.5rem;
font-family: monospace;
font-size: 3.5rem;
margin-left: 0.8rem;
}

View File

@ -6,13 +6,13 @@ require("./clock.css");
export default class Clock extends Component {
view(vnode: m.Vnode<{}, {}>): m.Children {
var now = new Date();
var days = ['Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi', 'Dimanche'];
var days = ['Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi'];
var nextUpdateDelay = 61 - now.getSeconds();
setTimeout(() => m.redraw(), nextUpdateDelay * 1000);
return <div class="clock">
<div class="date">
<p class="day">{days[now.getDay()-1]}</p>
<p class="day">{days[now.getDay()]}</p>
<p class="date">{('0'+now.getDate()).slice(-2) + '/' + ('0'+now.getMonth()).slice(-2)}</p>
</div>
<p class="time">{('0'+now.getHours()).slice(-2) + ':' + ('0'+now.getMinutes()).slice(-2)}</p>