박종현

Update holiday date logic

......@@ -2,7 +2,7 @@
---
공휴일·기념일 카운터 및 활동 추천
공휴일 카운터 및 활동 추천
## Getting Started (Installation)
......
......@@ -9,13 +9,14 @@
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"ejs": "^3.1.7",
"ejs": "^3.1.8",
"express": "^4.18.1",
"fs": "^0.0.1-security",
"request": "^2.88.2",
"xml-js": "^1.6.11",
"xml2js": "^0.4.23"
}
},
"devDependencies": {}
},
"node_modules/accepts": {
"version": "1.3.8",
......@@ -315,9 +316,9 @@
"integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0="
},
"node_modules/ejs": {
"version": "3.1.7",
"resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.7.tgz",
"integrity": "sha512-BIar7R6abbUxDA3bfXrO4DSgwo8I+fB5/1zgujl3HLLjwd6+9iOnrT+t3grn2qbk9vOgBubXOFwX2m9axoFaGw==",
"version": "3.1.8",
"resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.8.tgz",
"integrity": "sha512-/sXZeMlhS0ArkfX2Aw780gJzXSMPnKjtspYZv+f3NiKLlubezAHDU5+9xz6gd3/NhG3txQCo6xlglmTS+oTGEQ==",
"dependencies": {
"jake": "^10.8.5"
},
......@@ -1412,9 +1413,9 @@
"integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0="
},
"ejs": {
"version": "3.1.7",
"resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.7.tgz",
"integrity": "sha512-BIar7R6abbUxDA3bfXrO4DSgwo8I+fB5/1zgujl3HLLjwd6+9iOnrT+t3grn2qbk9vOgBubXOFwX2m9axoFaGw==",
"version": "3.1.8",
"resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.8.tgz",
"integrity": "sha512-/sXZeMlhS0ArkfX2Aw780gJzXSMPnKjtspYZv+f3NiKLlubezAHDU5+9xz6gd3/NhG3txQCo6xlglmTS+oTGEQ==",
"requires": {
"jake": "^10.8.5"
}
......
......@@ -39,9 +39,15 @@ h3 {
font-weight: 600;
}
#activity {
<<<<<<< HEAD
width:1000px;
height:fit-content;
border-radius: 10p 10px / 10px 10px;
=======
width:fit-content;
height:fit-content;
border-radius: 40px 80px / 80px 40px;
>>>>>>> ae2e4eac4bff94c5b55f982450db9baabf3fab50
background-color: rgba(197, 97, 201, 0.486);
}
body {
......
......@@ -9,7 +9,7 @@ const static = require("serve-static");
// Modify the values as needed
var year = "2022";
var month = "09";
var operation = "getHoliDeInfo";
var operation = "getRestDeInfo";
// Do not modify the values
......@@ -40,7 +40,7 @@ function getTodayDate() {
var month = ("0" + (today.getMonth() + 1)).slice(-2);
var day = ("0" + today.getDate()).slice(-2);
var dateString = year + "-" + month + "-" + day;
// return "2022-10-04"; // 테스트용 날짜를 입력하세요. 테스트가 끝나면 주석처리 하세요. ex) 2022-09-12, 2022-09-15, 2022-10-04
// return "2022-12-27"; // 테스트용 날짜를 입력하세요. 테스트가 끝나면 주석처리 하세요. ex) 2022-09-12, 2022-09-15, 2022-10-04
return dateString;
}
......@@ -56,7 +56,7 @@ function getModifiedDate(locdate) {
}
// To get remaining days from locdate
function getLeftDate(dateName, locdate) {
function getLeftDate(locdate) {
var today = new Date(getTodayDate()); // today date
var holiday = new Date(getModifiedDate(locdate)); // holiday date
var diffDate = today.getTime() - holiday.getTime();
......@@ -119,7 +119,7 @@ function getData() {
console.log(locdate);
var holiArr = [];
for (var i = 0; i < dateName.length; i++) {
holiArr.push(getLeftDate(dateName[i], locdate[i]));
holiArr.push(getLeftDate(locdate[i]));
}
console.log(holiArr);
// Create tempArr to save dateName and locdate and leftDate at once
......@@ -141,8 +141,14 @@ function getData() {
console.log(
"이번 달에는 남은 공휴일이 없습니다. 다음달 데이터를 불러옵니다."
);
// Get next month data
month = String(Number(month) + 1).padStart(2, "0");
if (Number(month) < 12) {
// Get next month data
month = String(Number(month) + 1).padStart(2, "0");
} else {
// Get next year data
year = String(Number(year) + 1).padStart(4, "0");
month = "01";
}
changeParams(year, month, operation);
getData();
}
......@@ -169,7 +175,7 @@ function init() {
var date = getTodayDate().split("-");
year = date[0];
month = date[1];
operation = "getHoliDeInfo";
operation = "getRestDeInfo";
changeParams(year, month, operation);
// Get data from holiday api
getData();
......
......@@ -28,6 +28,7 @@
</p>
</div>
</div>
<<<<<<< HEAD
<h2> [<%= data[0] %>] 추천 활동</h2> <!--recommend activity 추가파트 시작-->
<div id="activity">
......@@ -39,13 +40,62 @@
<h2>2. 놀이공원 </h2>
<h2>3. 서울숲</h2>
<% } else if (data[1] == '20220606') { %>
=======
<h2> <%= data[0] %> 에 추천하는 활동 목록입니다.</h2> <!--recommend activity 추가파트 시작-->
<div id="activity">
<% if (data[0] == '전국동시지방선거') { %>
<h2>1. 투표하세요.</h2>
<h2>2. 투표날이 어렵다면 사전투표하세요.</h2>
<% } else if (data[0] == '어린이날') { %>
<h2>1. 어린이날 즐기기.</h2>
<h2>2. 놀이공원 </h2>
<h2>3. 서울숲</h2>
<% } else if (data[0] == '현충일') { %>
>>>>>>> ae2e4eac4bff94c5b55f982450db9baabf3fab50
<h2>1. 현충원 가기.</h2>
<h2>2. 전쟁기념관 방문.</h2>
<h2>3. 어린이날 즐기기.</h2>
<<<<<<< HEAD
<% } else if (data[1] == '20220508') { %>
<h2>절 가기.</h2>
=======
<% } else if (data[0] == '석가탄신일') { %>
<h2>절 가기.</h2>
<% } else if (data[0] == '부처님오신날') { %>
<h2>절 가기.</h2>
<% } else if (data[0] == '1월1일') { %>
<h2>Happy new year!</h2>
<% } else if (data[0] == '설날') { %>
<h2>새해 복 많이 받으세요.</h2>
<% } else if (data[0] == '삼일절') { %>
<h2>대한독립만세</h2>
<% } else if (data[0] == '광복절') { %>
<h2>대한독립만세</h2>
<% } else if (data[0] == '추석') { %>
<h2>추석입니다. 풍요로운 한가위 되세요.</h2>
<% } else if (data[0] == '개천절') { %>
<h2>개천절입니다.</h2>
<% } else if (data[0] == '한글날') { %>
<h2>바른말 고운말</h2>
<% } else if (data[0] == '기독탄신일') { %>
<h2>메리 크리스마스!</h2>
<% } else if (data[0] == '임시공휴일') {%>
<h2> 보너스 휴일 </h2>
<% } else if (data[0] == '대체공휴일') {%>
<h2> 보너스 휴일 </h2>
<% } else if (data[0] == '대체휴무일') {%>
<h2> 보너스 휴일 </h2>
<% } else if (data[0] == '대통령선거일') {%>
<h2>1. 투표하세요.</h2>
<h2>2. 투표날이 어렵다면 사전투표하세요.</h2>
>>>>>>> ae2e4eac4bff94c5b55f982450db9baabf3fab50
<% } else { %>
<h2>Just Take some rest!.</h2>
......@@ -54,8 +104,13 @@
<<<<<<< HEAD
=======
>>>>>>> ae2e4eac4bff94c5b55f982450db9baabf3fab50
</div>
<div id="loading"><div class="spinner"></div></div>
</body>
</center>
</html>
\ No newline at end of file
......