Showing
1 changed file
with
13 additions
and
7 deletions
... | @@ -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 | // Do not modify the values | 14 | // Do not modify the values |
15 | var SERVEICE_KEY = | 15 | var SERVEICE_KEY = |
... | @@ -38,7 +38,7 @@ function getTodayDate() { | ... | @@ -38,7 +38,7 @@ function getTodayDate() { |
38 | var month = ("0" + (today.getMonth() + 1)).slice(-2); | 38 | var month = ("0" + (today.getMonth() + 1)).slice(-2); |
39 | var day = ("0" + today.getDate()).slice(-2); | 39 | var day = ("0" + today.getDate()).slice(-2); |
40 | var dateString = year + "-" + month + "-" + day; | 40 | var dateString = year + "-" + month + "-" + day; |
41 | - // return "2022-10-04"; // 테스트용 날짜를 입력하세요. 테스트가 끝나면 주석처리 하세요. ex) 2022-09-12, 2022-09-15, 2022-10-04 | 41 | + // return "2022-12-27"; // 테스트용 날짜를 입력하세요. 테스트가 끝나면 주석처리 하세요. ex) 2022-09-12, 2022-09-15, 2022-10-04 |
42 | return dateString; | 42 | return dateString; |
43 | } | 43 | } |
44 | 44 | ||
... | @@ -54,7 +54,7 @@ function getModifiedDate(locdate) { | ... | @@ -54,7 +54,7 @@ function getModifiedDate(locdate) { |
54 | } | 54 | } |
55 | 55 | ||
56 | // To get remaining days from locdate | 56 | // To get remaining days from locdate |
57 | -function getLeftDate(dateName, locdate) { | 57 | +function getLeftDate(locdate) { |
58 | var today = new Date(getTodayDate()); // today date | 58 | var today = new Date(getTodayDate()); // today date |
59 | var holiday = new Date(getModifiedDate(locdate)); // holiday date | 59 | var holiday = new Date(getModifiedDate(locdate)); // holiday date |
60 | var diffDate = today.getTime() - holiday.getTime(); | 60 | var diffDate = today.getTime() - holiday.getTime(); |
... | @@ -117,7 +117,7 @@ function getData() { | ... | @@ -117,7 +117,7 @@ function getData() { |
117 | console.log(locdate); | 117 | console.log(locdate); |
118 | var holiArr = []; | 118 | var holiArr = []; |
119 | for (var i = 0; i < dateName.length; i++) { | 119 | for (var i = 0; i < dateName.length; i++) { |
120 | - holiArr.push(getLeftDate(dateName[i], locdate[i])); | 120 | + holiArr.push(getLeftDate(locdate[i])); |
121 | } | 121 | } |
122 | console.log(holiArr); | 122 | console.log(holiArr); |
123 | // Create tempArr to save dateName and locdate and leftDate at once | 123 | // Create tempArr to save dateName and locdate and leftDate at once |
... | @@ -139,8 +139,14 @@ function getData() { | ... | @@ -139,8 +139,14 @@ function getData() { |
139 | console.log( | 139 | console.log( |
140 | "이번 달에는 남은 공휴일이 없습니다. 다음달 데이터를 불러옵니다." | 140 | "이번 달에는 남은 공휴일이 없습니다. 다음달 데이터를 불러옵니다." |
141 | ); | 141 | ); |
142 | - // Get next month data | 142 | + if (Number(month) < 12) { |
143 | - month = String(Number(month) + 1).padStart(2, "0"); | 143 | + // Get next month data |
144 | + month = String(Number(month) + 1).padStart(2, "0"); | ||
145 | + } else { | ||
146 | + // Get next year data | ||
147 | + year = String(Number(year) + 1).padStart(4, "0"); | ||
148 | + month = "01"; | ||
149 | + } | ||
144 | changeParams(year, month, operation); | 150 | changeParams(year, month, operation); |
145 | getData(); | 151 | getData(); |
146 | } | 152 | } |
... | @@ -167,7 +173,7 @@ function init() { | ... | @@ -167,7 +173,7 @@ function init() { |
167 | var date = getTodayDate().split("-"); | 173 | var date = getTodayDate().split("-"); |
168 | year = date[0]; | 174 | year = date[0]; |
169 | month = date[1]; | 175 | month = date[1]; |
170 | - operation = "getHoliDeInfo"; | 176 | + operation = "getRestDeInfo"; |
171 | changeParams(year, month, operation); | 177 | changeParams(year, month, operation); |
172 | // Get data from holiday api | 178 | // Get data from holiday api |
173 | getData(); | 179 | getData(); | ... | ... |
-
Please register or login to post a comment