박종현

Update feature/holiday-counter into server.js

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