-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
47 lines (41 loc) · 1.35 KB
/
script.js
File metadata and controls
47 lines (41 loc) · 1.35 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
window.onload = function() {printTime();}
function printTime() {
function normalizaTempo(tempo) {
return tempo < 10 ? '0' + tempo : tempo;
}
var D = new Date();
var horas = normalizaTempo(D.getHours());
var minutos = normalizaTempo(D.getMinutes());
var segundos = normalizaTempo(D.getSeconds());
var data = normalizaTempo(D.getDate());
var dia = D.getDay();
var mes = D.getMonth();
var ano = D.getFullYear();
switch(dia) {
case 0:
dia = "Domingo";
break;
case 1:
dia = "Segunda-Feira";
break;
case 2:
dia = "Terça-Feira";
break;
case 3:
dia = "Quarta-Feira";
break;
case 4:
dia = "Quinta-Feira";
break;
case 5:
dia = "Sexta-Feira";
break;
case 6:
dia = "Sábado";
break;
}
mes = (mes < 9 ? "0" : "") + (mes + 1);
document.getElementById("horas").innerHTML = horas + ":" + minutos + ":" + segundos;
document.getElementById("semana").innerHTML = dia + " - " + data + '/' + mes + "/" + ano;
}
setInterval(printTime, 1000);