-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.js
51 lines (43 loc) · 1.12 KB
/
index.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
function dpTime(){ //wtf
let now = new Date();
let hours = now.getHours();
let minutes = now.getMinutes();
let seconds = now.getSeconds();
let dates = now.getDate();
let months = now.getMonth();
let days = now.getDay();
let ampm = "오후 ";
if (hours > 12)
hours -= 12;
else
ampm = "오전 ";
months++; //0~11 -> 1~12
days = setDays(days);
render(months, dates, days, ampm, hours, minutes, seconds);
}
function setDays(days) {
if (days == 1)
return "월요일";
if (days == 2)
return "화요일";
if (days == 3)
return "수요일";
if (days == 4)
return "목요일";
if (days == 5)
return "금요일";
if (days == 6)
return "토요일";
if (days == 0)
return "일요일";
}
function zeroFill(number) {
if (number < 10)
return "0" + number;
else
return number;
}
function render(months, dates, days, ampm, hours, minutes, seconds) {
var CLOCK = document.getElementById("count").innerHTML = months + "월 "+ dates + "일 "+ days + " "+ ampm+ zeroFill(hours)+ ":" + zeroFill(minutes)+ ":" + zeroFill(seconds);
}
setInterval(() => dpTime(), 1000);