박종현

Update feature/holiday-counter into server.js

Showing 1 changed file with 15 additions and 0 deletions
...@@ -74,6 +74,19 @@ function init() { ...@@ -74,6 +74,19 @@ function init() {
74 locdate.push(tempStr); 74 locdate.push(tempStr);
75 idx = text.indexOf("locdate", idx + 1); 75 idx = text.indexOf("locdate", idx + 1);
76 } 76 }
77 + let i = 0;
78 + let length = dateName.length;
79 + while (i < length){
80 + var temptoday = dateName[i];
81 + var tempdate = locdate[i];
82 + var modifiedDate = tempdate.substr(0,4) + '-' + tempdate.substr(4,2) + '-' + tempdate.substr(6,2);
83 + var today = new Date("2022-05-13"); //오늘 날짜 입력
84 + var holiday = new Date(modifiedDate); //공휴일 날짜 입력
85 + var diffDate= today.getTime() - holiday.getTime();
86 + var dday= Math.abs(diffDate / (1000 * 3600 * 24));
87 + console.log(temptoday + "까지 " + dday +"일 남았습니다.");
88 + i++;
89 + }
77 console.log(locdate); 90 console.log(locdate);
78 // Create tempArr to save dateName and locdate at once 91 // Create tempArr to save dateName and locdate at once
79 tempArr = []; 92 tempArr = [];
...@@ -86,6 +99,8 @@ function init() { ...@@ -86,6 +99,8 @@ function init() {
86 }); 99 });
87 } 100 }
88 101
102 +
103 +
89 app.get("/", function (req, res) { 104 app.get("/", function (req, res) {
90 init(); 105 init();
91 // Send data from nodejs to ejs 106 // Send data from nodejs to ejs
......