박지환

Change api operation

......@@ -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
var SERVEICE_KEY =
......@@ -38,7 +38,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;
}
......@@ -54,7 +54,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();
......@@ -117,7 +117,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
......@@ -139,8 +139,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();
}
......@@ -167,7 +173,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();
......