-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoday.js
More file actions
44 lines (43 loc) · 875 Bytes
/
today.js
File metadata and controls
44 lines (43 loc) · 875 Bytes
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
const date = [];
const week = ["일", "월", "화", "수", "목", "금", "토"];
const today = new Date().getDate();
const day = new Date().getDay();
console.log(today, day);
const result = [];
const dates = [];
const days = [];
const istoday = [];
for (let i = -3; i < 7; i++) {
if (today + i > 31) {
dates.push(today + i - 31);
istoday.push(false);
continue;
}
if (day + i > 6) {
dates.push(today + i);
istoday.push(false);
continue;
}
if (today + i == 31) {
dates.push(today + i);
istoday.push(true);
continue;
}
dates.push(today + i);
istoday.push(false);
}
for (let i = -3; i < 7; i++) {
if (day + i > 6) {
days.push(day + i - 6);
continue;
}
days.push(day + i);
}
dates.map((a, i) => {
result.push({
date: dates[i],
day: week[days[i]],
istoday: istoday[i],
});
});
console.log(result);