-
Notifications
You must be signed in to change notification settings - Fork 0
/
calendar.js
81 lines (77 loc) · 1.47 KB
/
calendar.js
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
var date = new Date();
var month = "";
var monthDays = 0;
switch(date.getMonth()){
case 0:
month = "Enero";
monthDays = 31;
break;
case 1:
month = "Febrero"
if(date.getFullYear()%4==0 && date.getFullYear()%100==0 && date.getFullYear()%400==0){
monthDays = 29;
}else{
monthDays = 28;
}
break;
case 2:
month = "Marzo";
monthDays = 31;
break;
case 3:
month = "Abril";
monthDays = 30;
break;
case 4:
month = "Mayo";
monthDays = 31;
break;
case 5:
month = "Junio";
monthDays = 30;
break;
case 6:
month = "Julio";
monthDays = 31;
break;
case 7:
month = "Agosto";
monthDays = 31;
break;
case 8:
month = "Sepiembre"
monthDays = 30;
break;
case 9:
month = "Octubre";
monthDays = 31;
break;
case 10:
month = "Noviembre";
monthDays = 30;
break;
case 11:
month = "Diciembre"
monthDays = 31;
break;
default:
console.log("Invalid month")
}
document.getElementById("month").innerHTML = `
<ul>
<li class="prev">❮</li>
<li class="next">❯</li>
<li>${month}<br><span style="font-size:18px">${date.getFullYear()}</span></li>
</ul>`;
if(date.getDay() != 6){
for(let i = -1; i < date.getDay(); i++){
document.getElementById('days').innerHTML+= `<li></li>`
}
}
for(let i = 1; i <= monthDays; i++) {
if (i == date.getDate()){
document.getElementById('days').innerHTML+= `<li><span class="active">${i}</span></li>`
}else{
document.getElementById('days').innerHTML+= `<li>${i}</li>`
}
}