Browse Source

improved clock widget

master
Youen Toupin 3 years ago
parent
commit
81c2d82e1d
  1. 10
      WebApp/src/components/widgets/clock.css
  2. 4
      WebApp/src/components/widgets/clock.tsx

10
WebApp/src/components/widgets/clock.css

@ -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;
}

4
WebApp/src/components/widgets/clock.tsx

@ -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>

Loading…
Cancel
Save