박종현

Merge branch 'feature/holiday-counter'

1 +{
2 + // IntelliSense를 사용하여 가능한 특성에 대해 알아보세요.
3 + // 기존 특성에 대한 설명을 보려면 가리킵니다.
4 + // 자세한 내용을 보려면 https://go.microsoft.com/fwlink/?linkid=830387을(를) 방문하세요.
5 + "version": "0.2.0",
6 + "configurations": [
7 + {
8 + "type": "pwa-node",
9 + "request": "launch",
10 + "name": "Launch Program",
11 + "skipFiles": [
12 + "<node_internals>/**"
13 + ],
14 + "program": "${workspaceFolder}\\app.js"
15 + }
16 + ]
17 +}
...\ No newline at end of file ...\ No newline at end of file
1 +const today = new Date("2022-05-12"); //오늘 날짜 입력
2 +const holiday = new Date("2022-10-01"); //공휴일 날짜 입력
3 +
4 +const diffDate= today.getTime() - holiday.getTime();
5 +
6 +const dday= Math.abs(diffDate / (1000 * 3600 * 24));
7 +
8 +console.log(dday);
...\ No newline at end of file ...\ No newline at end of file
...@@ -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
......