박종현

Update holiday date logic

...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
2 2
3 --- 3 ---
4 4
5 -공휴일·기념일 카운터 및 활동 추천 5 +공휴일 카운터 및 활동 추천
6 6
7 ## Getting Started (Installation) 7 ## Getting Started (Installation)
8 8
......
...@@ -9,13 +9,14 @@ ...@@ -9,13 +9,14 @@
9 "version": "1.0.0", 9 "version": "1.0.0",
10 "license": "ISC", 10 "license": "ISC",
11 "dependencies": { 11 "dependencies": {
12 - "ejs": "^3.1.7", 12 + "ejs": "^3.1.8",
13 "express": "^4.18.1", 13 "express": "^4.18.1",
14 "fs": "^0.0.1-security", 14 "fs": "^0.0.1-security",
15 "request": "^2.88.2", 15 "request": "^2.88.2",
16 "xml-js": "^1.6.11", 16 "xml-js": "^1.6.11",
17 "xml2js": "^0.4.23" 17 "xml2js": "^0.4.23"
18 - } 18 + },
19 + "devDependencies": {}
19 }, 20 },
20 "node_modules/accepts": { 21 "node_modules/accepts": {
21 "version": "1.3.8", 22 "version": "1.3.8",
...@@ -315,9 +316,9 @@ ...@@ -315,9 +316,9 @@
315 "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" 316 "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0="
316 }, 317 },
317 "node_modules/ejs": { 318 "node_modules/ejs": {
318 - "version": "3.1.7", 319 + "version": "3.1.8",
319 - "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.7.tgz", 320 + "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.8.tgz",
320 - "integrity": "sha512-BIar7R6abbUxDA3bfXrO4DSgwo8I+fB5/1zgujl3HLLjwd6+9iOnrT+t3grn2qbk9vOgBubXOFwX2m9axoFaGw==", 321 + "integrity": "sha512-/sXZeMlhS0ArkfX2Aw780gJzXSMPnKjtspYZv+f3NiKLlubezAHDU5+9xz6gd3/NhG3txQCo6xlglmTS+oTGEQ==",
321 "dependencies": { 322 "dependencies": {
322 "jake": "^10.8.5" 323 "jake": "^10.8.5"
323 }, 324 },
...@@ -1412,9 +1413,9 @@ ...@@ -1412,9 +1413,9 @@
1412 "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" 1413 "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0="
1413 }, 1414 },
1414 "ejs": { 1415 "ejs": {
1415 - "version": "3.1.7", 1416 + "version": "3.1.8",
1416 - "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.7.tgz", 1417 + "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.8.tgz",
1417 - "integrity": "sha512-BIar7R6abbUxDA3bfXrO4DSgwo8I+fB5/1zgujl3HLLjwd6+9iOnrT+t3grn2qbk9vOgBubXOFwX2m9axoFaGw==", 1418 + "integrity": "sha512-/sXZeMlhS0ArkfX2Aw780gJzXSMPnKjtspYZv+f3NiKLlubezAHDU5+9xz6gd3/NhG3txQCo6xlglmTS+oTGEQ==",
1418 "requires": { 1419 "requires": {
1419 "jake": "^10.8.5" 1420 "jake": "^10.8.5"
1420 } 1421 }
......
...@@ -39,9 +39,15 @@ h3 { ...@@ -39,9 +39,15 @@ h3 {
39 font-weight: 600; 39 font-weight: 600;
40 } 40 }
41 #activity { 41 #activity {
42 +<<<<<<< HEAD
42 width:1000px; 43 width:1000px;
43 height:fit-content; 44 height:fit-content;
44 border-radius: 10p 10px / 10px 10px; 45 border-radius: 10p 10px / 10px 10px;
46 +=======
47 + width:fit-content;
48 + height:fit-content;
49 + border-radius: 40px 80px / 80px 40px;
50 +>>>>>>> ae2e4eac4bff94c5b55f982450db9baabf3fab50
45 background-color: rgba(197, 97, 201, 0.486); 51 background-color: rgba(197, 97, 201, 0.486);
46 } 52 }
47 body { 53 body {
......
...@@ -9,7 +9,7 @@ const static = require("serve-static"); ...@@ -9,7 +9,7 @@ const static = require("serve-static");
9 // Modify the values as needed 9 // Modify the values as needed
10 var year = "2022"; 10 var year = "2022";
11 var month = "09"; 11 var month = "09";
12 -var operation = "getHoliDeInfo"; 12 +var operation = "getRestDeInfo";
13 13
14 14
15 // Do not modify the values 15 // Do not modify the values
...@@ -40,7 +40,7 @@ function getTodayDate() { ...@@ -40,7 +40,7 @@ function getTodayDate() {
40 var month = ("0" + (today.getMonth() + 1)).slice(-2); 40 var month = ("0" + (today.getMonth() + 1)).slice(-2);
41 var day = ("0" + today.getDate()).slice(-2); 41 var day = ("0" + today.getDate()).slice(-2);
42 var dateString = year + "-" + month + "-" + day; 42 var dateString = year + "-" + month + "-" + day;
43 - // return "2022-10-04"; // 테스트용 날짜를 입력하세요. 테스트가 끝나면 주석처리 하세요. ex) 2022-09-12, 2022-09-15, 2022-10-04 43 + // return "2022-12-27"; // 테스트용 날짜를 입력하세요. 테스트가 끝나면 주석처리 하세요. ex) 2022-09-12, 2022-09-15, 2022-10-04
44 return dateString; 44 return dateString;
45 } 45 }
46 46
...@@ -56,7 +56,7 @@ function getModifiedDate(locdate) { ...@@ -56,7 +56,7 @@ function getModifiedDate(locdate) {
56 } 56 }
57 57
58 // To get remaining days from locdate 58 // To get remaining days from locdate
59 -function getLeftDate(dateName, locdate) { 59 +function getLeftDate(locdate) {
60 var today = new Date(getTodayDate()); // today date 60 var today = new Date(getTodayDate()); // today date
61 var holiday = new Date(getModifiedDate(locdate)); // holiday date 61 var holiday = new Date(getModifiedDate(locdate)); // holiday date
62 var diffDate = today.getTime() - holiday.getTime(); 62 var diffDate = today.getTime() - holiday.getTime();
...@@ -119,7 +119,7 @@ function getData() { ...@@ -119,7 +119,7 @@ function getData() {
119 console.log(locdate); 119 console.log(locdate);
120 var holiArr = []; 120 var holiArr = [];
121 for (var i = 0; i < dateName.length; i++) { 121 for (var i = 0; i < dateName.length; i++) {
122 - holiArr.push(getLeftDate(dateName[i], locdate[i])); 122 + holiArr.push(getLeftDate(locdate[i]));
123 } 123 }
124 console.log(holiArr); 124 console.log(holiArr);
125 // Create tempArr to save dateName and locdate and leftDate at once 125 // Create tempArr to save dateName and locdate and leftDate at once
...@@ -141,8 +141,14 @@ function getData() { ...@@ -141,8 +141,14 @@ function getData() {
141 console.log( 141 console.log(
142 "이번 달에는 남은 공휴일이 없습니다. 다음달 데이터를 불러옵니다." 142 "이번 달에는 남은 공휴일이 없습니다. 다음달 데이터를 불러옵니다."
143 ); 143 );
144 + if (Number(month) < 12) {
144 // Get next month data 145 // Get next month data
145 month = String(Number(month) + 1).padStart(2, "0"); 146 month = String(Number(month) + 1).padStart(2, "0");
147 + } else {
148 + // Get next year data
149 + year = String(Number(year) + 1).padStart(4, "0");
150 + month = "01";
151 + }
146 changeParams(year, month, operation); 152 changeParams(year, month, operation);
147 getData(); 153 getData();
148 } 154 }
...@@ -169,7 +175,7 @@ function init() { ...@@ -169,7 +175,7 @@ function init() {
169 var date = getTodayDate().split("-"); 175 var date = getTodayDate().split("-");
170 year = date[0]; 176 year = date[0];
171 month = date[1]; 177 month = date[1];
172 - operation = "getHoliDeInfo"; 178 + operation = "getRestDeInfo";
173 changeParams(year, month, operation); 179 changeParams(year, month, operation);
174 // Get data from holiday api 180 // Get data from holiday api
175 getData(); 181 getData();
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
28 </p> 28 </p>
29 </div> 29 </div>
30 </div> 30 </div>
31 +<<<<<<< HEAD
31 <h2> [<%= data[0] %>] 추천 활동</h2> <!--recommend activity 추가파트 시작--> 32 <h2> [<%= data[0] %>] 추천 활동</h2> <!--recommend activity 추가파트 시작-->
32 33
33 <div id="activity"> 34 <div id="activity">
...@@ -39,13 +40,62 @@ ...@@ -39,13 +40,62 @@
39 <h2>2. 놀이공원 </h2> 40 <h2>2. 놀이공원 </h2>
40 <h2>3. 서울숲</h2> 41 <h2>3. 서울숲</h2>
41 <% } else if (data[1] == '20220606') { %> 42 <% } else if (data[1] == '20220606') { %>
43 +=======
44 + <h2> <%= data[0] %> 에 추천하는 활동 목록입니다.</h2> <!--recommend activity 추가파트 시작-->
45 +
46 + <div id="activity">
47 +
48 + <% if (data[0] == '전국동시지방선거') { %>
49 + <h2>1. 투표하세요.</h2>
50 + <h2>2. 투표날이 어렵다면 사전투표하세요.</h2>
51 +
52 + <% } else if (data[0] == '어린이날') { %>
53 + <h2>1. 어린이날 즐기기.</h2>
54 + <h2>2. 놀이공원 </h2>
55 + <h2>3. 서울숲</h2>
56 +
57 + <% } else if (data[0] == '현충일') { %>
58 +>>>>>>> ae2e4eac4bff94c5b55f982450db9baabf3fab50
42 <h2>1. 현충원 가기.</h2> 59 <h2>1. 현충원 가기.</h2>
43 <h2>2. 전쟁기념관 방문.</h2> 60 <h2>2. 전쟁기념관 방문.</h2>
44 <h2>3. 어린이날 즐기기.</h2> 61 <h2>3. 어린이날 즐기기.</h2>
45 62
63 +<<<<<<< HEAD
46 <% } else if (data[1] == '20220508') { %> 64 <% } else if (data[1] == '20220508') { %>
47 <h2>절 가기.</h2> 65 <h2>절 가기.</h2>
48 66
67 +=======
68 + <% } else if (data[0] == '석가탄신일') { %>
69 + <h2>절 가기.</h2>
70 + <% } else if (data[0] == '부처님오신날') { %>
71 + <h2>절 가기.</h2>
72 + <% } else if (data[0] == '1월1일') { %>
73 + <h2>Happy new year!</h2>
74 + <% } else if (data[0] == '설날') { %>
75 + <h2>새해 복 많이 받으세요.</h2>
76 + <% } else if (data[0] == '삼일절') { %>
77 + <h2>대한독립만세</h2>
78 + <% } else if (data[0] == '광복절') { %>
79 + <h2>대한독립만세</h2>
80 + <% } else if (data[0] == '추석') { %>
81 + <h2>추석입니다. 풍요로운 한가위 되세요.</h2>
82 + <% } else if (data[0] == '개천절') { %>
83 + <h2>개천절입니다.</h2>
84 + <% } else if (data[0] == '한글날') { %>
85 + <h2>바른말 고운말</h2>
86 + <% } else if (data[0] == '기독탄신일') { %>
87 + <h2>메리 크리스마스!</h2>
88 + <% } else if (data[0] == '임시공휴일') {%>
89 + <h2> 보너스 휴일 </h2>
90 + <% } else if (data[0] == '대체공휴일') {%>
91 + <h2> 보너스 휴일 </h2>
92 + <% } else if (data[0] == '대체휴무일') {%>
93 + <h2> 보너스 휴일 </h2>
94 + <% } else if (data[0] == '대통령선거일') {%>
95 + <h2>1. 투표하세요.</h2>
96 + <h2>2. 투표날이 어렵다면 사전투표하세요.</h2>
97 +
98 +>>>>>>> ae2e4eac4bff94c5b55f982450db9baabf3fab50
49 <% } else { %> 99 <% } else { %>
50 <h2>Just Take some rest!.</h2> 100 <h2>Just Take some rest!.</h2>
51 101
...@@ -54,8 +104,13 @@ ...@@ -54,8 +104,13 @@
54 104
55 105
56 106
107 +<<<<<<< HEAD
108 +=======
109 +
110 +
111 +>>>>>>> ae2e4eac4bff94c5b55f982450db9baabf3fab50
57 </div> 112 </div>
58 - <div id="loading"><div class="spinner"></div></div> 113 +
59 </body> 114 </body>
60 </center> 115 </center>
61 </html> 116 </html>
...\ No newline at end of file ...\ No newline at end of file
......