-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
49 lines (38 loc) · 1.51 KB
/
app.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
function displayTime() {
const date = new Date()
console.log(date)
let hours = ("0" + date.getHours()).slice(-2);
let minutes = ("0" + date.getMinutes()).slice(-2);
let seconds = ("0" + date.getSeconds()).slice(-2);
const greetings = ['Good Morning', 'Good Afternoon', 'Good Evening']
let index = hours >= 12 && hours < 17 ? 1 : hours >= 17 ? 2 : 0
// Array to set the day of the week to apear in the screen
let weekDay = [
"Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday", "Sunday"
]
let dayOfWeek = weekDay[date.getDay()]
let weekly = date.getDate()
// Array to set the day of the week to apear in the screen
const months = [
'January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November', 'December'
]
let month = months[date.getMonth()]
let actualYear = date.getFullYear()
//
var turno
if (hours < 12 && hours >= 0) {
var turno = 'AM'
} else {
var turno = 'PM'
}
document.getElementById('day').innerHTML = `${greetings[index]} it's ${dayOfWeek}`
document.getElementById('hour').innerHTML = hours
document.getElementById('minute').innerHTML = minutes
document.getElementById('second').innerHTML = seconds
document.getElementById('season').innerHTML = weekly + '/' + month + '/' + actualYear
document.getElementById('schedule').innerHTML = turno
}
setInterval(displayTime, 1000)
displayTime()